yq/pkg/yqlib/operator_value.go

25 lines
793 B
Go
Raw Normal View History

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) {
log.Debug("value = %v", expressionNode.Operation.CandidateNode.Value)
2023-01-12 04:11:45 +00:00
if context.MatchingNodes.Len() == 0 {
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() {
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
}