Esempio n. 1
0
	private AndExprContext andExpr(int _p) {
		ParserRuleContext _parentctx = _ctx;
		int _parentState = State;
		AndExprContext _localctx = new AndExprContext(_ctx, _parentState);
		AndExprContext _prevctx = _localctx;
		int _startState = 6;
		EnterRecursionRule(_localctx, 6, RULE_andExpr, _p);
		int _la;
		try {
			int _alt;
			EnterOuterAlt(_localctx, 1);
			{
			{
			State = 63; _localctx._bitOrExpr = bitOrExpr(0);
			 _localctx.retValue =  _localctx._bitOrExpr.retValue;
			}
			_ctx.stop = _input.Lt(-1);
			State = 73;
			_errHandler.Sync(this);
			_alt = Interpreter.AdaptivePredict(_input,2,_ctx);
			while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber ) {
				if ( _alt==1 ) {
					if ( _parseListeners!=null ) TriggerExitRuleEvent();
					_prevctx = _localctx;
					{
					{
					_localctx = new AndExprContext(_parentctx, _parentState);
					_localctx.first = _prevctx;
					PushNewRecursionContext(_localctx, _startState, RULE_andExpr);
					State = 66;
					if (!(Precpred(_ctx, 2))) throw new FailedPredicateException(this, "Precpred(_ctx, 2)");
					State = 67;
					_la = _input.La(1);
					if ( !(_la==T__24 || _la==T__3) ) {
					_errHandler.RecoverInline(this);
					}
					Consume();
					State = 68; _localctx._bitOrExpr = bitOrExpr(0);
					 _localctx.retValue =  new BinaryExpression(BinaryExpressionType.And, _localctx.first.retValue, _localctx._bitOrExpr.retValue);
					}
					} 
				}
				State = 75;
				_errHandler.Sync(this);
				_alt = Interpreter.AdaptivePredict(_input,2,_ctx);
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.ReportError(this, re);
			_errHandler.Recover(this, re);
		}
		finally {
			UnrollRecursionContexts(_parentctx);
		}
		return _localctx;
	}
Esempio n. 2
0
    private ExprContext expr(int _p)
    {
        ParserRuleContext _parentctx = Context;
        int         _parentState     = State;
        ExprContext _localctx        = new ExprContext(Context, _parentState);
        ExprContext _prevctx         = _localctx;
        int         _startState      = 12;

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

        try {
            int _alt;
            EnterOuterAlt(_localctx, 1);
            {
                State = 58;
                switch (TokenStream.La(1))
                {
                case K_NOT:
                {
                    _localctx = new NotExprContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;

                    State = 46; Match(K_NOT);
                    State = 47; expr(5);
                }
                break;

                case ID:
                {
                    _localctx = new BaseComparisonContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 48; Match(ID);
                    State     = 49; Match(COMPARISON_OP);
                    State     = 51;
                    _la       = TokenStream.La(1);
                    if (_la == NEGATION)
                    {
                        {
                            State = 50; Match(NEGATION);
                        }
                    }

                    State = 53; literal();
                }
                break;

                case T__1:
                {
                    _localctx = new ParanthesizedExprContext(_localctx);
                    Context   = _localctx;
                    _prevctx  = _localctx;
                    State     = 54; Match(T__1);
                    State     = 55; expr(0);
                    State     = 56; Match(T__2);
                }
                break;

                default:
                    throw new NoViableAltException(this);
                }
                Context.Stop = TokenStream.Lt(-1);
                State        = 68;
                ErrorHandler.Sync(this);
                _alt = Interpreter.AdaptivePredict(TokenStream, 6, Context);
                while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber)
                {
                    if (_alt == 1)
                    {
                        if (ParseListeners != null)
                        {
                            TriggerExitRuleEvent();
                        }
                        _prevctx = _localctx;
                        {
                            State = 66;
                            switch (Interpreter.AdaptivePredict(TokenStream, 5, Context))
                            {
                            case 1:
                            {
                                _localctx = new AndExprContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 60;
                                if (!(Precpred(Context, 3)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 3)");
                                }
                                State = 61; Match(K_AND);
                                State = 62; expr(4);
                            }
                            break;

                            case 2:
                            {
                                _localctx = new OrExprContext(new ExprContext(_parentctx, _parentState));
                                PushNewRecursionContext(_localctx, _startState, RULE_expr);
                                State = 63;
                                if (!(Precpred(Context, 2)))
                                {
                                    throw new FailedPredicateException(this, "Precpred(Context, 2)");
                                }
                                State = 64; Match(K_OR);
                                State = 65; expr(3);
                            }
                            break;
                            }
                        }
                    }
                    State = 70;
                    ErrorHandler.Sync(this);
                    _alt = Interpreter.AdaptivePredict(TokenStream, 6, Context);
                }
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            UnrollRecursionContexts(_parentctx);
        }
        return(_localctx);
    }
Esempio n. 3
0
	private bool andExpr_sempred(AndExprContext _localctx, int predIndex) {
		switch (predIndex) {
		case 1: return Precpred(_ctx, 2);
		}
		return true;
	}