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

Method VisitCalc

parser/parser.go:537–549  ·  view source on GitHub ↗

Visit a parse tree produced by CELParser#calc.

(ctx *gen.CalcContext)

Source from the content-addressed store, hash-verified

535
536// Visit a parse tree produced by CELParser#calc.
537func (p *parser) VisitCalc(ctx *gen.CalcContext) any {
538 opText := ""
539 if ctx.GetOp() != nil {
540 opText = ctx.GetOp().GetText()
541 }
542 if op, found := operators.Find(opText); found {
543 lhs := p.Visit(ctx.Calc(0)).(ast.Expr)
544 opID := p.helper.id(ctx.GetOp())
545 rhs := p.Visit(ctx.Calc(1)).(ast.Expr)
546 return p.globalCallOrMacro(opID, op, lhs, rhs)
547 }
548 return p.reportError(ctx, "operator not found")
549}
550
551func (p *parser) VisitUnary(ctx *gen.UnaryContext) any {
552 return p.helper.newLiteralString(ctx, "<<error>>")

Callers 1

VisitMethod · 0.95

Calls 8

VisitMethod · 0.95
globalCallOrMacroMethod · 0.95
reportErrorMethod · 0.95
FindFunction · 0.92
GetTextMethod · 0.80
idMethod · 0.80
GetOpMethod · 0.65
CalcMethod · 0.65

Tested by

no test coverage detected