Inheritance: Antlr.Runtime.Lexer
Ejemplo n.º 1
0
        public static ParseResult Parse(string expression)
        {
            try
            {
                var inputStream = new ANTLRStringStream(expression);

                var lexer       = new CsharpLexer(inputStream);
                var tokenStream = new CommonTokenStream(lexer);
                var parser      = new CsharpParser(tokenStream);

                var progResult = parser.prog();
                var result     = progResult.value;

                return(new ParseResult(result, parser._identifiers));
            }
            catch (ExpressionsException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ExpressionsException("Compilation failed", ExpressionsExceptionType.SyntaxError, ex);
            }
        }
Ejemplo n.º 2
0
        public static ParseResult Parse(string expression)
        {
            try
            {
                var inputStream = new ANTLRStringStream(expression);

                var lexer = new CsharpLexer(inputStream);
                var tokenStream = new CommonTokenStream(lexer);
                var parser = new CsharpParser(tokenStream);

                var progResult = parser.prog();
                var result = progResult.value;

                return new ParseResult(result, parser._identifiers);
            }
            catch (ExpressionsException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new ExpressionsException("Compilation failed", ExpressionsExceptionType.SyntaxError, ex);
            }
        }