MCPcopy
hub / github.com/antlr/antlr4 / expr

Method expr

runtime/Python3/tests/expr/ExprParser.py:569–644  ·  view source on GitHub ↗
(self, _p:int=0)

Source from the content-addressed store, hash-verified

567
568
569 def expr(self, _p:int=0):
570 _parentctx = self._ctx
571 _parentState = self.state
572 localctx = ExprParser.ExprContext(self, self._ctx, _parentState)
573 _prevctx = localctx
574 _startState = 10
575 self.enterRecursionRule(localctx, 10, self.RULE_expr, _p)
576 self._la = 0 # Token type
577 try:
578 self.enterOuterAlt(localctx, 1)
579 localctx = ExprParser.PrimContext(self, localctx)
580 self._ctx = localctx
581 _prevctx = localctx
582
583 self.state = 59
584 self.primary()
585 self._ctx.stop = self._input.LT(-1)
586 self.state = 69
587 self._errHandler.sync(self)
588 _alt = self._interp.adaptivePredict(self._input,5,self._ctx)
589 while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
590 if _alt==1:
591 if self._parseListeners is not None:
592 self.triggerExitRuleEvent()
593 _prevctx = localctx
594 self.state = 67
595 self._errHandler.sync(self)
596 la_ = self._interp.adaptivePredict(self._input,4,self._ctx)
597 if la_ == 1:
598 localctx = ExprParser.MulDivContext(self, ExprParser.ExprContext(self, _parentctx, _parentState))
599 self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
600 self.state = 61
601 if not self.precpred(self._ctx, 3):
602 from antlr4.error.Errors import FailedPredicateException
603 raise FailedPredicateException(self, "self.precpred(self._ctx, 3)")
604 self.state = 62
605 _la = self._input.LA(1)
606 if not(_la==9 or _la==10):
607 self._errHandler.recoverInline(self)
608 else:
609 self._errHandler.reportMatch(self)
610 self.consume()
611 self.state = 63
612 self.expr(4)
613 pass
614
615 elif la_ == 2:
616 localctx = ExprParser.AddSubContext(self, ExprParser.ExprContext(self, _parentctx, _parentState))
617 self.pushNewRecursionContext(localctx, _startState, self.RULE_expr)
618 self.state = 64
619 if not self.precpred(self._ctx, 2):
620 from antlr4.error.Errors import FailedPredicateException
621 raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
622 self.state = 65
623 _la = self._input.LA(1)
624 if not(_la==11 or _la==12):
625 self._errHandler.recoverInline(self)
626 else:

Callers 5

statMethod · 0.95
primaryMethod · 0.95
visitSMethod · 0.45
visitMultiplyMethod · 0.45
visitAddMethod · 0.45

Calls 15

primaryMethod · 0.95
LTMethod · 0.65
syncMethod · 0.65
LAMethod · 0.65
recoverInlineMethod · 0.65
reportMatchMethod · 0.65
consumeMethod · 0.65
reportErrorMethod · 0.65
recoverMethod · 0.65
enterRecursionRuleMethod · 0.45
enterOuterAltMethod · 0.45

Tested by 3

visitSMethod · 0.36
visitMultiplyMethod · 0.36
visitAddMethod · 0.36