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

Method VisitIndex

parser/parser.go:603–619  ·  view source on GitHub ↗

Visit a parse tree produced by CELParser#Index.

(ctx *gen.IndexContext)

Source from the content-addressed store, hash-verified

601
602// Visit a parse tree produced by CELParser#Index.
603func (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.
622func (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