ast

package
v1.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2021 License: MIT Imports: 7 Imported by: 62

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTokenType  = xerrors.New("invalid token type")
	ErrInvalidAnchorName = xerrors.New("invalid anchor name")
	ErrInvalidAliasName  = xerrors.New("invalid alias name")
)

Functions

func Merge added in v1.8.0

func Merge(dst Node, src Node) error

Merge merge document, map, sequence node.

func Walk

func Walk(v Visitor, node Node)

Walk traverses an AST in depth-first order: It starts by calling v.Visit(node); node must not be nil. If the visitor w returned by v.Visit(node) is not nil, Walk is invoked recursively with visitor w for each of the non-nil children of node, followed by a call of w.Visit(nil).

Types

type AliasNode

type AliasNode struct {
	*BaseNode
	Start *token.Token
	Value Node
}

AliasNode type of alias node

func Alias added in v1.8.0

func Alias(tk *token.Token) *AliasNode

func (*AliasNode) AddColumn added in v1.1.4

func (n *AliasNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*AliasNode) GetToken

func (n *AliasNode) GetToken() *token.Token

GetToken returns token instance

func (*AliasNode) MarshalYAML added in v1.8.9

func (n *AliasNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*AliasNode) Read added in v1.8.0

func (n *AliasNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*AliasNode) SetName added in v1.8.0

func (n *AliasNode) SetName(name string) error

func (*AliasNode) String

func (n *AliasNode) String() string

String alias to text

func (*AliasNode) Type

func (n *AliasNode) Type() NodeType

Type returns AliasType

type AnchorNode

type AnchorNode struct {
	*BaseNode
	Start *token.Token
	Name  Node
	Value Node
}

AnchorNode type of anchor node

func Anchor added in v1.8.0

func Anchor(tk *token.Token) *AnchorNode

func (*AnchorNode) AddColumn added in v1.1.4

func (n *AnchorNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*AnchorNode) GetToken

func (n *AnchorNode) GetToken() *token.Token

GetToken returns token instance

func (*AnchorNode) MarshalYAML added in v1.8.9

func (n *AnchorNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*AnchorNode) Read added in v1.8.0

func (n *AnchorNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*AnchorNode) SetName added in v1.8.0

func (n *AnchorNode) SetName(name string) error

func (*AnchorNode) String

func (n *AnchorNode) String() string

String anchor to text

func (*AnchorNode) Type

func (n *AnchorNode) Type() NodeType

Type returns AnchorType

type ArrayNode

type ArrayNode interface {
	ArrayRange() *ArrayNodeIter
}

ArrayNode interface of SequenceNode

type ArrayNodeIter

type ArrayNodeIter struct {
	// contains filtered or unexported fields
}

ArrayNodeIter is an iterator for ranging over a ArrayNode

func (*ArrayNodeIter) Len

func (m *ArrayNodeIter) Len() int

Len returns length of array

func (*ArrayNodeIter) Next

func (m *ArrayNodeIter) Next() bool

Next advances the array iterator and reports whether there is another entry. It returns false when the iterator is exhausted.

func (*ArrayNodeIter) Value

func (m *ArrayNodeIter) Value() Node

Value returns the value of the iterator's current array entry.

type BaseNode added in v1.8.0

type BaseNode struct {
	Comment *CommentGroupNode
	// contains filtered or unexported fields
}

func (*BaseNode) GetComment added in v1.8.0

func (n *BaseNode) GetComment() *CommentGroupNode

GetComment returns comment token instance

func (*BaseNode) SetComment added in v1.8.0

func (n *BaseNode) SetComment(node *CommentGroupNode) error

SetComment set comment token

type BoolNode

type BoolNode struct {
	*BaseNode
	Token *token.Token
	Value bool
}

BoolNode type of boolean node

func (*BoolNode) AddColumn added in v1.1.4

func (n *BoolNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*BoolNode) GetToken

func (n *BoolNode) GetToken() *token.Token

GetToken returns token instance

func (*BoolNode) GetValue

func (n *BoolNode) GetValue() interface{}

GetValue returns boolean value

func (*BoolNode) MarshalYAML added in v1.8.9

func (n *BoolNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*BoolNode) Read added in v1.8.0

func (n *BoolNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*BoolNode) String

