Visit a parse tree produced by CELParser#mapInitializerList.
(ctx *gen.MapInitializerListContext)
| 731 | |
| 732 | // Visit a parse tree produced by CELParser#mapInitializerList. |
| 733 | func (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. |
| 763 | func (p *parser) VisitInt(ctx *gen.IntContext) any { |
no test coverage detected