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

Method VisitMapInitializerList

parser/parser.go:733–760  ·  view source on GitHub ↗

Visit a parse tree produced by CELParser#mapInitializerList.

(ctx *gen.MapInitializerListContext)

Source from the content-addressed store, hash-verified

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