func (n *BoolNode) String() string

String boolean to text

func (*BoolNode) Type

func (n *BoolNode) Type() NodeType

Type returns BoolType

type CommentGroupNode added in v1.9.0

type CommentGroupNode struct {
	*BaseNode
	Comments []*CommentNode
}

CommentGroupNode type of comment node

func CommentGroup added in v1.9.0

func CommentGroup(comments []*token.Token) *CommentGroupNode

func (*CommentGroupNode) AddColumn added in v1.9.0

func (n *CommentGroupNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*CommentGroupNode) GetToken added in v1.9.0

func (n *CommentGroupNode) GetToken() *token.Token

GetToken returns token instance

func (*CommentGroupNode) MarshalYAML added in v1.9.0

func (n *CommentGroupNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*CommentGroupNode) Read added in v1.9.0

func (n *CommentGroupNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*CommentGroupNode) String added in v1.9.0

func (n *CommentGroupNode) String() string

String comment to text

func (*CommentGroupNode) StringWithSpace added in v1.9.0

func (n *CommentGroupNode) StringWithSpace(col int) string

func (*CommentGroupNode) Type added in v1.9.0

func (n *CommentGroupNode) Type() NodeType

Type returns TagType

type CommentNode added in v1.4.5

type CommentNode struct {
	*BaseNode
	Token *token.Token
}

CommentNode type of comment node

func Comment added in v1.4.5

func Comment(tk *token.Token) *CommentNode

Comment create node for comment

func (*CommentNode) AddColumn added in v1.4.5

func (n *CommentNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*CommentNode) GetToken added in v1.4.5

func (n *CommentNode) GetToken() *token.Token

GetToken returns token instance

func (*CommentNode) MarshalYAML added in v1.8.9

func (n *CommentNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*CommentNode) Read added in v1.8.0

func (n *CommentNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*CommentNode) String added in v1.4.5

func (n *CommentNode) String() string

String comment to text

func (*CommentNode) Type added in v1.4.5

func (n *CommentNode) Type() NodeType

Type returns TagType

type DirectiveNode

type DirectiveNode struct {
	*BaseNode
	Start *token.Token
	Value Node
}

DirectiveNode type of directive node

func Directive added in v1.8.0

func Directive(tk *token.Token) *DirectiveNode

func (*DirectiveNode) AddColumn added in v1.1.4

func (n *DirectiveNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*DirectiveNode) GetToken

func (n *DirectiveNode) GetToken() *token.Token

GetToken returns token instance

func (*DirectiveNode) MarshalYAML added in v1.8.9

func (n *DirectiveNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*DirectiveNode) Read added in v1.8.0

func (n *DirectiveNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*DirectiveNode) String

func (n *DirectiveNode) String() string

String directive to text

func (*DirectiveNode) Type

func (n *DirectiveNode) Type() NodeType

Type returns DirectiveType

type DocumentNode added in v1.8.0

type DocumentNode struct {
	*BaseNode
	Start *token.Token // position of DocumentHeader ( `---` )
	End   *token.Token // position of DocumentEnd ( `...` )
	Body  Node
}

DocumentNode type of Document

func Document

func Document(tk *token.Token, body Node) *DocumentNode

func (*DocumentNode) AddColumn added in v1.8.0

func (d *DocumentNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*DocumentNode) GetToken added in v1.8.0

func (d *DocumentNode) GetToken() *token.Token

GetToken returns token instance

func (*DocumentNode) MarshalYAML added in v1.8.9

func (d *DocumentNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*DocumentNode) Read added in v1.8.0

func (d *DocumentNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*DocumentNode) String added in v1.8.0

func (d *DocumentNode) String() string

String document to text

func (*DocumentNode) Type added in v1.8.0

func (d *DocumentNode) Type() NodeType

Type returns DocumentNodeType

type ErrInvalidMergeType added in v1.8.0

type ErrInvalidMergeType struct {
	// contains filtered or unexported fields
}

func (*ErrInvalidMergeType) Error added in v1.8.0

func (e *ErrInvalidMergeType) Error() string

type File

type File struct {
	Name string
	Docs []*DocumentNode
}

File contains all documents in YAML file

func (*File) Read added in v1.8.0

func (f *File) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*File) String

