private bool simpleExpression_sempred(SimpleExpressionContext _localctx, int predIndex) { switch (predIndex) { case 0: return(Precpred(Context, 4)); case 1: return(Precpred(Context, 3)); } return(true); }
private SimpleExpressionContext simpleExpression(int _p) { ParserRuleContext _parentctx = Context; int _parentState = State; SimpleExpressionContext _localctx = new SimpleExpressionContext(Context, _parentState); SimpleExpressionContext _prevctx = _localctx; int _startState = 4; EnterRecursionRule(_localctx, 4, RULE_simpleExpression, _p); int _la; try { int _alt; EnterOuterAlt(_localctx, 1); { State = 22; ErrorHandler.Sync(this); switch (Interpreter.AdaptivePredict(TokenStream, 1, Context)) { case 1: { State = 20; variableRef(); } break; case 2: { State = 21; functionRef(); } break; } Context.Stop = TokenStream.LT(-1); State = 32; 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 = 30; ErrorHandler.Sync(this); switch (Interpreter.AdaptivePredict(TokenStream, 2, Context)) { case 1: { _localctx = new SimpleExpressionContext(_parentctx, _parentState); PushNewRecursionContext(_localctx, _startState, RULE_simpleExpression); State = 24; if (!(Precpred(Context, 4))) { throw new FailedPredicateException(this, "Precpred(Context, 4)"); } State = 25; _la = TokenStream.LA(1); if (!(_la == PLUS || _la == MINUS)) { ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 26; simpleExpression(5); } break; case 2: { _localctx = new SimpleExpressionContext(_parentctx, _parentState); PushNewRecursionContext(_localctx, _startState, RULE_simpleExpression); State = 27; if (!(Precpred(Context, 3))) { throw new FailedPredicateException(this, "Precpred(Context, 3)"); } State = 28; _la = TokenStream.LA(1); if (!(_la == MULTIPLY || _la == DIVIDE)) { ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 29; simpleExpression(4); } break; } } } State = 34; 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); }
private PostfixExpressionContext postfixExpression(int _p) { ParserRuleContext _parentctx = Context; int _parentState = State; PostfixExpressionContext _localctx = new PostfixExpressionContext(Context, _parentState); PostfixExpressionContext _prevctx = _localctx; int _startState = 14; EnterRecursionRule(_localctx, 14, RULE_postfixExpression, _p); int _la; try { int _alt; EnterOuterAlt(_localctx, 1); { { _localctx = new SimpleExpressionContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 115; primaryExpression(); } Context.Stop = TokenStream.Lt(-1); State = 140; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,10,Context); while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.InvalidAltNumber ) { if ( _alt==1 ) { if ( ParseListeners!=null ) TriggerExitRuleEvent(); _prevctx = _localctx; { State = 138; switch ( Interpreter.AdaptivePredict(TokenStream,9,Context) ) { case 1: { _localctx = new IndexContext(new PostfixExpressionContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_postfixExpression); State = 117; if (!(Precpred(Context, 6))) throw new FailedPredicateException(this, "Precpred(Context, 6)"); State = 118; Match(LeftBracket); State = 119; argumentExpressionList(0); State = 120; Match(RightBracket); } break; case 2: { _localctx = new CallContext(new PostfixExpressionContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_postfixExpression); State = 122; if (!(Precpred(Context, 5))) throw new FailedPredicateException(this, "Precpred(Context, 5)"); State = 123; Match(LeftParen); State = 125; _la = TokenStream.La(1); if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << LeftParen) | (1L << Plus) | (1L << PlusPlus) | (1L << Minus) | (1L << MinusMinus) | (1L << Star) | (1L << And) | (1L << Not) | (1L << Tilde) | (1L << Identifier) | (1L << Constant) | (1L << StringLiteral))) != 0)) { { State = 124; argumentExpressionList(0); } } State = 127; Match(RightParen); } break; case 3: { _localctx = new MemberAccessContext(new PostfixExpressionContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_postfixExpression); State = 128; if (!(Precpred(Context, 4))) throw new FailedPredicateException(this, "Precpred(Context, 4)"); State = 129; Match(Dot); State = 130; Match(Identifier); } break; case 4: { _localctx = new MemberPointerAccessContext(new PostfixExpressionContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_postfixExpression); State = 131; if (!(Precpred(Context, 3))) throw new FailedPredicateException(this, "Precpred(Context, 3)"); State = 132; Match(Arrow); State = 133; Match(Identifier); } break; case 5: { _localctx = new PostfixIncrementContext(new PostfixExpressionContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_postfixExpression); State = 134; if (!(Precpred(Context, 2))) throw new FailedPredicateException(this, "Precpred(Context, 2)"); State = 135; Match(PlusPlus); } break; case 6: { _localctx = new PostfixDecrementContext(new PostfixExpressionContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_postfixExpression); State = 136; if (!(Precpred(Context, 1))) throw new FailedPredicateException(this, "Precpred(Context, 1)"); State = 137; Match(MinusMinus); } break; } } } State = 142; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream,10,Context); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { UnrollRecursionContexts(_parentctx); } return _localctx; }