示例#1
0
	private bool equalityExpression_sempred(EqualityExpressionContext _localctx, int predIndex) {
		switch (predIndex) {
		case 18: return Precpred(Context, 2);
		case 19: return Precpred(Context, 1);
		}
		return true;
	}
示例#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);
    }
示例#3
0
	private EqualityExpressionContext equalityExpression(int _p) {
		ParserRuleContext _parentctx = Context;
		int _parentState = State;
		EqualityExpressionContext _localctx = new EqualityExpressionContext(Context, _parentState);
		EqualityExpressionContext _prevctx = _localctx;
		int _startState = 32;
		EnterRecursionRule(_localctx, 32, RULE_equalityExpression, _p);
		try {
			int _alt;
			EnterOuterAlt(_localctx, 1);
			{
			{
			State = 239; relationalExpression(0);
			}
			Context.Stop = TokenStream.Lt(-1);
			State = 249;
			ErrorHandler.Sync(this);
			_alt = Interpreter.AdaptivePredict(TokenStream,23,Context);
			while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber ) {
				if ( _alt==1 ) {
					if ( ParseListeners!=null )
						TriggerExitRuleEvent();
					_prevctx = _localctx;
					{
					State = 247;
					switch ( Interpreter.AdaptivePredict(TokenStream,22,Context) ) {
					case 1:
						{
						_localctx = new EqualityExpressionContext(_parentctx, _parentState);
						PushNewRecursionContext(_localctx, _startState, RULE_equalityExpression);
						State = 241;
						if (!(Precpred(Context, 2))) throw new FailedPredicateException(this, "Precpred(Context, 2)");
						State = 242; Match(Equal);
						State = 243; relationalExpression(0);
						}
						break;
					case 2:
						{
						_localctx = new EqualityExpressionContext(_parentctx, _parentState);
						PushNewRecursionContext(_localctx, _startState, RULE_equalityExpression);
						State = 244;
						if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)");
						State = 245; Match(NotEqual);
						State = 246; relationalExpression(0);
						}
						break;
					}
					} 
				}
				State = 251;
				ErrorHandler.Sync(this);
				_alt = Interpreter.AdaptivePredict(TokenStream,23,Context);
			}
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			UnrollRecursionContexts(_parentctx);
		}
		return _localctx;
	}