func (f *File) String() string

String all documents to text

type FloatNode

type FloatNode struct {
	*BaseNode
	Token     *token.Token
	Precision int
	Value     float64
}

FloatNode type of float node

func (*FloatNode) AddColumn added in v1.1.4

func (n *FloatNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*FloatNode) GetToken

func (n *FloatNode) GetToken() *token.Token

GetToken returns token instance

func (*FloatNode) GetValue

func (n *FloatNode) GetValue() interface{}

GetValue returns float64 value

func (*FloatNode) MarshalYAML added in v1.8.9

func (n *FloatNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*FloatNode) Read added in v1.8.0

func (n *FloatNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*FloatNode) String

func (n *FloatNode) String() string

String float64 to text

func (*FloatNode) Type

func (n *FloatNode) Type() NodeType

Type returns FloatType

type InfinityNode

type InfinityNode struct {
	*BaseNode
	Token *token.Token
	Value float64
}

InfinityNode type of infinity node

func Infinity

func Infinity(tk *token.Token) *InfinityNode

Infinity create node for .inf or -.inf value

func (*InfinityNode) AddColumn added in v1.1.4

func (n *InfinityNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*InfinityNode) GetToken

func (n *InfinityNode) GetToken() *token.Token

GetToken returns token instance

func (*InfinityNode) GetValue

func (n *InfinityNode) GetValue() interface{}

GetValue returns math.Inf(0) or math.Inf(-1)

func (*InfinityNode) MarshalYAML added in v1.8.9

func (n *InfinityNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*InfinityNode) Read added in v1.8.0

func (n *InfinityNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*InfinityNode) String

func (n *InfinityNode) String() string

String infinity to text

func (*InfinityNode) Type

func (n *InfinityNode) Type() NodeType

Type returns InfinityType

type IntegerNode

type IntegerNode struct {
	*BaseNode
	Token *token.Token
	Value interface{} // int64 or uint64 value
}

IntegerNode type of integer node

func (*IntegerNode) AddColumn added in v1.1.4

func (n *IntegerNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*IntegerNode) GetToken

func (n *IntegerNode) GetToken() *token.Token

GetToken returns token instance

func (*IntegerNode) GetValue

func (n *IntegerNode) GetValue() interface{}

GetValue returns int64 value

func (*IntegerNode) MarshalYAML added in v1.8.9

func (n *IntegerNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*IntegerNode) Read added in v1.8.0

func (n *IntegerNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*IntegerNode) String

func (n *IntegerNode) String() string

String int64 to text

func (*IntegerNode) Type

func (n *IntegerNode) Type() NodeType

Type returns IntegerType

type LiteralNode

type LiteralNode struct {
	*BaseNode
	Start *token.Token
	Value *StringNode
}

LiteralNode type of literal node

func Literal added in v1.8.0

func Literal(tk *token.Token) *LiteralNode

func (*LiteralNode) AddColumn added in v1.1.4

func (n *LiteralNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*LiteralNode) GetToken

func (n *LiteralNode) GetToken() *token.Token

GetToken returns token instance

func (*LiteralNode) GetValue

func (n *LiteralNode) GetValue() interface{}

GetValue returns string value

func (*LiteralNode) MarshalYAML added in v1.8.9

func (n *LiteralNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*LiteralNode) Read added in v1.8.0

func (n *LiteralNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*LiteralNode) String

func (n *LiteralNode) String() string

String literal to text

func (*LiteralNode) Type

func (n *LiteralNode) Type() NodeType

Type returns LiteralType

type MapNode

type MapNode interface {
	MapRange() *MapNodeIter
}

MapNode interface of MappingValueNode / MappingNode

type MapNodeIter

type MapNodeIter struct {
	// contains filtered or unexported fields
}

MapNodeIter is an iterator for ranging over a MapNode

func (*MapNodeIter) Key

func (m *MapNodeIter) Key() Node

Key returns the key of the iterator's current map node entry.

func (*MapNodeIter) Next

func (m *MapNodeIter) Next() bool

Next advances the map iterator and reports whether there is another entry. It returns false when the iterator is exhausted.

func (*MapNodeIter) Value

func (m *MapNodeIter) Value() Node

Value returns the value of the iterator's current map node entry.

