示例#1
0
 public UnitTest1()
 {
     _grammar = LoadGrammar.LoadFromFile($@"{projectDirectory}/examples/ex2.json").ToGrammar();
     LeftRecursionResolver.ResolveIndirectRecursion(_grammar);
     LanguageUtils.RemoveLeftFactoring(_grammar);
     LanguageUtils.RemoveEPS(ref _grammar);
 }
示例#2
0
        public void Test3()
        {
            var grammar         = Grammar.LoadFromFile(@"/home/pacman29/Рабочий стол/cc-lab1/TestCCLab2/testGrammars/dragon.json");
            var expectedGrammar = Grammar.LoadFromFile(@"/home/pacman29/Рабочий стол/cc-lab1/TestCCLab2/testExpectedGrammars/dragon.json");

            LeftRecursionResolver.ResolveIndirectRecursion(grammar);
            _testOutputHelper.WriteLine("Dragon test:");
            _testOutputHelper.WriteLine(grammar.ToString());
            Assert.Equal(expectedGrammar, grammar);
        }
示例#3
0
        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");
        }