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