public UnitTest1() { _grammar = LoadGrammar.LoadFromFile($@"{projectDirectory}/examples/ex2.json").ToGrammar(); LeftRecursionResolver.ResolveIndirectRecursion(_grammar); LanguageUtils.RemoveLeftFactoring(_grammar); LanguageUtils.RemoveEPS(ref _grammar); }
static void Main(string[] args) { var grammar = LoadGrammar.LoadFromFile(@"./examples/ex2.json").ToGrammar(); Console.WriteLine(grammar.ToString()); LeftRecursionResolver.ResolveIndirectRecursion(grammar); LanguageUtils.RemoveLeftFactoring(grammar); LanguageUtils.RemoveEPS(ref grammar); Console.WriteLine(grammar.ToString()); var parser = new LL1Parser(grammar); Console.WriteLine(parser.ProcessText("a + b cvcvx = ( b - c )")); parser.PrintTree(@"./tree.gv"); }