Generic ast (#1829)

Remove dependency on yaml.Node for internal AST representation. Yaml decoder is now just another decoder.
This commit is contained in:
Mike Farah
2023-10-18 12:11:53 +11:00
committed by GitHub
parent 7430419413
commit 13d1bbb45f
171 changed files with 6402 additions and 2421 deletions
+6 -10
View File
@@ -3,8 +3,6 @@ package yqlib
import (
"container/list"
"strconv"
yaml "gopkg.in/yaml.v3"
)
func hasOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
@@ -19,20 +17,18 @@ func hasOperator(d *dataTreeNavigator, context Context, expressionNode *Expressi
}
wantedKey := "null"
wanted := &yaml.Node{Tag: "!!null"}
wanted := &CandidateNode{Tag: "!!null"}
if rhs.MatchingNodes.Len() != 0 {
wanted = rhs.MatchingNodes.Front().Value.(*CandidateNode).Node
wanted = rhs.MatchingNodes.Front().Value.(*CandidateNode)
wantedKey = wanted.Value
}
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
// grab the first value
candidateNode := unwrapDoc(candidate.Node)
var contents = candidateNode.Content
switch candidateNode.Kind {
case yaml.MappingNode:
var contents = candidate.Content
switch candidate.Kind {
case MappingNode:
candidateHasKey := false
for index := 0; index < len(contents) && !candidateHasKey; index = index + 2 {
key := contents[index]
@@ -41,7 +37,7 @@ func hasOperator(d *dataTreeNavigator, context Context, expressionNode *Expressi
}
}
results.PushBack(createBooleanCandidate(candidate, candidateHasKey))
case yaml.SequenceNode:
case SequenceNode:
candidateHasKey := false
if wanted.Tag == "!!int" {
var number, errParsingInt = strconv.ParseInt(wantedKey, 10, 64)