Documentation ¶
Overview ¶
Package parser contains functions and types to parse tokens into YAML AST.
Index ¶
- func Parse(cts ConfigurableTokenStream) (ast.Node, error)
- func ParseBytes(src []byte, opts ...ParseOption) (ast.Node, error)
- func ParseString(src string, opts ...ParseOption) (ast.Node, error)
- func ParseTokenStream(cts ConfigurableTokenStream) (ast.Node, error)
- func ParseTokens(tokens []token.Token) (ast.Node, error)
- type ConfigurableTokenStream
- type DeadEndError
- type ParseOption
- type RawTokenModer
- type TagError
- type UnbalancedClosingParenthesisError
- type UnbalancedOpeningParenthesisError
- type UnbalancedQuotesError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(cts ConfigurableTokenStream) (ast.Node, error)
Parse builds an YAML AST using tokens from given token stream.
func ParseBytes ¶
func ParseBytes(src []byte, opts ...ParseOption) (ast.Node, error)
ParseBytes builds an YAML AST from parsing provided bytes slice.
func ParseString ¶
func ParseString(src string, opts ...ParseOption) (ast.Node, error)
ParseString builds an YAML AST from parsing provided source string.
func ParseTokenStream ¶
func ParseTokenStream(cts ConfigurableTokenStream) (ast.Node, error)
ParseTokenStream builds an YAML AST using tokens from given token stream.
Types ¶
type ConfigurableTokenStream ¶
type ConfigurableTokenStream interface { cpaccessor.ResourceStream[token.Token] RawTokenModer }
ConfigurableTokenStream represents a token stream with abilities to set checkpoints and change mode to raw tokens.
type DeadEndError ¶
DeadEndError is used to indicate some sort of loops occured during parsing when the same token appears multiple times. When YAML document is correct, there will be no 'dead ends' because parsing will go lightly.
func (DeadEndError) Error ¶
func (d DeadEndError) Error() string
type ParseOption ¶
type ParseOption interface {
// contains filtered or unexported methods
}
ParseOption allows to modify parser behavior
func WithOmitStream ¶
func WithOmitStream() ParseOption
WithOmitStream will make parser to omit stream node from AST in case the stream has only one document.
func WithTokenStreamConstructor ¶
func WithTokenStreamConstructor(tsConstructor func(string) ConfigurableTokenStream) ParseOption
WithTokenStreamConstructor will make parser use the token stream constructed with given constructor function.
type RawTokenModer ¶
type RawTokenModer interface { SetRawMode() UnsetRawMode() }
RawTokenModer is used to set "raw mode" in lexer, meaning it almost will not change it's state from incoming tokens.
type TagError ¶
TagError indicates case when tag has a string after it which is not allowed in YAML.
type UnbalancedClosingParenthesisError ¶
UnbalancedClosingParenthesisError is used to indicate case when a closing parenthesis (or bracket) appears in source without corresponding opening counterpart. E.g. "[]]"
func (UnbalancedClosingParenthesisError) Error ¶
func (u UnbalancedClosingParenthesisError) Error() string
type UnbalancedOpeningParenthesisError ¶
type UnbalancedOpeningParenthesisError struct { ExpectedPos token.Position // contains filtered or unexported fields }
UnbalancedOpeningParenthesisError is used to indicate case when an opening parenthesis (or bracket) appears in source without corresponding closing counterpart. E.g. "[[]"
func (UnbalancedOpeningParenthesisError) Error ¶
func (u UnbalancedOpeningParenthesisError) Error() string
type UnbalancedQuotesError ¶
type UnbalancedQuotesError struct { ExpectedPos token.Position // contains filtered or unexported fields }
UnbalancedQuotesError is used to indicate case when an opening quote appears in source without corresponding closing counterpart. E.g. `'` or `"text" "`
func (UnbalancedQuotesError) Error ¶
func (u UnbalancedQuotesError) Error() string