type MappingKeyNode added in v1.7.19

type MappingKeyNode struct {
	*BaseNode
	Start *token.Token
	Value Node
}

MappingKeyNode type of tag node

func MappingKey added in v1.7.19

func MappingKey(tk *token.Token) *MappingKeyNode

MappingKey create node for map key ( '?' ).

func (*MappingKeyNode) AddColumn added in v1.7.19

func (n *MappingKeyNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*MappingKeyNode) GetToken added in v1.7.19

func (n *MappingKeyNode) GetToken() *token.Token

GetToken returns token instance

func (*MappingKeyNode) MarshalYAML added in v1.8.9

func (n *MappingKeyNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*MappingKeyNode) Read added in v1.8.0

func (n *MappingKeyNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*MappingKeyNode) String added in v1.7.19

func (n *MappingKeyNode) String() string

String tag to text

func (*MappingKeyNode) Type added in v1.7.19

func (n *MappingKeyNode) Type() NodeType

Type returns MappingKeyType

type MappingNode

type MappingNode struct {
	*BaseNode
	Start       *token.Token
	End         *token.Token
	IsFlowStyle bool
	Values      []*MappingValueNode
}

MappingNode type of mapping node

func Mapping

func Mapping(tk *token.Token, isFlowStyle bool, values ...*MappingValueNode) *MappingNode

Mapping create node for map

func (*MappingNode) AddColumn added in v1.1.4

func (n *MappingNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*MappingNode) GetToken

func (n *MappingNode) GetToken() *token.Token

GetToken returns token instance

func (*MappingNode) MapRange

func (n *MappingNode) MapRange() *MapNodeIter

MapRange implements MapNode protocol

func (*MappingNode) MarshalYAML added in v1.8.9

func (n *MappingNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*MappingNode) Merge added in v1.8.0

func (n *MappingNode) Merge(target *MappingNode)

Merge merge key/value of map.

func (*MappingNode) Read added in v1.8.0

func (n *MappingNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*MappingNode) SetIsFlowStyle added in v1.8.4

func (n *MappingNode) SetIsFlowStyle(isFlow bool)

SetIsFlowStyle set value to IsFlowStyle field recursively.

func (*MappingNode) String

func (n *MappingNode) String() string

String mapping values to text

func (*MappingNode) Type

func (n *MappingNode) Type() NodeType

Type returns MappingType

type MappingValueNode

type MappingValueNode struct {
	*BaseNode
	Start *token.Token
	Key   Node
	Value Node
}

MappingValueNode type of mapping value

func MappingValue added in v1.8.0

func MappingValue(tk *token.Token, key Node, value Node) *MappingValueNode

MappingValue create node for mapping value

func (*MappingValueNode) AddColumn added in v1.1.4

func (n *MappingValueNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*MappingValueNode) GetToken

func (n *MappingValueNode) GetToken() *token.Token

GetToken returns token instance

func (*MappingValueNode) MapRange

func (n *MappingValueNode) MapRange() *MapNodeIter

MapRange implements MapNode protocol

func (*MappingValueNode) MarshalYAML added in v1.8.9

func (n *MappingValueNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*MappingValueNode) Read added in v1.8.0

func (n *MappingValueNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*MappingValueNode) Replace added in v1.8.0

func (n *MappingValueNode) Replace(value Node) error

Replace replace value node.

func (*MappingValueNode) SetIsFlowStyle added in v1.8.4

func (n *MappingValueNode) SetIsFlowStyle(isFlow bool)

SetIsFlowStyle set value to IsFlowStyle field recursively.

func (*MappingValueNode) String

func (n *MappingValueNode) String() string

String mapping value to text

func (*MappingValueNode) Type

func (n *MappingValueNode) Type() NodeType

Type returns MappingValueType

type MergeKeyNode

type MergeKeyNode struct {
	*BaseNode
	Token *token.Token
}

MergeKeyNode type of merge key node

func MergeKey

func MergeKey(tk *token.Token) *MergeKeyNode

MergeKey create node for merge key ( << )

func (*MergeKeyNode) AddColumn added in v1.4.0

func (n *MergeKeyNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*MergeKeyNode) GetToken

func (n *MergeKeyNode) GetToken() *token.Token

GetToken returns token instance

