Exemplo n.º 1
0
        public static double Evaluate(string expression)
        {
            var lexer = new CalculatorLexer(new AntlrInputStream(expression));

            lexer.RemoveErrorListeners();
            lexer.AddErrorListener(new ThrowExceptionErrorListener());

            var tokens = new CommonTokenStream(lexer);
            var parser = new CalculatorParser(tokens);

            var tree = parser.compileUnit();

            var visitor = new ExcelVisitor();

            return(visitor.Visit(tree));
        }