yq/pkg/yqlib/operator_value.go

31 lines
902 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) {
2021-01-12 23:18:53 +00:00
log.Debug("value = %v", expressionNode.Operation.CandidateNode.Node.Value)
2023-01-12 04:11:45 +00:00
if context.MatchingNodes.Len() == 0 {
clone, err := expressionNode.Operation.CandidateNode.Copy()
if err != nil {
return Context{}, err
}
return context.SingleChildContext(clone), nil
}
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
clone, err := expressionNode.Operation.CandidateNode.Copy()
if err != nil {
return Context{}, err
}
results.PushBack(clone)
}
return context.ChildContext(results), nil
2020-10-20 04:33:20 +00:00
}