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

Function unnest

parser/antlr_parser.go:929–984  ·  view source on GitHub ↗

unnest traverses down the left-hand side of the parse graph until it encounters the first compound parse node or the first leaf in the parse graph.

(tree antlr.ParseTree)

Source from the content-addressed store, hash-verified

927// unnest traverses down the left-hand side of the parse graph until it encounters the first compound
928// parse node or the first leaf in the parse graph.
929func unnest(tree antlr.ParseTree) antlr.ParseTree {
930 for tree != nil {
931 switch t := tree.(type) {
932 case *gen.ExprContext:
933 // conditionalOr op='?' conditionalOr : expr
934 if t.GetOp() != nil {
935 return t
936 }
937 // conditionalOr
938 tree = t.GetE()
939 case *gen.ConditionalOrContext:
940 // conditionalAnd (ops=|| conditionalAnd)*
941 if t.GetOps() != nil && len(t.GetOps()) > 0 {
942 return t
943 }
944 // conditionalAnd
945 tree = t.GetE()
946 case *gen.ConditionalAndContext:
947 // relation (ops=&& relation)*
948 if t.GetOps() != nil && len(t.GetOps()) > 0 {
949 return t
950 }
951 // relation
952 tree = t.GetE()
953 case *gen.RelationContext:
954 // relation op relation
955 if t.GetOp() != nil {
956 return t
957 }
958 // calc
959 tree = t.Calc()
960 case *gen.CalcContext:
961 // calc op calc
962 if t.GetOp() != nil {
963 return t
964 }
965 // unary
966 tree = t.Unary()
967 case *gen.MemberExprContext:
968 // member expands to one of: primary, select, index, or create message
969 tree = t.Member()
970 case *gen.PrimaryExprContext:
971 // primary expands to one of identifier, nested, create list, create struct, literal
972 tree = t.Primary()
973 case *gen.NestedContext:
974 // contains a nested 'expr'
975 tree = t.GetE()
976 case *gen.ConstantLiteralContext:
977 // expands to a primitive literal
978 tree = t.Literal()
979 default:
980 return t
981 }
982 }
983 return tree
984}
985
986var (

Callers 1

VisitMethod · 0.85

Calls 8

GetOpMethod · 0.65
GetEMethod · 0.65
GetOpsMethod · 0.65
CalcMethod · 0.65
UnaryMethod · 0.65
MemberMethod · 0.45
PrimaryMethod · 0.45
LiteralMethod · 0.45

Tested by

no test coverage detected