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