internal/third_party/yaml: parse into CUE ast
Also:
- remove support for parsing into Go-structs
- remove support for encoding
- add comment parsing
- port non-standard test harness to standard go
- add testdata
- fix some bugs related to merging
Change-Id: I7fbd2bed6f76bb5da8a309f8d3fb3fb6228048ab
diff --git a/internal/third_party/yaml/parserc.go b/internal/third_party/yaml/parserc.go
index 81d05df..52d8f74 100644
--- a/internal/third_party/yaml/parserc.go
+++ b/internal/third_party/yaml/parserc.go
@@ -2,6 +2,8 @@
import (
"bytes"
+
+ "cuelang.org/go/cue/token"
)
// The parser implements the following grammar:
@@ -58,6 +60,14 @@
parser.tokens_head++
}
+func add_comment(parser *yaml_parser_t, p token.RelPos, m yaml_mark_t, text string) {
+ parser.comments = append(parser.comments, yaml_comment_t{
+ pos: p,
+ mark: m,
+ text: text,
+ })
+}
+
// Get the next event.
func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool {
// Erase the event object.
@@ -1010,8 +1020,7 @@
}
// Parse directives.
-func yaml_parser_process_directives(parser *yaml_parser_t,
- version_directive_ref **yaml_version_directive_t,
+func yaml_parser_process_directives(parser *yaml_parser_t, version_directive_ref **yaml_version_directive_t,
tag_directives_ref *[]yaml_tag_directive_t) bool {
var version_directive *yaml_version_directive_t