private ExprContext expr(int _p) { ParserRuleContext _parentctx = Context; int _parentState = State; ExprContext _localctx = new ExprContext(Context, _parentState); ExprContext _prevctx = _localctx; int _startState = 6; EnterRecursionRule(_localctx, 6, RULE_expr, _p); int _la; try { int _alt; EnterOuterAlt(_localctx, 1); { { _localctx = new Expr_defineContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 35; define(); } Context.Stop = TokenStream.LT(-1); State = 42; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context); while (_alt != 2 && _alt != global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER) { if (_alt == 1) { if (ParseListeners != null) { TriggerExitRuleEvent(); } _prevctx = _localctx; { { _localctx = new Expr_additiveContext(new ExprContext(_parentctx, _parentState)); ((Expr_additiveContext)_localctx).lhs = _prevctx; PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 37; if (!(Precpred(Context, 1))) { throw new FailedPredicateException(this, "Precpred(Context, 1)"); } State = 38; _la = TokenStream.LA(1); if (!(_la == PLUS || _la == MINUS)) { ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 39; ((Expr_additiveContext)_localctx).rhs = expr(2); } } } State = 44; ErrorHandler.Sync(this); _alt = Interpreter.AdaptivePredict(TokenStream, 4, Context); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { UnrollRecursionContexts(_parentctx); } return(_localctx); }
private ExprContext expr(int _p) { ParserRuleContext _parentctx = Context; int _parentState = State; ExprContext _localctx = new ExprContext(Context, _parentState); ExprContext _prevctx = _localctx; int _startState = 2; EnterRecursionRule(_localctx, 2, RULE_expr, _p); int _la; try { int _alt; EnterOuterAlt(_localctx, 1); { State = 24; ErrorHandler.Sync(this); switch (Interpreter.AdaptivePredict(TokenStream, 0, Context)) { case 1: { _localctx = new Expr_noneContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 14; num(); } break; case 2: { _localctx = new Expr_defineContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 15; define(); } break; case 3: { _localctx = new Expr_stringContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 16; @string(); } break; case 4: { _localctx = new Expr_unaryContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 17; ((Expr_unaryContext)_localctx).op = TokenStream.LT(1); _la = TokenStream.LA(1); if (!(_la == PLUS || _la == MINUS)) { ((Expr_unaryContext)_localctx).op = ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 18; expr(4); } break; case 5: { _localctx = new Expr_funccallContext(_localctx); Context = _localctx; _prevctx = _localctx; State = 19; ((Expr_funccallContext)_localctx).funcname = Match(IDENTIFIER); State = 20; Match(OPEN_PAREN); State = 21; ((Expr_funccallContext)_localctx)._expr = expr(0); ((Expr_funccallContext)_localctx)._args.Add(((Expr_funccallContext)_localctx)._expr); State = 22; Match(CLOSE_PAREN); } break; } Context.Stop = TokenStream.LT(-1); State = 34; 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 = 32; ErrorHandler.Sync(this); switch (Interpreter.AdaptivePredict(TokenStream, 1, Context)) { case 1: { _localctx = new Expr_additiveContext(new ExprContext(_parentctx, _parentState)); ((Expr_additiveContext)_localctx).lhs = _prevctx; PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 26; if (!(Precpred(Context, 3))) { throw new FailedPredicateException(this, "Precpred(Context, 3)"); } State = 27; ((Expr_additiveContext)_localctx).op = TokenStream.LT(1); _la = TokenStream.LA(1); if (!(_la == PLUS || _la == MINUS)) { ((Expr_additiveContext)_localctx).op = ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 28; ((Expr_additiveContext)_localctx).rhs = expr(4); } break; case 2: { _localctx = new Expr_multipricativeContext(new ExprContext(_parentctx, _parentState)); ((Expr_multipricativeContext)_localctx).lhs = _prevctx; PushNewRecursionContext(_localctx, _startState, RULE_expr); State = 29; if (!(Precpred(Context, 2))) { throw new FailedPredicateException(this, "Precpred(Context, 2)"); } State = 30; ((Expr_multipricativeContext)_localctx).op = TokenStream.LT(1); _la = TokenStream.LA(1); if (!(_la == ASTERISK || _la == SLASH)) { ((Expr_multipricativeContext)_localctx).op = ErrorHandler.RecoverInline(this); } else { ErrorHandler.ReportMatch(this); Consume(); } State = 31; ((Expr_multipricativeContext)_localctx).rhs = expr(3); } break; } } } State = 36; 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); }