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"
func referenceOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
return context.SingleChildContext(expressionNode.Operation.CandidateNode), nil
}
func valueOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
2023-04-09 01:14:51 +00:00
log.Debug("value = %v", expressionNode.Operation.CandidateNode.Value)
2023-01-12 04:11:45 +00:00
if context.MatchingNodes.Len() == 0 {
2023-04-09 01:14:51 +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-04-09 01:14:51 +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
}