func (*MergeKeyNode) GetValue

func (n *MergeKeyNode) GetValue() interface{}

GetValue returns '<<' value

func (*MergeKeyNode) MarshalYAML added in v1.8.9

func (n *MergeKeyNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*MergeKeyNode) Read added in v1.8.0

func (n *MergeKeyNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*MergeKeyNode) String

func (n *MergeKeyNode) String() string

String returns '<<' value

func (*MergeKeyNode) Type

func (n *MergeKeyNode) Type() NodeType

Type returns MergeKeyType

type NanNode

type NanNode struct {
	*BaseNode
	Token *token.Token
}

NanNode type of nan node

func Nan

func Nan(tk *token.Token) *NanNode

Nan create node for .nan value

func (*NanNode) AddColumn added in v1.1.4

func (n *NanNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*NanNode) GetToken

func (n *NanNode) GetToken() *token.Token

GetToken returns token instance

func (*NanNode) GetValue

func (n *NanNode) GetValue() interface{}

GetValue returns math.NaN()

func (*NanNode) MarshalYAML added in v1.8.9

func (n *NanNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*NanNode) Read added in v1.8.0

func (n *NanNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*NanNode) String

func (n *NanNode) String() string

String returns .nan

func (*NanNode) Type

func (n *NanNode) Type() NodeType

Type returns NanType

type Node

type Node interface {
	io.Reader
	// String node to text
	String() string
	// GetToken returns token instance
	GetToken() *token.Token
	// Type returns type of node
	Type() NodeType
	// AddColumn add column number to child nodes recursively
	AddColumn(int)
	// SetComment set comment token to node
	SetComment(*CommentGroupNode) error
	// Comment returns comment token instance
	GetComment() *CommentGroupNode
	// MarshalYAML
	MarshalYAML() ([]byte, error)
	// contains filtered or unexported methods
}

Node type of node

func Bool

func Bool(tk *token.Token) Node

Bool create node for boolean value

func Filter added in v1.8.0

func Filter(typ NodeType, node Node) []Node

Filter returns a list of nodes that match the given type.

func FilterFile added in v1.8.0

func FilterFile(typ NodeType, file *File) []Node

FilterFile returns a list of nodes that match the given type.

func Float

func Float(tk *token.Token) Node

Float create node for float value

func Integer

func Integer(tk *token.Token) Node

Integer create node for integer value

func Null

func Null(tk *token.Token) Node

Null create node for null value

func Parent added in v1.9.2

func Parent(root, child Node) Node

Parent get parent node from child node.

type NodeType

type NodeType int

NodeType type identifier of node

const (
	// UnknownNodeType type identifier for default
	UnknownNodeType NodeType = iota
	// DocumentType type identifier for document node
	DocumentType
	// NullType type identifier for null node
	NullType
	// BoolType type identifier for boolean node
	BoolType
	// IntegerType type identifier for integer node
	IntegerType
	// FloatType type identifier for float node
	FloatType
	// InfinityType type identifier for infinity node
	InfinityType
	// NanType type identifier for nan node
	NanType
	// StringType type identifier for string node
	StringType
	// MergeKeyType type identifier for merge key node
	MergeKeyType
	// LiteralType type identifier for literal node
	LiteralType
	// MappingType type identifier for mapping node
	MappingType
	// MappingKeyType type identifier for mapping key node
	MappingKeyType
	// MappingValueType type identifier for mapping value node
	MappingValueType
	// SequenceType type identifier for sequence node
	SequenceType
	// AnchorType type identifier for anchor node
	AnchorType
	// AliasType type identifier for alias node
	AliasType
	// DirectiveType type identifier for directive node
	DirectiveType
	// TagType type identifier for tag node
	TagType
	// CommentType type identifier for comment node
	CommentType
	// CommentGroupType type identifier for comment group node
	CommentGroupType
)

func (NodeType) String

func (t NodeType) String() string

String node type identifier to text

func (NodeType) YAMLName added in v1.8.10

func (t NodeType) YAMLName() string

String node type identifier to YAML Structure name based on https://yaml.org/spec/1.2/spec.html

type NullNode

type NullNode struct {
	*BaseNode
	Token *token.Token
}

NullNode type of null node

func (*NullNode) AddColumn added in v1.1.4

