예제 #1
0
        //Returns the whole Stork tree.
        public static storkParser.CompileUnitContext GetTree(string testString)
        {
            var chars  = new AntlrInputStream(testString);
            var lexer  = new storkLexer(chars);
            var tokens = new CommonTokenStream(lexer);
            var parser = new storkParser(tokens);

            return(parser.compileUnit());
        }
예제 #2
0
        //Prints the entire processed ANTLR parse tree to console.
        public static void PrintParseList(string testString)
        {
            //Creating parser.
            var chars  = new AntlrInputStream(testString);
            var lexer  = new storkLexer(chars);
            var tokens = new CommonTokenStream(lexer);
            var parser = new storkParser(tokens);
            var tree   = parser.compileUnit();

            //Printing parse tree.
            Console.WriteLine("ANTLR Parse Tree:");
            Console.WriteLine(tree.ToStringTree(parser));
            Console.WriteLine("Total Statements: " + tree.block().statement().Length + "\n");
        }