package ast
import "github.com/pelletier/go-toml/v2/internal/ast"
Index ¶
- type Builder
- func (b *Builder) AttachChild(parent Reference, child Reference)
- func (b *Builder) Chain(from Reference, to Reference)
- func (b *Builder) NodeAt(ref Reference) Node
- func (b *Builder) Push(n Node) Reference
- func (b *Builder) PushAndChain(n Node) Reference
- func (b *Builder) Reset()
- func (b *Builder) Tree() *Root
- type Iterator
- type Kind
- type Node
- func (n Node) Child() Node
- func (n Node) Children() Iterator
- func (n *Node) Key() Iterator
- func (n Node) Next() Node
- func (n Node) Valid() bool
- func (n Node) Value() Node
- type Reference
- type Root
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (*Builder) AttachChild ¶
func (*Builder) Chain ¶
func (*Builder) NodeAt ¶
func (*Builder) Push ¶
func (*Builder) PushAndChain ¶
func (*Builder) Reset ¶
func (b *Builder) Reset()
func (*Builder) Tree ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator starts uninitialized, you need to call Next() first.
For example:
it := n.Children()
for it.Next() { it.Node() }
func (*Iterator) Next ¶
Next moves the iterator forward and returns true if points to a node, false otherwise.
func (*Iterator) Node ¶
Node returns a copy of the node pointed at by the iterator.
type Kind ¶
type Kind int
const ( // meta Invalid Kind = iota Comment Key // top level structures Table ArrayTable KeyValue // containers values Array InlineTable // values String Bool Float Integer LocalDate LocalDateTime DateTime Time )
func (Kind) String ¶
type Node ¶
type Node struct { Kind Kind Data []byte // Raw bytes from the input // contains filtered or unexported fields }
Arrays have one child per element in the array. InlineTables have one child per key-value pair in the table. KeyValues have at least two children. The first one is the value. The rest make a potentially dotted key. Table and Array table have one child per element of the key they represent (same as KeyValue, but without the last node being the value). children []Node
func (Node) Child ¶
Child returns a copy of the first child node of this node. Other children can be accessed calling Next on the first child. Returns an invalid Node if there is none.
func (Node) Children ¶
Children returns an iterator over a node's children.
func (*Node) Key ¶
Key returns the child nodes making the Key on a supported node. Panics otherwise. They are guaranteed to be all be of the Kind Key. A simple key would return just one element.
func (Node) Next ¶
Next returns a copy of the next node, or an invalid Node if there is no next node.
func (Node) Valid ¶
Valid returns true if the node's kind is set (not to Invalid).
func (Node) Value ¶
Value returns a pointer to the value node of a KeyValue. Guaranteed to be non-nil. Panics if not called on a KeyValue node, or if the Children are malformed.
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
func (Reference) Valid ¶
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root contains a full AST.
It is immutable once constructed with Builder.
func (*Root) Iterator ¶
Iterator over the top level nodes.
Source Files ¶
- Version
- v2.0.0-alpha.1
- Published
- Apr 15, 2021
- Platform
- js/wasm
- Imports
- 1 packages
- Last checked
- 12 hours ago –
Tools for package owners.