Documentation
¶
Overview ¶
Package tree is the boundary between a file's syntax and everything that reads it. Each syntax front (YAML and HOCON) fills a Node, and the format check and the decoder read only Nodes, so nothing after this package knows which syntax a file used.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
Entry carries the key's own position so that a problem with the key, such as an unknown key, points at the key, and a problem with the value points at the value.
type Node ¶
type Node struct {
Kind Kind
Text string
// Quoted is true for a scalar a YAML reader takes as text whatever it holds: one written in quotes, or as a
// literal or folded block. The format check refuses one where a number or a boolean is expected, because the JSON
// Schema an editor checks the file with refuses text there. The HOCON front sets it for every HOCON string, quoted
// or not, because HOCON types unquoted text as a string.
Quoted bool
// NumberOrBool is true for a plain scalar go-yaml takes as a number or a boolean, such as 404, 1.5 or true. The
// format check refuses one where text is expected, because the JSON Schema refuses a number or a boolean there; the
// origins and methods files follow the same rule, because one checker serves all three files. go-yaml also takes
// some YAML 1.1 spellings as numbers (1_000, 0b1, 0X1F) that YAML 1.2's core schema reads as text, so an editor
// reading YAML 1.2 accepts them as text where the check refuses them: there the check is the stricter side. The
// HOCON front sets it for every HOCON number and boolean.
NumberOrBool bool
Items []*Node
Entries []Entry
Pos model.Pos
}
Node is a value of either syntax: a scalar is its text without the quotes (a YAML null is ""), a map keeps its entries in written order.
func FromHOCON ¶ added in v1.1.0
FromHOCON reads the HOCON file at path into the tree the YAML front builds for the same gateway, so every check after the tree reads one form. It returns either the root or the problems, never both, as FromYAML does. It takes the path, not the bytes, because the library reads an include relative to the including file only when it opens that file.
func FromYAML ¶
FromYAML returns either the root or the problems, never both, so no caller can read a tree with a value left out of it.
func (*Node) Entry ¶
Entry is Get for a reader that also needs the key's position, such as a problem that names the key.