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
+4 -11
View File
@@ -6,8 +6,6 @@ import (
"fmt"
"io"
"os"
yaml "gopkg.in/yaml.v3"
)
// A yaml expression evaluator that runs the expression multiple times for each given yaml document.
@@ -33,12 +31,7 @@ func (s *streamEvaluator) EvaluateNew(expression string, printer Printer) error
if err != nil {
return err
}
candidateNode := &CandidateNode{
Document: 0,
Filename: "",
Node: &yaml.Node{Kind: yaml.DocumentNode, Content: []*yaml.Node{{Tag: "!!null", Kind: yaml.ScalarNode}}},
FileIndex: 0,
}
candidateNode := createScalarNode(nil, "")
inputList := list.New()
inputList.PushBack(candidateNode)
@@ -98,9 +91,9 @@ func (s *streamEvaluator) Evaluate(filename string, reader io.Reader, node *Expr
} else if errorReading != nil {
return currentIndex, fmt.Errorf("bad file '%v': %w", filename, errorReading)
}
candidateNode.Document = currentIndex
candidateNode.Filename = filename
candidateNode.FileIndex = s.fileIndex
candidateNode.document = currentIndex
candidateNode.filename = filename
candidateNode.fileIndex = s.fileIndex
inputList := list.New()
inputList.PushBack(candidateNode)