/// <summary> /// Reverses the grammar such that, when created into a parse table, can parse input backwards. /// </summary> /// <returns>A new context free grammar object that represents the reversed form of this grammar.</returns> public ContextFreeGrammar <T> Reverse() { //Copy the grammar. ContextFreeGrammar <T> grammar = this.DeepCopy(); foreach (Production <T> production in grammar.Productions) { production.DerivedElements.Reverse(); } return(grammar); }
public bool Equals(ContextFreeGrammar <T> other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(StartElement.Equals(other.StartElement) && EndOfInputElement.Equals(other.EndOfInputElement) && Productions.SequenceEqual(other.Productions)); }