Visit a parse tree produced by CELParser#calc.
(ctx *gen.CalcContext)
| 527 | |
| 528 | // Visit a parse tree produced by CELParser#calc. |
| 529 | func (p *parser) VisitCalc(ctx *gen.CalcContext) any { |
| 530 | opText := "" |
| 531 | if ctx.GetOp() != nil { |
| 532 | opText = ctx.GetOp().GetText() |
| 533 | } |
| 534 | if op, found := operators.Find(opText); found { |
| 535 | lhs := p.Visit(ctx.Calc(0)).(ast.Expr) |
| 536 | opID := p.helper.id(ctx.GetOp()) |
| 537 | rhs := p.Visit(ctx.Calc(1)).(ast.Expr) |
| 538 | return p.globalCallOrMacro(opID, op, lhs, rhs) |
| 539 | } |
| 540 | return p.reportError(ctx, "operator not found") |
| 541 | } |
| 542 | |
| 543 | func (p *parser) VisitUnary(ctx *gen.UnaryContext) any { |
| 544 | return p.helper.newLiteralString(ctx, "<<error>>") |
no test coverage detected