コード例 #1
0
ファイル: ANTLRDebug.cs プロジェクト: c272/stork-lang
        //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
ファイル: ANTLRDebug.cs プロジェクト: c272/stork-lang
        //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");
        }