public override Node VisitLiteralExpression(LiteralExpressionContext context)
 {
     return(new LiteralNode(context.Start, context.literal().GetText(), QLTypeConverter.FromTokenTypeToQLType(context.Start)));
 }
Exemple #2
0
    private ExprContext expr(int _p)
    {
        ParserRuleContext _parentctx = Context;
        int         _parentState     = State;
        ExprContext _localctx        = new ExprContext(Context, _parentState);
        ExprContext _prevctx         = _localctx;
        int         _startState      = 0;

        EnterRecursionRule(_localctx, 0, RULE_expr, _p);
        int _la;

        try {
            int _alt;
            EnterOuterAlt(_localctx, 1);
            {
                State = 23;
                ErrorHandler.Sync(this);
                switch (Interpreter.AdaptivePredict(TokenStream, 0, Context))
                {
                case 1:
                {
                    _localctx = new IfExpressionContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;

                    State = 11; ifexpr();
                }
                break;

                case 2:
                {
                    _localctx = new FunctionExpressionContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 12; function();
                }
                break;

                case 3:
                {
                    _localctx = new LiteralExpressionContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 13; literal();
                }
                break;

                case 4:
                {
                    _localctx = new FieldExpressionContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 14; field();
                }
                break;

                case 5:
                {
                    _localctx = new NotExpressionContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 15; Match(T__0);
                    State     = 16; expr(9);
                }
                break;

                case 6:
                {
                    _localctx = new NegateExpressionContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 17; Match(T__1);
                    State     = 18; expr(8);
                }
                break;

                case 7:
                {
                    _localctx = new BracketedExpressionContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 19; Match(T__2);
                    State     = 20; expr(0);
                    State     = 21; Match(T__3);
                }
                break;
                }
                Context.Stop = TokenStream.LT(-1);
                State        = 45;
                ErrorHandler.Sync(this);
                _alt = Interpreter.AdaptivePredict(TokenStream, 2, Context);
                while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER)
                {
                    if (_alt == 1)
                    {
                        if (ParseListeners != null)
                        {
                            TriggerExitRuleEvent();
                        }
                        _prevctx = _localctx;
                        {
                            State = 43;
                            ErrorHandler.Sync(this);
                            switch (Interpreter.AdaptivePredict(TokenStream, 1, Context))
                            {
                            case 1:
                            {
                                _localctx = new MulDivExpressionContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 25;
                                if (!(Precpred(Context, 6)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 6)");
                                }
                                State = 26;
                                _la   = TokenStream.LA(1);
                                if (!(_la == T__4 || _la == T__5))
                                {
                                    ErrorHandler.RecoverInline(this);
                                }
                                else
                                {
                                    ErrorHandler.ReportMatch(this);
                                    Consume();
                                }
                                State = 27; expr(7);
                            }
                            break;

                            case 2:
                            {
                                _localctx = new AddSubExpressionContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 28;
                                if (!(Precpred(Context, 5)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 5)");
                                }
                                State = 29;
                                _la   = TokenStream.LA(1);
                                if (!(_la == T__1 || _la == T__6))
                                {
                                    ErrorHandler.RecoverInline(this);
                                }
                                else
                                {
                                    ErrorHandler.ReportMatch(this);
                                    Consume();
                                }
                                State = 30; expr(6);
                            }
                            break;

                            case 3:
                            {
                                _localctx = new ComparisonExpressionContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 31;
                                if (!(Precpred(Context, 4)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 4)");
                                }
                                State = 32;
                                _la   = TokenStream.LA(1);
                                if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__7) | (1L << T__8) | (1L << T__9) | (1L << T__10))) != 0)))
                                {
                                    ErrorHandler.RecoverInline(this);
                                }
                                else
                                {
                                    ErrorHandler.ReportMatch(this);
                                    Consume();
                                }
                                State = 33; expr(5);
                            }
                            break;

                            case 4:
                            {
                                _localctx = new EqualityExpressionContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 34;
                                if (!(Precpred(Context, 3)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 3)");
                                }
                                State = 35;
                                _la   = TokenStream.LA(1);
                                if (!(_la == T__11 || _la == T__12))
                                {
                                    ErrorHandler.RecoverInline(this);
                                }
                                else
                                {
                                    ErrorHandler.ReportMatch(this);
                                    Consume();
                                }
                                State = 36; expr(4);
                            }
                            break;

                            case 5:
                            {
                                _localctx = new AndExpressionContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 37;
                                if (!(Precpred(Context, 2)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 2)");
                                }
                                State = 38; Match(T__13);
                                State = 39; expr(3);
                            }
                            break;

                            case 6:
                            {
                                _localctx = new OrExpressionContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 40;
                                if (!(Precpred(Context, 1)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 1)");
                                }
                                State = 41; Match(T__14);
                                State = 42; expr(2);
                            }
                            break;
                            }
                        }
                    }
                    State = 47;
                    ErrorHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(TokenStream, 2, Context);
                }
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            UnrollRecursionContexts(_parentctx);
        }
        return(_localctx);
    }