Exemplo n.º 1
0
        protected static IParseTree AntlrParse(string expression)
        {
            var inputStream = new AntlrInputStream(expression);
            var lexer       = new ExpressionLexer(inputStream);

            lexer.RemoveErrorListeners();
            var tokenStream = new CommonTokenStream(lexer);
            var parser      = new ExpressionParser(tokenStream);

            parser.RemoveErrorListeners();
            parser.AddErrorListener(ParserErrorListener.Instance);
            parser.BuildParseTree = true;
            return(parser.file()?.expression());
        }