Beispiel #1
0
        public object Evaluate(string expression)
        {
            AntlrInputStream  input       = new AntlrInputStream(expression);
            MegaScryptLexer   lexer       = new MegaScryptLexer(input);
            CommonTokenStream tokenStream = new CommonTokenStream(lexer);
            MegaScryptParser  parser      = new MegaScryptParser(tokenStream);

            MegaScryptParser.ExpressionContext root = parser.expression();
            object result = root.Accept(_processor);

            return(result);
        }
Beispiel #2
0
        public object Execute(string script)
        {
            AntlrInputStream  input       = new AntlrInputStream(script);
            MegaScryptLexer   lexer       = new MegaScryptLexer(input);
            CommonTokenStream tokenStream = new CommonTokenStream(lexer);
            MegaScryptParser  parser      = new MegaScryptParser(tokenStream);

            parser.AddErrorListener(new ThrowErrorListener());

            MegaScryptParser.ProgramContext root = parser.program();
            object result = root.Accept(_processor);

            return(result);
        }