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

Method VisitMapInitializerList

parser/parser.go:741–768  ·  view source on GitHub ↗

Visit a parse tree produced by CELParser#mapInitializerList.

(ctx *gen.MapInitializerListContext)

Source from the content-addressed store, hash-verified

739
740// Visit a parse tree produced by CELParser#mapInitializerList.
741func (p *parser) VisitMapInitializerList(ctx *gen.MapInitializerListContext) any {
742 if ctx == nil || ctx.GetKeys() == nil {
743 // This is the result of a syntax error handled elswhere, return empty.
744 return []ast.EntryExpr{}
745 }
746
747 result := make([]ast.EntryExpr, len(ctx.GetCols()))
748 keys := ctx.GetKeys()
749 vals := ctx.GetValues()
750 for i, col := range ctx.GetCols() {
751 colID := p.helper.id(col)
752 if i >= len(keys) || i >= len(vals) {
753 // This is the result of a syntax error detected elsewhere.
754 return []ast.EntryExpr{}
755 }
756 optKey := keys[i]
757 optional := optKey.GetOpt() != nil
758 if !p.enableOptionalSyntax && optional {
759 p.reportError(optKey, "unsupported syntax '?'")
760 continue
761 }
762 key := p.Visit(optKey.GetE()).(ast.Expr)
763 value := p.Visit(vals[i]).(ast.Expr)
764 entry := p.helper.newMapEntry(colID, key, value, optional)
765 result[i] = entry
766 }
767 return result
768}
769
770// Visit a parse tree produced by CELParser#Int.
771func (p *parser) 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