Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. if let Some(following_nonterminals) = indirections.get(&elem) {
  2. for &(other, idx, rule) in following_nonterminals.iter() {
  3. if !result.contains_key(&other) { continue; }
  4.  
  5. let mut copy = HashSet::new();
  6. let mut needs_next = false;
  7. { // Lifetimes woo
  8. let other_first_set = result.get(&other).unwrap();
  9. for &term in other_first_set.iter() {
  10. match term {
  11. ProdElem::Epsilon => needs_next = true,
  12. _ => { copy.insert(term); }
  13. }
  14. }
  15. }
  16.  
  17. if needs_next {
  18. if idx < rule.len() - 1 && !following_nonterminals.contains(&(rule[idx+1], idx + 1, rule)) {
  19. if Grammar::analyze_rule_for_first(rule, idx + 1, result.get_mut(&elem).unwrap(), indirections.get_mut(&elem).unwrap()) {
  20. dirty = true
  21. }
  22. } else if idx == rule.len() - 1 && !result.get(&elem).unwrap().contains(&ProdElem::Epsilon) {
  23. result.get_mut(&elem).unwrap().insert(ProdElem::Epsilon);
  24. dirty = true;
  25. }
  26. }
  27.  
  28. for &c in copy.iter() {
  29. if !result.get_mut(&elem).unwrap().contains(&c) {
  30. result.get_mut(&elem).unwrap().insert(c);
  31. dirty = true;
  32. }
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement