func (d *DocumentNode) AddColumn(col int) {
	if d.Body != nil {
		d.Body.AddColumn(col)
	}
}
AddColumn add column number to child nodes recursively
package ast
import (
	"fmt"
	"io"
	"math"
	"strconv"
	"strings"
	"github.com/goccy/go-yaml/token"
	"golang.org/x/xerrors"
)
var (
	ErrInvalidTokenType  = xerrors.New("invalid token type")
	ErrInvalidAnchorName = xerrors.New("invalid anchor name")
	ErrInvalidAliasName  = xerrors.New("invalid alias name")
)
type NodeType int
const (
	UnknownNodeType NodeType = iota
	DocumentType
	NullType
	BoolType
	IntegerType
	FloatType
	InfinityType
	NanType
	StringType
	MergeKeyType
	LiteralType
	MappingType
	MappingKeyType
	MappingValueType
	SequenceType
	AnchorType
	AliasType
	DirectiveType
	TagType
	CommentType
	CommentGroupType
)
func (t NodeType) String() string {
	switch t {
	case UnknownNodeType:
		return "UnknownNode"
	case DocumentType:
		return "Document"
	case NullType:
		return "Null"
	case BoolType:
		return "Bool"
	case IntegerType:
		return "Integer"
	case FloatType:
		return "Float"
	case InfinityType:
		return "Infinity"
	case NanType:
		return "Nan"
	case StringType:
		return "String"
	case MergeKeyType:
		return "MergeKey"
	case LiteralType:
		return "Literal"
	case MappingType:
		return "Mapping"
	case MappingKeyType:
		return "MappingKey"
	case MappingValueType:
		return "MappingValue"
	case SequenceType:
		return "Sequence"
	case AnchorType:
		return "Anchor"
	case AliasType:
		return "Alias"
	case DirectiveType:
		return "Directive"
	case TagType:
		return "Tag"
	case CommentType:
		return "Comment"
	case CommentGroupType:
		return "CommentGroup"
	}
	return ""
}
func (t NodeType) YAMLName() string {
	switch t {
	case UnknownNodeType:
		return "unknown"
	case DocumentType:
		return "document"
	case NullType:
		return "null"
	case BoolType:
		return "boolean"
	case IntegerType:
		return "int"
	case FloatType:
		return "float"
	case InfinityType:
		return "inf"
	case NanType:
		return "nan"
	case StringType:
		return "string"
	case MergeKeyType:
		return "merge key"
	case LiteralType:
		return "scalar"
	case MappingType:
		return "mapping"
	case MappingKeyType:
		return "key"
	case MappingValueType:
		return "value"
	case SequenceType:
		return "sequence"
	case AnchorType:
		return "anchor"
	case AliasType:
		return "alias"
	case DirectiveType:
		return "directive"
	case TagType:
		return "tag"
	case CommentType:
		return "comment"
	case CommentGroupType:
		return "comment"
	}
	return ""
}
type Node interface {
	io.Reader
	String() string
	GetToken() *token.Token
	Type() NodeType
	AddColumn(int)
	SetComment(*CommentGroupNode) error
	GetComment() *CommentGroupNode
	GetPath() string
	SetPath(string)
	MarshalYAML() ([]byte, error)
	readLen() int
	addReadLen(int)
	clearLen()
	stringWithoutComment() string
}
type ScalarNode interface {
	Node
	GetValue() interface{}
}
type BaseNode struct {
	Path    string
	Comment *CommentGroupNode
	read    int
}
func addCommentString(base string, node *CommentGroupNode) string {
	return fmt.Sprintf("%s %s", base, node.String())
}
func (n *BaseNode) readLen() int {
	return n.read
}
func (n *BaseNode) clearLen() {
	n.read = 0
}
func (n *BaseNode) addReadLen(len int) {
	n.read += len
}
func (n *BaseNode) GetPath() string {
	if n == nil {
		return ""
	}
	return n.Path
}
func (n *BaseNode) SetPath(path string) {
	if n == nil {
		return
	}
	n.Path = path
}
func (n *BaseNode) GetComment() *CommentGroupNode {
	return n.Comment
}
func (n *BaseNode) SetComment(node *CommentGroupNode) error {
	n.Comment = node
	return nil
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func readNode(p []byte, node Node) (int, error) {
	s := node.String()
	readLen := node.readLen()
	remain := len(s) - readLen
	if remain == 0 {
		node.clearLen()
		return 0, io.EOF
	}
	size := min(remain, len(p))
	for idx, b := range s[readLen : readLen+size] {
		p[idx] = byte(b)
	}
	node.addReadLen(size)
	return size, nil
}
func Null(tk *token.Token) Node {
	return &NullNode{
		BaseNode: &BaseNode{},
		Token:    tk,
	}
}
func Bool(tk *token.Token) Node {
	b, _ := strconv.ParseBool(tk.Value)
	return &BoolNode{
		BaseNode: &BaseNode{},
		Token:    tk,
		Value:    b,
	}
}
func Integer(tk *token.Token) Node {
	value := removeUnderScoreFromNumber(tk.Value)
	switch tk.Type {
	case token.BinaryIntegerType:
		skipCharacterNum := 2
		negativePrefix := ""
		if value[0] == '-' {
			skipCharacterNum++
			negativePrefix = "-"
		}
		if len(negativePrefix) > 0 {
			i, _ := strconv.ParseInt(negativePrefix+value[skipCharacterNum:], 2, 64)
			return &IntegerNode{
				BaseNode: &BaseNode{},
				Token:    tk,
				Value:    i,
			}
		}
		i, _ := strconv.ParseUint(negativePrefix+value[skipCharacterNum:], 2, 64)
		return &IntegerNode{
			BaseNode: &BaseNode{},
			Token:    tk,
			Value:    i,
		}
	case token.OctetIntegerType:
		skipCharacterNum := 1
		negativePrefix := ""
		if value[0] == '-' {
			skipCharacterNum++
			if len(value) > 2 && value[2] == 'o' {
				skipCharacterNum++
			}
			negativePrefix = "-"
		} else {
			if value[1] == 'o' {
				skipCharacterNum++
			}
		}
		if len(negativePrefix) > 0 {
			i, _ := strconv.ParseInt(negativePrefix+value[skipCharacterNum:], 8, 64)
			return &IntegerNode{
				BaseNode: &BaseNode{},
				Token:    tk,
				Value:    i,
			}
		}
		i, _ := strconv.ParseUint(value[skipCharacterNum:], 8, 64)
		return &IntegerNode{
			BaseNode: &BaseNode{},
			Token:    tk,
			Value:    i,
		}
	case token.HexIntegerType:
		skipCharacterNum := 2
		negativePrefix := ""
		if value[0] == '-' {
			skipCharacterNum++
			negativePrefix = "-"
		}
		if len(negativePrefix) > 0 {
			i, _ := strconv.ParseInt(negativePrefix+value[skipCharacterNum:], 16, 64)
			return &IntegerNode{
				BaseNode: &BaseNode{},
				Token:    tk,
				Value:    i,
			}
		}
		i, _ := strconv.ParseUint(value[skipCharacterNum:], 16, 64)
		return &IntegerNode{
			BaseNode: &BaseNode{},
			Token:    tk,
			Value:    i,
		}
	}
	if value[0] == '-' || value[0] == '+' {
		i, _ := strconv.ParseInt(value, 10, 64)
		return &IntegerNode{
			BaseNode: &BaseNode{},
			Token:    tk,
			Value:    i,
		}
	}
	i, _ := strconv.ParseUint(value, 10, 64)
	return &IntegerNode{
		BaseNode: &BaseNode{},
		Token:    tk,
		Value:    i,
	}
}
func Float(tk *token.Token) Node {
	f, _ := strconv.ParseFloat(removeUnderScoreFromNumber(tk.Value), 64)
	return &FloatNode{
		BaseNode: &BaseNode{},
		Token:    tk,
		Value:    f,
	}
}
func Infinity(tk *token.Token) *InfinityNode {
	node := &InfinityNode{
		BaseNode: &BaseNode{},
		Token:    tk,
	}
	switch tk.Value {
	case ".inf", ".Inf", ".INF":
		node.Value = math.Inf(0)
	case "-.inf", "-.Inf", "-.INF":
		node.Value = math.Inf(-1)
	}
	return node
}
func Nan(tk *token.Token) *NanNode {
	return &NanNode{
		BaseNode: &BaseNode{},
		Token:    tk,
	}
}
func String(tk *token.Token) *StringNode {
	return &StringNode{
		BaseNode: &BaseNode{},
		Token:    tk,
		Value:    tk.Value,
	}
}
func Comment(tk *token.Token) *CommentNode {
	return &CommentNode{
		BaseNode: &BaseNode{},
		Token:    tk,
	}
}
func CommentGroup(comments []*token.Token) *CommentGroupNode {
	nodes := []*CommentNode{}
	for _, comment := range comments {
		nodes = append(nodes, Comment(comment))
	}
	return &CommentGroupNode{
		BaseNode: &BaseNode{},
		Comments: nodes,
	}
}
func MergeKey(tk *token.Token) *MergeKeyNode {
	return &MergeKeyNode{
		BaseNode: &BaseNode{},
		Token:    tk,
	}
}
func Mapping(tk *token.Token, isFlowStyle bool, values ...*MappingValueNode) *MappingNode {
	node := &MappingNode{
		BaseNode:    &BaseNode{},
		Start:       tk,
		IsFlowStyle: isFlowStyle,
		Values:      []*MappingValueNode{},
	}
	node.Values = append(node.Values, values...)
	return node
}
func MappingValue(tk *token.Token, key Node, value Node) *MappingValueNode {
	return &MappingValueNode{
		BaseNode: &BaseNode{},
		Start:    tk,
		Key:      key,
		Value:    value,
	}
}
func MappingKey(tk *token.Token) *MappingKeyNode {
	return &MappingKeyNode{
		BaseNode: &BaseNode{},
		Start:    tk,
	}
}
func Sequence(tk *token.Token, isFlowStyle bool) *SequenceNode {
	return &SequenceNode{
		BaseNode:    &BaseNode{},
		Start:       tk,
		IsFlowStyle: isFlowStyle,
		Values:      []Node{},
	}
}
func Anchor(tk *token.Token) *AnchorNode {
	return &AnchorNode{
		BaseNode: &BaseNode{},
		Start:    tk,
	}
}
func Alias(tk *token.Token) *AliasNode {
	return &AliasNode{
		BaseNode: &BaseNode{},
		Start:    tk,
	}
}
func Document(tk *token.Token, body Node) *DocumentNode {
	return &DocumentNode{
		BaseNode: &BaseNode{},
		Start:    tk,
		Body:     body,
	}
}
func Directive(tk *token.Token) *DirectiveNode {
	return &DirectiveNode{
		BaseNode: &BaseNode{},
		Start:    tk,
	}
}
func Literal(tk *token.Token) *LiteralNode {
	return &LiteralNode{
		BaseNode: &BaseNode{},
		Start:    tk,
	}
}
func Tag(tk *token.Token) *TagNode {
	return &TagNode{
		BaseNode: &BaseNode{},
		Start:    tk,
	}
}
type File struct {
	Name string
	Docs []*DocumentNode
}
func (f *File) Read(p []byte) (int, error) {
	for _, doc := range f.Docs {
		n, err := doc.Read(p)
		if err == io.EOF {
			continue
		}
		return n, nil
	}
	return 0, io.EOF
}
func (f *File) String() string {
	docs := []string{}
	for _, doc := range f.Docs {
		docs = append(docs, doc.String())
	}
	return strings.Join(docs, "\n")
}
func (f *File) stringWithoutComment() string {
	return f.String()
}
type DocumentNode struct {
	*BaseNode
	Start *token.Token  
	End   *token.Token  
	Body  Node
}
func (d *DocumentNode) Read(p []byte) (int, error) {
	return readNode(p, d)
}
func (d *DocumentNode) Type() NodeType { return DocumentType }
func (d *DocumentNode) GetToken() *token.Token {
	return d.Body.GetToken()
}