public int CompareTo(SymbolString other) { if (other == null) { return(1); } if (other.Count < Count) { return(1); } if (other.Count > Count) { return(-1); } for (int i = 0; i < this.Count; i++) { var cp = this[i].CompareTo(other[i]); if (cp != 0) { return(cp); } } return(0); }
public static SymbolString Concat(SymbolString symbolString, TerminalSymbol symbol) { List <Symbol> symbols = new List <Symbol>(symbolString); if (symbol != null) { symbols.Add(symbol); } return(new SymbolString(symbols)); }
public HashSet <TerminalSymbol> GetNextLookaheads(GrammarProductionDatabase db) { if (ParsingPoint == (Production.Body.Count - 1)) { return new HashSet <TerminalSymbol> { Lookahead } } ; return(SymbolString.Concat(Production.Body.Range(ParsingPoint + 1), Lookahead).FirstSet(db)); } }
public bool Equals(SymbolString other) { if (other == null) { return(false); } if (this.Count != other.Count) { return(false); } for (int i = 0; i < other.Count; i++) { if (this[i] != other[i]) { return(false); } } return(true); }
public GrammarProduction(NonterminalSymbol head, SymbolString body) { this.Head = head; this.Body = body; }