Пример #1
0
        public Result Evaluate(string formula)
        {
            var stream = new AntlrInputStream(formula);
            var lexer  = new ExpressionLexer(stream);
            var tokens = new CommonTokenStream(lexer);
            var parser = new ExpressionParser(tokens);
            var tree   = parser.program();

            Result result = Visit(tree);

            return(result);
        }
Пример #2
0
        internal Result Execute(string formula, out IParseTree tree)
        {
            ErrorListener listener = new ErrorListener();

            listener.Owner        = Owner;
            listener.ErrorOutput += ErrorOutput;

            var stream = new AntlrInputStream(formula);
            var lexer  = new ExpressionLexer(stream);
            var tokens = new CommonTokenStream(lexer);
            var parser = new ExpressionParser(tokens);

            parser.AddErrorListener(listener);

            tree = parser.program();

            return(Visit(tree));
        }