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

Method VisitIndex

parser/parser.go:611–627  ·  view source on GitHub ↗

Visit a parse tree produced by CELParser#Index.

(ctx *gen.IndexContext)

Source from the content-addressed store, hash-verified

609
610// Visit a parse tree produced by CELParser#Index.
611func (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.
630func (p *parser) VisitCreateMessage(ctx *gen.CreateMessageContext) any {

Callers 1

VisitMethod · 0.95

Calls 9

VisitMethod · 0.95
reportErrorMethod · 0.95
globalCallOrMacroMethod · 0.95
idMethod · 0.80
GetOpMethod · 0.65
GetOptMethod · 0.65
MemberMethod · 0.45
newExprMethod · 0.45
GetIndexMethod · 0.45

Tested by

no test coverage detected