Visit a parse tree produced by CELParser#Index.
(ctx *gen.IndexContext)
| 601 | |
| 602 | // Visit a parse tree produced by CELParser#Index. |
| 603 | func (p *parser) VisitIndex(ctx *gen.IndexContext) any { |
| 604 | target := p.Visit(ctx.Member()).(ast.Expr) |
| 605 | // Handle the error case where no valid identifier is specified. |
| 606 | if ctx.GetOp() == nil { |
| 607 | return p.helper.newExpr(ctx) |
| 608 | } |
| 609 | opID := p.helper.id(ctx.GetOp()) |
| 610 | index := p.Visit(ctx.GetIndex()).(ast.Expr) |
| 611 | operator := operators.Index |
| 612 | if ctx.GetOpt() != nil { |
| 613 | if !p.enableOptionalSyntax { |
| 614 | return p.reportError(ctx.GetOp(), "unsupported syntax '[?'") |
| 615 | } |
| 616 | operator = operators.OptIndex |
| 617 | } |
| 618 | return p.globalCallOrMacro(opID, operator, target, index) |
| 619 | } |
| 620 | |
| 621 | // Visit a parse tree produced by CELParser#CreateMessage. |
| 622 | func (p *parser) VisitCreateMessage(ctx *gen.CreateMessageContext) any { |
no test coverage detected