(ctx gen.IListInitContext)
| 851 | } |
| 852 | |
| 853 | func (p *parser) visitListInit(ctx gen.IListInitContext) ([]ast.Expr, []int32) { |
| 854 | if ctx == nil { |
| 855 | return []ast.Expr{}, []int32{} |
| 856 | } |
| 857 | elements := ctx.GetElems() |
| 858 | result := make([]ast.Expr, len(elements)) |
| 859 | optionals := []int32{} |
| 860 | for i, e := range elements { |
| 861 | ex := p.Visit(e.GetE()).(ast.Expr) |
| 862 | if ex == nil { |
| 863 | return []ast.Expr{}, []int32{} |
| 864 | } |
| 865 | result[i] = ex |
| 866 | if e.GetOpt() != nil { |
| 867 | if !p.enableOptionalSyntax { |
| 868 | p.reportError(e.GetOpt(), "unsupported syntax '?'") |
| 869 | continue |
| 870 | } |
| 871 | optionals = append(optionals, int32(i)) |
| 872 | } |
| 873 | } |
| 874 | return result, optionals |
| 875 | } |
| 876 | |
| 877 | func (p *parser) visitSlice(expressions []gen.IExprContext) []ast.Expr { |
| 878 | if expressions == nil { |
no test coverage detected