Пример #1
0
        public static QueryParser.ProgramContext Parse(string query)
        {
            var lexer = new QueryLexer(new AntlrInputStream(query));

            lexer.RemoveErrorListeners();
            lexer.AddErrorListener(new ThrowingErrorListener <int>());

            var parser = new QueryParser(new CommonTokenStream(lexer));

            parser.RemoveErrorListeners();
            parser.AddErrorListener(new ThrowingErrorListener <IToken>());

            return(parser.program());
        }
Пример #2
0
        internal virtual T QueryParse <T>(ref string s, Func <QueryParser, T> func)
            where T : RuleContext
        {
            var stream = new AntlrInputStream(s);
            var lexer  = new QueryLexer(stream);

            lexer.RemoveErrorListeners();
            var tokens = new CommonTokenStream(lexer);
            var parser = new QueryParser(tokens)
            {
                ErrorHandler = new BailErrorStrategy()
            };

            parser.RemoveErrorListeners();
            return(Check(ref s, func(parser)));
        }