func (n *NullNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*NullNode) GetToken

func (n *NullNode) GetToken() *token.Token

GetToken returns token instance

func (*NullNode) GetValue

func (n *NullNode) GetValue() interface{}

GetValue returns nil value

func (*NullNode) MarshalYAML added in v1.8.9

func (n *NullNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*NullNode) Read added in v1.8.0

func (n *NullNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*NullNode) String

func (n *NullNode) String() string

String returns `null` text

func (*NullNode) Type

func (n *NullNode) Type() NodeType

Type returns NullType

type ScalarNode

type ScalarNode interface {
	Node
	GetValue() interface{}
}

ScalarNode type for scalar node

type SequenceNode

type SequenceNode struct {
	*BaseNode
	Start         *token.Token
	End           *token.Token
	IsFlowStyle   bool
	Values        []Node
	ValueComments []*CommentGroupNode
}

SequenceNode type of sequence node

func Sequence

func Sequence(tk *token.Token, isFlowStyle bool) *SequenceNode

Sequence create node for sequence

func (*SequenceNode) AddColumn added in v1.1.4

func (n *SequenceNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*SequenceNode) ArrayRange

func (n *SequenceNode) ArrayRange() *ArrayNodeIter

ArrayRange implements ArrayNode protocol

func (*SequenceNode) GetToken

func (n *SequenceNode) GetToken() *token.Token

GetToken returns token instance

func (*SequenceNode) MarshalYAML added in v1.8.9

func (n *SequenceNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*SequenceNode) Merge added in v1.8.0

func (n *SequenceNode) Merge(target *SequenceNode)

Merge merge sequence value.

func (*SequenceNode) Read added in v1.8.0

func (n *SequenceNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*SequenceNode) Replace added in v1.8.0

func (n *SequenceNode) Replace(idx int, value Node) error

Replace replace value node.

func (*SequenceNode) SetIsFlowStyle added in v1.8.4

func (n *SequenceNode) SetIsFlowStyle(isFlow bool)

SetIsFlowStyle set value to IsFlowStyle field recursively.

func (*SequenceNode) String

func (n *SequenceNode) String() string

String sequence to text

func (*SequenceNode) Type

func (n *SequenceNode) Type() NodeType

Type returns SequenceType

type StringNode

type StringNode struct {
	*BaseNode
	Token *token.Token
	Value string
}

StringNode type of string node

func String

func String(tk *token.Token) *StringNode

String create node for string value

func (*StringNode) AddColumn added in v1.1.4

func (n *StringNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*StringNode) GetToken

func (n *StringNode) GetToken() *token.Token

GetToken returns token instance

func (*StringNode) GetValue

func (n *StringNode) GetValue() interface{}

GetValue returns string value

func (*StringNode) MarshalYAML added in v1.8.9

func (n *StringNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*StringNode) Read added in v1.8.0

func (n *StringNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*StringNode) String

func (n *StringNode) String() string

String string value to text with quote or literal header if required

func (*StringNode) Type

func (n *StringNode) Type() NodeType

Type returns StringType

type TagNode

type TagNode struct {
	*BaseNode
	Start *token.Token
	Value Node
}

TagNode type of tag node

func Tag added in v1.8.0

func Tag(tk *token.Token) *TagNode

func (*TagNode) AddColumn added in v1.1.4

func (n *TagNode) AddColumn(col int)

AddColumn add column number to child nodes recursively

func (*TagNode) GetToken

func (n *TagNode) GetToken() *token.Token

GetToken returns token instance

func (*TagNode) MarshalYAML added in v1.8.9

func (n *TagNode) MarshalYAML() ([]byte, error)

MarshalYAML encodes to a YAML text

func (*TagNode) Read added in v1.8.0

func (n *TagNode) Read(p []byte) (int, error)

Read implements (io.Reader).Read

func (*TagNode) String

func (n *TagNode) String() string

String tag to text

func (*TagNode) Type

func (n *TagNode) Type() NodeType

Type returns TagType

type Visitor

type Visitor interface {
	Visit(Node) Visitor
}

Visitor has Visit method that is invokded for each node encountered by Walk. If the result visitor w is not nil, Walk visits each of the children of node with the visitor w, followed by a call of w.Visit(nil).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL