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

Method visitListInit

parser/parser.go:853–875  ·  view source on GitHub ↗
(ctx gen.IListInitContext)

Source from the content-addressed store, hash-verified

851}
852
853func (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
877func (p *parser) visitSlice(expressions []gen.IExprContext) []ast.Expr {
878 if expressions == nil {

Callers 1

VisitCreateListMethod · 0.95

Calls 5

VisitMethod · 0.95
reportErrorMethod · 0.95
GetElemsMethod · 0.65
GetEMethod · 0.65
GetOptMethod · 0.65

Tested by

no test coverage detected