Beispiel #1
0
        static void ExampleTwo()
        {
            AntlrInputStream input = new AntlrInputStream(File.Open("t.expr", FileMode.Open));

            ExprLexer         lexer       = new ExprLexer(input);
            CommonTokenStream tokenStream = new CommonTokenStream(lexer);
            ExprParser        parser      = new ExprParser(tokenStream);

            IParseTree    tree    = parser.prog();
            MyExprVisitor visitor = new MyExprVisitor();

            visitor.Visit(tree);
            Console.Read();
        }
Beispiel #2
0
        static void ExampleOne()
        {
            AntlrInputStream input = new AntlrInputStream(File.Open("t.expr", FileMode.Open));

            ExprLexer         lexer       = new ExprLexer(input);
            CommonTokenStream tokenStream = new CommonTokenStream(lexer);
            ExprParser        parser      = new ExprParser(tokenStream);

            IParseTree tree = parser.prog();

            string output = tree.ToStringTree(parser).Replace("\\n", "\n");            //Environment.NewLine);

            Console.Write(output);
            Console.Read();
        }