Fix tree evaluation

This commit is contained in:
Ian Gulliver
2023-07-04 08:44:26 +01:00
parent 188e0a3fd0
commit 565dc9b0a8
3 changed files with 23 additions and 1 deletions

13
bkl.go
View File

@@ -52,6 +52,19 @@ func (p *Parser) SetDebug(debug bool) {
p.debug = debug
}
// MergeOther applies other's internal document state to ours, using bkl's
// merge semantics.
func (p *Parser) MergeOther(other *Parser) error {
for i, doc := range other.docs {
err := p.MergePatch(i, doc)
if err != nil {
return err
}
}
return nil
}
// MergePatch applies the supplied patch to the [Parser]'s current internal
// document state (at the specified document index) using bkl's merge
// semantics.

View File

@@ -35,7 +35,12 @@ func main() {
}
for _, path := range opts.Positional.InputPaths {
err := p.MergeFileLayers(path)
fileP, err := bkl.NewFromFile(path)
if err != nil {
fatal("%s", err)
}
err = p.MergeOther(fileP)
if err != nil {
fatal("%s", err)
}

View File

@@ -0,0 +1,4 @@
a: 1
b: 2
c: 3
d: 4