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);
        try {
            int _alt;
            EnterOuterAlt(_localctx, 1);
            {
                State = 17;
                ErrorHandler.Sync(this);
                switch (Interpreter.AdaptivePredict(TokenStream, 0, Context))
                {
                case 1:
                {
                    _localctx = new ParenthesisExpContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;

                    State = 9; Match(T__0);
                    State = 10; expr(0);
                    State = 11; Match(T__1);
                }
                break;

                case 2:
                {
                    _localctx = new NotExpContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 13; Match(T__2);
                    State     = 14; expr(5);
                }
                break;

                case 3:
                {
                    _localctx = new AttrCompExpContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 15; attr_comp();
                }
                break;

                case 4:
                {
                    _localctx = new AttrPrExpContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 16; attr_pr();
                }
                break;
                }
                Context.Stop = TokenStream.LT(-1);
                State        = 27;
                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 = 25;
                            ErrorHandler.Sync(this);
                            switch (Interpreter.AdaptivePredict(TokenStream, 1, Context))
                            {
                            case 1:
                            {
                                _localctx = new AndExpContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 19;
                                if (!(Precpred(Context, 4)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 4)");
                                }
                                State = 20; Match(T__3);
                                State = 21; expr(5);
                            }
                            break;

                            case 2:
                            {
                                _localctx = new OrExpContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 22;
                                if (!(Precpred(Context, 3)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 3)");
                                }
                                State = 23; Match(T__4);
                                State = 24; expr(4);
                            }
                            break;
                            }
                        }
                    }
                    State = 29;
                    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);
    }
示例#2
0
        private MainExprContext mainExpr(int _p)
        {
            ParserRuleContext _parentctx = Context;
            int             _parentState = State;
            MainExprContext _localctx    = new MainExprContext(Context, _parentState);
            MainExprContext _prevctx     = _localctx;
            int             _startState  = 2;

            EnterRecursionRule(_localctx, 2, RULE_mainExpr, _p);
            try {
                int _alt;
                EnterOuterAlt(_localctx, 1);
                {
                    State = 21;
                    ErrorHandler.Sync(this);
                    switch (Interpreter.AdaptivePredict(TokenStream, 1, Context))
                    {
                    case 1:
                    {
                        _localctx = new ParenthesisExpContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;

                        State = 11; Match(T__0);
                        State = 12; mainExpr(0);
                        State = 13; Match(T__1);
                    }
                    break;

                    case 2:
                    {
                        _localctx = new CompareNumberExpContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 15; Match(PROPERTY);
                        State     = 16; Match(OPERATOR);
                        State     = 17; Match(NUMBER);
                    }
                    break;

                    case 3:
                    {
                        _localctx = new CompareStringExpContext(_localctx);
                        Context   = _localctx;
                        _prevctx  = _localctx;
                        State     = 18; Match(PROPERTY);
                        State     = 19; Match(OPERATOR);
                        State     = 20; Match(ESCAPEDSTRING);
                    }
                    break;
                    }
                    Context.Stop = TokenStream.LT(-1);
                    State        = 31;
                    ErrorHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(TokenStream, 3, Context);
                    while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER)
                    {
                        if (_alt == 1)
                        {
                            if (ParseListeners != null)
                            {
                                TriggerExitRuleEvent();
                            }
                            _prevctx = _localctx;
                            {
                                State = 29;
                                ErrorHandler.Sync(this);
                                switch (Interpreter.AdaptivePredict(TokenStream, 2, Context))
                                {
                                case 1:
                                {
                                    _localctx = new AndExpContext(new MainExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_mainExpr);
                                    State = 23;
                                    if (!(Precpred(Context, 4)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 4)");
                                    }
                                    State = 24; Match(AND);
                                    State = 25; mainExpr(5);
                                }
                                break;

                                case 2:
                                {
                                    _localctx = new OrExpContext(new MainExprContext(_parentctx, _parentState));
                                    PushNewRecursionContext(_localctx, _startState, RULE_mainExpr);
                                    State = 26;
                                    if (!(Precpred(Context, 3)))
                                    {
                                        throw new FailedPredicateException(this, "Precpred(Context, 3)");
                                    }
                                    State = 27; Match(OR);
                                    State = 28; mainExpr(4);
                                }
                                break;
                                }
                            }
                        }
                        State = 33;
                        ErrorHandler.Sync(this);
                        _alt = Interpreter.AdaptivePredict(TokenStream, 3, Context);
                    }
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                ErrorHandler.ReportError(this, re);
                ErrorHandler.Recover(this, re);
            }
            finally {
                UnrollRecursionContexts(_parentctx);
            }
            return(_localctx);
        }