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

Method VisitMapInitializerList

parser/antlr_parser.go:647–674  ·  view source on GitHub ↗

Visit a parse tree produced by CELParser#mapInitializerList.

(ctx *gen.MapInitializerListContext)

Source from the content-addressed store, hash-verified

645
646// Visit a parse tree produced by CELParser#mapInitializerList.
647func (p *antlrVisitor) VisitMapInitializerList(ctx *gen.MapInitializerListContext) any {
648 if ctx == nil || ctx.GetKeys() == nil {
649 // This is the result of a syntax error handled elswhere, return empty.
650 return []ast.EntryExpr{}
651 }
652
653 result := make([]ast.EntryExpr, len(ctx.GetCols()))
654 keys := ctx.GetKeys()
655 vals := ctx.GetValues()
656 for i, col := range ctx.GetCols() {
657 colID := p.helper.id(col)
658 if i >= len(keys) || i >= len(vals) {
659 // This is the result of a syntax error detected elsewhere.
660 return []ast.EntryExpr{}
661 }
662 optKey := keys[i]
663 optional := optKey.GetOpt() != nil
664 if !p.enableOptionalSyntax && optional {
665 p.reportError(optKey, "unsupported syntax '?'")
666 continue
667 }
668 key := p.Visit(optKey.GetE()).(ast.Expr)
669 value := p.Visit(vals[i]).(ast.Expr)
670 entry := p.helper.newMapEntry(colID, key, value, optional)
671 result[i] = entry
672 }
673 return result
674}
675
676// Visit a parse tree produced by CELParser#Int.
677func (p *antlrVisitor) VisitInt(ctx *gen.IntContext) any {

Callers 1

VisitMethod · 0.95

Calls 9

reportErrorMethod · 0.95
VisitMethod · 0.95
idMethod · 0.80
newMapEntryMethod · 0.80
GetKeysMethod · 0.65
GetColsMethod · 0.65
GetValuesMethod · 0.65
GetOptMethod · 0.65
GetEMethod · 0.65

Tested by

no test coverage detected