Documentation
¶
Overview ¶
Package parser implements a parser for TOML, as defined by the TOML v1 specification https://toml.io/en/v1.0.0.
Unlike other TOML libraries, this parser does not unmarshal into Go values, but only constructs an abstract syntax tree for its input. This is meant to support manipulating the structure of a TOML document.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayItem ¶
type ArrayItem interface {
// contains filtered or unexported methods
}
An ArrayItem is an element in a TOML array value. The concrete type of an ArrayItem is one of Comments or Value.
type Comments ¶
type Comments []string
Comments is an Item that represents a block of comments. Each entry represents a single comment line, including its comment marker but omitting the trailing line break.
type Datum ¶
type Datum interface { String() string // contains filtered or unexported methods }
A Datum is the representation of a data value. The concrete type of a Datum is one of Token, Array, or Inline.
type Heading ¶
type Heading struct { Block Comments // a block comment before the heading (empty if none) Trailer string // a trailing line comment after the heading (empty if none) IsArray bool // whether this is an array (true) or table (false) Name Key // the name of the array }
Heading is an Item that represents a table or array section heading.
type Item ¶
type Item interface {
// contains filtered or unexported methods
}
An Item is an element in a TOML document. The concrete type of an Item is one of Comments, Heading, or KeyValue.
type Key ¶
type Key []string
A Key represents a dotted compound name.
func (Key) IsPrefixOf ¶
IsPrefixOf reports whether k is a prefix of k2.
type KeyValue ¶
type KeyValue struct { Block Comments // a block comment before the key-value pair (empty if none) Name Key Value Value }
KeyValue is an Item that represents a key-value definition.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
A Parser is a parser for TOML syntax.
type Token ¶
type Token struct { Type scanner.Token // the lexical type of the token // contains filtered or unexported fields }
A Token represents a lexical data element such as a string, integer, floating point literal, Boolean, or date/time literal.
type Value ¶
type Value struct { Trailer string // a trailing line-comment after the value (empty if none) X Datum // the concrete value }
A Value represents a value in an array or a key-value assignment.
func MustValue ¶
MustValue parses s as a TOML value. It panics if parsing fails. This is intended for use at program initialization time, or for static string constants that are expected to be always valid. For all other casesl, use ParseValue to check the error.
func (Value) WithComment ¶ added in v0.0.4
WithComment returns a copy of v with its trailer set to text.