@@ -307,19 +307,14 @@ func (n PathNode) Evaluate(ctx *Context) (interface{}, error) {
307307
308308 var current interface {} = ctx .Input
309309 for i , step := range n .Steps {
310- stepNode , ok := step .(Node )
311- if ! ok {
312- return nil , fmt .Errorf ("invalid path step type at position %d" , i )
313- }
314-
315310 nextCtx := & Context {
316311 Parent : ctx ,
317312 Position : - 1 ,
318313 Input : current ,
319314 }
320315
321316 var err error
322- current , err = stepNode .Evaluate (nextCtx )
317+ current , err = step .Evaluate (nextCtx )
323318 if err != nil {
324319 return nil , err
325320 }
@@ -1559,7 +1554,6 @@ func (n PredicateNode) Evaluate(ctx *Context) (interface{}, error) {
15591554 }
15601555 default :
15611556 match = false
1562- break
15631557 }
15641558 }
15651559
@@ -2416,89 +2410,7 @@ func (n FunctionApplicationNode) Evaluate(ctx *Context) (interface{}, error) {
24162410// expressions. It is deliberately unexported and creates a PathNode
24172411// during its optimize phase.
24182412
2419- // A dotNode is an interim structure used to process JSONata path
2420- // expressions. It is deliberately unexported and creates a PathNode
2421- // during its optimize phase.
2422- type dotNode struct {
2423- lhs Node
2424- rhs Node
2425- }
2426-
2427- func parseDot (p * parser , t token , lhs Node ) (Node , error ) {
2428- return & dotNode {
2429- lhs : lhs ,
2430- rhs : p .parseExpression (p .bp (t .Type )),
2431- }, nil
2432- }
2433-
2434- func (n * dotNode ) optimize () (Node , error ) {
2435- path := & PathNode {}
2436-
2437- lhs , err := n .lhs .optimize ()
2438- if err != nil {
2439- return nil , err
2440- }
2441-
2442- switch lhs := lhs .(type ) {
2443- case * NumberNode , * StringNode , * BooleanNode , * NullNode :
2444- return nil , & Error {
2445- Type : ErrPathLiteral ,
2446- Hint : lhs .String (),
2447- }
2448- case * PathNode :
2449- path .Steps = lhs .Steps
2450- if lhs .KeepArrays {
2451- path .KeepArrays = true
2452- }
2453- default :
2454- path .Steps = []Node {lhs }
2455- }
2456-
2457- rhs , err := n .rhs .optimize ()
2458- if err != nil {
2459- return nil , err
2460- }
2461-
2462- switch rhs := rhs .(type ) {
2463- case * NumberNode , * StringNode , * BooleanNode , * NullNode :
2464- return nil , & Error {
2465- Type : ErrPathLiteral ,
2466- Hint : rhs .String (),
2467- }
2468- case * PathNode :
2469- path .Steps = append (path .Steps , rhs .Steps ... )
2470- if rhs .KeepArrays {
2471- path .KeepArrays = true
2472- }
2473- default :
2474- path .Steps = append (path .Steps , rhs )
2475- }
2476-
2477- return path , nil
2478- }
24792413
2480- func (n dotNode ) String () string {
2481- return fmt .Sprintf ("%s.%s" , n .lhs , n .rhs )
2482- }
2483-
2484- func (n dotNode ) Evaluate (ctx * Context ) (interface {}, error ) {
2485- lhs , err := n .lhs .Evaluate (ctx )
2486- if err != nil {
2487- return nil , err
2488- }
2489-
2490- if lhs == nil {
2491- return nil , nil
2492- }
2493-
2494- rhsCtx := & Context {
2495- Input : lhs ,
2496- Parent : ctx ,
2497- Position : - 1 ,
2498- }
2499-
2500- return n .rhs .Evaluate (rhsCtx )
2501- }
25022414
25032415// A singletonArrayNode is an interim data structure used when
25042416// processing path expressions. It is deliberately unexported
0 commit comments