mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-07 02:48:27 +08:00
Generic ast (#1829)
Remove dependency on yaml.Node for internal AST representation. Yaml decoder is now just another decoder.
This commit is contained in:
@@ -3,22 +3,22 @@ package yqlib
|
||||
import "container/list"
|
||||
|
||||
func unionOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
|
||||
log.Debug("unionOperator")
|
||||
log.Debug("context: %v", NodesToString(context.MatchingNodes))
|
||||
log.Debug("unionOperator--")
|
||||
log.Debug("unionOperator: context: %v", NodesToString(context.MatchingNodes))
|
||||
lhs, err := d.GetMatchingNodes(context, expressionNode.LHS)
|
||||
if err != nil {
|
||||
return Context{}, err
|
||||
}
|
||||
log.Debug("lhs: %v", NodesToString(lhs.MatchingNodes))
|
||||
log.Debug("rhs input: %v", NodesToString(context.MatchingNodes))
|
||||
log.Debug("rhs: %v", expressionNode.RHS.Operation.toString())
|
||||
log.Debug("unionOperator: lhs: %v", NodesToString(lhs.MatchingNodes))
|
||||
log.Debug("unionOperator: rhs input: %v", NodesToString(context.MatchingNodes))
|
||||
log.Debug("unionOperator: rhs: %v", expressionNode.RHS.Operation.toString())
|
||||
rhs, err := d.GetMatchingNodes(context, expressionNode.RHS)
|
||||
|
||||
if err != nil {
|
||||
return Context{}, err
|
||||
}
|
||||
log.Debug("lhs: %v", lhs.ToString())
|
||||
log.Debug("rhs: %v", rhs.ToString())
|
||||
log.Debug("unionOperator: lhs: %v", lhs.ToString())
|
||||
log.Debug("unionOperator: rhs: %v", rhs.ToString())
|
||||
|
||||
results := lhs.ChildContext(list.New())
|
||||
for el := lhs.MatchingNodes.Front(); el != nil; el = el.Next() {
|
||||
@@ -33,12 +33,11 @@ func unionOperator(d *dataTreeNavigator, context Context, expressionNode *Expres
|
||||
|
||||
for el := rhs.MatchingNodes.Front(); el != nil; el = el.Next() {
|
||||
node := el.Value.(*CandidateNode)
|
||||
log.Debug("processing %v", NodeToString(node))
|
||||
log.Debug("union operator rhs: processing %v", NodeToString(node))
|
||||
|
||||
results.MatchingNodes.PushBack(node)
|
||||
}
|
||||
}
|
||||
log.Debug("and lets print it out")
|
||||
log.Debug("all together: %v", results.ToString())
|
||||
log.Debug("union operator: all together: %v", results.ToString())
|
||||
return results, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user