2020-11-03 23:48:43 +00:00
|
|
|
package yqlib
|
2020-10-20 04:33:20 +00:00
|
|
|
|
2023-01-12 04:11:45 +00:00
|
|
|
import "container/list"
|
|
|
|
|
2024-01-11 02:17:34 +00:00
|
|
|
func referenceOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
2023-01-12 04:11:45 +00:00
|
|
|
return context.SingleChildContext(expressionNode.Operation.CandidateNode), nil
|
|
|
|
}
|
|
|
|
|
2024-01-11 02:17:34 +00:00
|
|
|
func valueOperator(_ *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
2023-10-18 01:11:53 +00:00
|
|
|
log.Debug("value = %v", expressionNode.Operation.CandidateNode.Value)
|
2023-01-12 04:11:45 +00:00
|
|
|
if context.MatchingNodes.Len() == 0 {
|
2023-10-18 01:11:53 +00:00
|
|
|
clone := expressionNode.Operation.CandidateNode.Copy()
|
2023-01-12 04:11:45 +00:00
|
|
|
return context.SingleChildContext(clone), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var results = list.New()
|
|
|
|
|
|
|
|
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
|
2023-10-18 01:11:53 +00:00
|
|
|
clone := expressionNode.Operation.CandidateNode.Copy()
|
2023-01-12 04:11:45 +00:00
|
|
|
results.PushBack(clone)
|
|
|
|
}
|
|
|
|
|
|
|
|
return context.ChildContext(results), nil
|
2020-10-20 04:33:20 +00:00
|
|
|
}
|