Exemple #1
0
 //Check if regular grammars are the same
 public bool Equals(RegGrammar <T> other)
 {
     if (other == null)
     {
         return(false);
     }
     else if (this.ToString() == other.ToString() && this.startSymbol == other.startSymbol && this.ProductRules == other.ProductRules && this.symbols == other.symbols)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public static RegGrammar <String> getExample0()
        {
            HashSet <ProductRule <String> > rules = new HashSet <ProductRule <String> >();

            rules.Add(new ProductRule <string>("S", 'a', "B"));
            rules.Add(new ProductRule <string>("S", 'a', "A"));
            rules.Add(new ProductRule <string>("S", 'b', "B"));

            rules.Add(new ProductRule <string>("A", 'b', "B"));
            rules.Add(new ProductRule <string>("A", 'a', ""));

            rules.Add(new ProductRule <string>("B", 'a', "A"));
            rules.Add(new ProductRule <string>("B", 'b', ""));
            rules.Add(new ProductRule <string>("B", 'a', "B"));

            RegGrammar <String> g = new RegGrammar <String>("S", rules);

            return(g);
        }