private IEnumerable <int> GetOutTokens(IDotItemSet itemSet) { foreach (var item in itemSet) { if (!item.IsReduce) { yield return(item.NextToken); } } }
// TODO: Performance private static void CollectClosureLookaheads(IDotItemSet result, GrammarAnalysis grammar) { int count = result.Count; if (count == 0) { return; } bool modified; // Debug.WriteLine("closured lookeads: item count = {0}", result.Count); do { modified = false; for (int i = 0; i != count; ++i) { var fromItem = result[i]; if (!fromItem.IsReduce) { for (int j = 0; j != count; ++j) { var toItem = result[j]; if (fromItem.NextToken == toItem.Outcome) { int countBefore = 0; if (!modified) { countBefore = toItem.LA.Count; } grammar.AddFirst(fromItem.CreateNextItem(), toItem.LA); if (!modified) { modified = toItem.LA.Count != countBefore; } } } } } if (modified) { // Debug.WriteLine("closured lookaheads: extra pass"); } }while (modified); }
// TODO: Performance private static void CollectClosureLookaheads(IDotItemSet result, GrammarAnalysis grammar) { int count = result.Count; if (count == 0) { return; } bool modified; // Debug.WriteLine("closured lookeads: item count = {0}", result.Count); do { modified = false; for (int i = 0; i != count; ++i) { var fromItem = result[i]; if (!fromItem.IsReduce) { for (int j = 0; j != count; ++j) { var toItem = result[j]; if (fromItem.NextToken == toItem.Outcome) { int countBefore = 0; if (!modified) { countBefore = toItem.LA.Count; } grammar.AddFirst(fromItem.CreateNextItem(), toItem.LA); if (!modified) { modified = toItem.LA.Count != countBefore; } } } } } if (modified) { // Debug.WriteLine("closured lookaheads: extra pass"); } } while (modified); }
public bool Equals(IDotItemSet other) { if (other == null || Count != other.Count) { return(false); } for (int i = 0; i != Count; ++i) { if (this[i] != other[i]) { return(false); } } return(true); }
public bool Equals(IDotItemSet other) { if (other == null || Count != other.Count) { return false; } for (int i = 0; i != Count; ++i) { if (this[i] != other[i]) { return false; } } return true; }
private IEnumerable<int> GetOutTokens(IDotItemSet itemSet) { foreach (var item in itemSet) { if (!item.IsReduce) { yield return item.NextToken; } } }
public DotState(int index, IEnumerable <DotItem> dotItems) { this.index = index; this.Items = new MutableDotItemSet(dotItems); }
public DotState(int index) { this.index = index; this.Items = new MutableDotItemSet(); }