Пример #1
0
        /// <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);
        }
Пример #2
0
 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));
 }