public PlusminusContext plusminus() { PlusminusContext _localctx = new PlusminusContext(Context, State); EnterRule(_localctx, 8, RULE_plusminus); int _la; try { EnterOuterAlt(_localctx, 1); { State = 31; _la = TokenStream.LA(1); if (!(_la == T__3 || _la == T__4)) { ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
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 = 9; ErrorHandler.Sync(this); switch (TokenStream.LA(1)) { case OP: { _localctx = new ParenExpContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 3; Match(OP); State = 4; expr(0); State = 5; Match(CP); } break; case VAR: { _localctx = new VarContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 7; Match(VAR); } break; case NUM: { _localctx = new ConstContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 8; Match(NUM); } break; default: throw new NoViableAltException(this); } Context.Stop = TokenStream.LT(-1); State = 24; 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 = 22; ErrorHandler.Sync(this); switch (Interpreter.AdaptivePredict(TokenStream, 2, Context)) { case 1: { _localctx = new PowerContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 11; if (!(Precpred(Context, 5))) { throw new FailedPredicateException(this, "Precpred(Context, 5)"); } State = 12; Match(POWER); State = 13; expr(5); } break; case 2: { _localctx = new ProdContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 14; if (!(Precpred(Context, 4))) { throw new FailedPredicateException(this, "Precpred(Context, 4)"); } State = 16; ErrorHandler.Sync(this); _la = TokenStream.LA(1); if (_la == PROD) { { State = 15; Match(PROD); } } State = 18; expr(5); } break; case 3: { _localctx = new PlusminusContext(new ExprContext(_parentctx, _parentState)); PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 19; if (!(Precpred(Context, 3))) { throw new FailedPredicateException(this, "Precpred(Context, 3)"); } State = 20; _la = TokenStream.LA(1); if (!(_la == PLUS || _la == MINUS)) { ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 21; expr(4); } break; } } } State = 26; 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); }