parser

package
v1.15.10 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: MIT Imports: 7 Imported by: 55

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(tokens token.Tokens, mode Mode, opts ...Option) (*ast.File, error)

Parse parse from token instances, and returns ast.File

func ParseBytes

func ParseBytes(bytes []byte, mode Mode, opts ...Option) (*ast.File, error)

ParseBytes parse from byte slice, and returns ast.File

func ParseFile

func ParseFile(filename string, mode Mode, opts ...Option) (*ast.File, error)

Parse parse from filename, and returns ast.File

Types

type Mode

type Mode uint
const (
	ParseComments Mode = 1 << iota // parse comments and add them to AST
)

type Option added in v1.14.0

type Option func(p *parser)

Option represents parser's option.

func AllowDuplicateMapKey added in v1.14.0

func AllowDuplicateMapKey() Option

AllowDuplicateMapKey allow the use of keys with the same name in the same map, but by default, this is not permitted.

type Token added in v1.15.0

type Token struct {
	Token       *token.Token
	Group       *TokenGroup
	LineComment *token.Token
}

func (*Token) Column added in v1.15.0

func (t *Token) Column() int

func (*Token) Dump added in v1.15.0

func (t *Token) Dump()

func (*Token) GroupType added in v1.15.0

func (t *Token) GroupType() TokenGroupType

func (*Token) Line added in v1.15.0

func (t *Token) Line() int

func (*Token) RawToken added in v1.15.0

func (t *Token) RawToken() *token.Token

func (*Token) SetGroupType added in v1.15.0

func (t *Token) SetGroupType(typ TokenGroupType)

func (*Token) Type added in v1.15.0

func (t *Token) Type() token.Type

type TokenGroup added in v1.15.0

type TokenGroup struct {
	Type   TokenGroupType
	Tokens []*Token
}

func (*TokenGroup) Column added in v1.15.0

func (g *TokenGroup) Column() int

func (*TokenGroup) First added in v1.15.0

func (g *TokenGroup) First() *Token

func (*TokenGroup) Last added in v1.15.0

func (g *TokenGroup) Last() *Token

func (*TokenGroup) Line added in v1.15.0

func (g *TokenGroup) Line() int

func (*TokenGroup) RawToken added in v1.15.0

func (g *TokenGroup) RawToken() *token.Token

func (*TokenGroup) TokenType added in v1.15.0

func (g *TokenGroup) TokenType() token.Type

type TokenGroupType added in v1.15.0

type TokenGroupType int
const (
	TokenGroupNone TokenGroupType = iota
	TokenGroupDirective
	TokenGroupDirectiveName
	TokenGroupDocument
	TokenGroupDocumentBody
	TokenGroupAnchor
	TokenGroupAnchorName
	TokenGroupAlias
	TokenGroupLiteral
	TokenGroupFolded
	TokenGroupScalarTag
	TokenGroupMapKey
	TokenGroupMapKeyValue
)

func (TokenGroupType) String added in v1.15.0

func (t TokenGroupType) String() string

type YAMLVersion added in v1.15.8

type YAMLVersion string
const (
	YAML10 YAMLVersion = "1.0"
	YAML11 YAMLVersion = "1.1"
	YAML12 YAMLVersion = "1.2"
	YAML13 YAMLVersion = "1.3"
)

Jump to

Keyboard shortcuts

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