MCPcopy Create free account
hub / github.com/cel-expr/cel-go / calc

Method calc

parser/gen/cel_parser.go:1613–1746  ·  view source on GitHub ↗
(_p int)

Source from the content-addressed store, hash-verified

1611}
1612
1613func (p *CELParser) calc(_p int) (localctx ICalcContext) {
1614 var _parentctx antlr.ParserRuleContext = p.GetParserRuleContext()
1615
1616 _parentState := p.GetState()
1617 localctx = NewCalcContext(p, p.GetParserRuleContext(), _parentState)
1618 var _prevctx ICalcContext = localctx
1619 var _ antlr.ParserRuleContext = _prevctx // TODO: To prevent unused variable warning.
1620 _startState := 10
1621 p.EnterRecursionRule(localctx, 10, CELParserRULE_calc, _p)
1622 var _la int
1623
1624 var _alt int
1625
1626 p.EnterOuterAlt(localctx, 1)
1627 {
1628 p.SetState(73)
1629 p.Unary()
1630 }
1631
1632 p.GetParserRuleContext().SetStop(p.GetTokenStream().LT(-1))
1633 p.SetState(83)
1634 p.GetErrorHandler().Sync(p)
1635 if p.HasError() {
1636 goto errorExit
1637 }
1638 _alt = p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 5, p.GetParserRuleContext())
1639 if p.HasError() {
1640 goto errorExit
1641 }
1642 for _alt != 2 && _alt != antlr.ATNInvalidAltNumber {
1643 if _alt == 1 {
1644 if p.GetParseListeners() != nil {
1645 p.TriggerExitRuleEvent()
1646 }
1647 _prevctx = localctx
1648 p.SetState(81)
1649 p.GetErrorHandler().Sync(p)
1650 if p.HasError() {
1651 goto errorExit
1652 }
1653
1654 switch p.GetInterpreter().AdaptivePredict(p.BaseParser, p.GetTokenStream(), 4, p.GetParserRuleContext()) {
1655 case 1:
1656 localctx = NewCalcContext(p, _parentctx, _parentState)
1657 p.PushNewRecursionContext(localctx, _startState, CELParserRULE_calc)
1658 p.SetState(75)
1659
1660 if !(p.Precpred(p.GetParserRuleContext(), 2)) {
1661 p.SetError(antlr.NewFailedPredicateException(p, "p.Precpred(p.GetParserRuleContext(), 2)", ""))
1662 goto errorExit
1663 }
1664 {
1665 p.SetState(76)
1666
1667 var _lt = p.GetTokenStream().LT(1)
1668
1669 localctx.(*CalcContext).op = _lt
1670

Callers 2

relationMethod · 0.95
CalcMethod · 0.95

Calls 9

UnaryMethod · 0.95
LTMethod · 0.80
LAMethod · 0.80
RecoverInlineMethod · 0.80
ReportErrorMethod · 0.80
RecoverMethod · 0.80
NewCalcContextFunction · 0.70
GetStateMethod · 0.65
ConsumeMethod · 0.45

Tested by

no test coverage detected