Documentation ¶
Overview ¶
Package token contains the token and lexer logic.
Code generated by go generate; DO NOT EDIT.
Index ¶
- type Assign
- type BlockEnd
- type BlockStart
- type CharData
- type Comma
- type DefineAttribute
- type DefineElement
- type ErrDetail
- type G1Comment
- type G1LineEnd
- type G2Arrow
- type G2Comment
- type G2Preamble
- type GenericEnd
- type GenericStart
- type GrammarMode
- type GroupEnd
- type GroupStart
- type Identifier
- type Lexer
- type Node
- type Pos
- type PosError
- type Position
- type Semicolon
- type Token
- type Type
- type WantMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockStart ¶
type BlockStart struct {
Position
}
BlockStart is a '{' that is the start of a block.
func (*BlockStart) Pos ¶
func (t *BlockStart) Pos() *Position
func (*BlockStart) Type ¶
func (t *BlockStart) Type() Type
type CharData ¶
A CharData token represents a run of text.
func (CharData) SplitLines ¶
SplitLines splits this token into one or more, one for each line. This will return empty tokens for empty lines, as the newline-characters are not included in the new tokens.
type DefineAttribute ¶
DefineAttribute is the '@' before the name of an attribute.
func (*DefineAttribute) Pos ¶
func (t *DefineAttribute) Pos() *Position
func (*DefineAttribute) Type ¶
func (t *DefineAttribute) Type() Type
type DefineElement ¶
DefineElement is the '#' before the name of an element.
func (*DefineElement) Pos ¶
func (t *DefineElement) Pos() *Position
func (*DefineElement) Type ¶
func (t *DefineElement) Type() Type
type ErrDetail ¶
func NewErrDetail ¶
type G1Comment ¶
type G1Comment struct {
Position
}
G1Comment is a '#?' that indicates a comment in G1.
type G1LineEnd ¶
type G1LineEnd struct {
Position
}
G1LineEnd is a special newline, that is only emitted when a G1Line ends.
type G2Arrow ¶
type G2Arrow struct {
Position
}
G2Arrow is a '->' that indicates a return value in G2.
type G2Comment ¶
type G2Comment struct {
Position
}
G2Comment is a '//' that indicates a comment in G2.
type G2Preamble ¶
type G2Preamble struct {
Position
}
G2Preamble is the '#!' preamble for a G2 grammar.
func (*G2Preamble) Pos ¶
func (t *G2Preamble) Pos() *Position
func (*G2Preamble) Type ¶
func (t *G2Preamble) Type() Type
type GenericEnd ¶
type GenericEnd struct {
Position
}
GenericEnd is a '>' that is the end of a generic group.
func (*GenericEnd) Pos ¶
func (t *GenericEnd) Pos() *Position
func (*GenericEnd) Type ¶
func (t *GenericEnd) Type() Type
type GenericStart ¶
type GenericStart struct {
Position
}
GenericStart is a '<' that is the start of a generic group.
func (*GenericStart) Pos ¶
func (t *GenericStart) Pos() *Position
func (*GenericStart) Type ¶
func (t *GenericStart) Type() Type
type GrammarMode ¶
type GrammarMode int
GrammarMode is used to identify if the lexer is in grammar 1, grammar 2, or lexing a single line in grammar 1.
const ( // G1 is the default text-first mode. G1 GrammarMode = iota // G2 ist the node-first mode. G2 // G1Line is a single G1 line in G2. G1Line // G1LineForward is the same as G1Line, but the elements should be forwarded. G1LineForward )
type GroupStart ¶
type GroupStart struct {
Position
}
GroupStart is a '(' that is the start of a group.
func (*GroupStart) Pos ¶
func (t *GroupStart) Pos() *Position
func (*GroupStart) Type ¶
func (t *GroupStart) Type() Type
type Identifier ¶
Identifier is an identifier as you would expect from a programming language: [0-9a-zA-Z_]+.
func (*Identifier) Pos ¶
func (t *Identifier) Pos() *Position
func (*Identifier) Type ¶
func (t *Identifier) Type() Type
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer can be used to get individual tokens.
func (*Lexer) Token ¶
Token returns the next dyml token in the input stream. At the end of the input stream, Token returns nil, io.EOF. The lexer start of in G1 mode. Should a user of a Lexer detect a token that indicates a mode change, it is THEIR responsibility to change the lexer's mode accordingly.
type Node ¶
Node contains access to the start and end positions of a token.
func NewFileNode ¶
NewFileNode returns a fake node which just points to 1:1 of the file, whatever that is.
type Pos ¶
type Pos struct { // File contains the absolute file path. File string // Line denotes the one-based line number in the denoted File. Line int // Col denotes the one-based column number in the denoted Line. Col int // Offset in bytes Offset int }
A Pos describes a resolved position within a file.
type PosError ¶
PosError represents a very specific positional error with a lot of explaining noise. Use Explain.
func NewPosError ¶
NewPosError creates a new PosError with the given root cause and optional details.
type Position ¶
type Position struct {
BeginPos, EndPos Pos
}
type Semicolon ¶
type Semicolon struct {
Position
}
Semicolon ';' is used as a separator in G2 and is interchangeable with Comma.
type Type ¶
type Type string
const ( TokenCharData Type = "TokenCharData" TokenIdentifier Type = "TokenIdentifier" TokenBlockStart Type = "TokenBlockStart" TokenBlockEnd Type = "TokenBlockEnd" TokenGroupStart Type = "TokenGroupStart" TokenGroupEnd Type = "TokenGroupEnd" TokenGenericStart Type = "TokenGenericStart" TokenGenericEnd Type = "TokenGenericEnd" TokenG2Preamble Type = "TokenG2Preamble" TokenDefineElement Type = "TokenDefineElement" TokenDefineAttribute Type = "TokenDefineAttribute" TokenAssign Type = "TokenAssign" TokenG1LineEnd Type = "TokenG1LineEnd" TokenComma Type = "TokenComma" TokenSemicolon Type = "TokenSemicolon" TokenG1Comment Type = "TokenG1Comment" TokenG2Comment Type = "TokenG2Comment" TokenG2Arrow Type = "TokenG2Arrow" )
type WantMode ¶
type WantMode string
WantMode is used to make sure the next token is lexed as a specific thing.
const ( // WantNothing indicates that the lexer should operate as usual. WantNothing WantMode = "Nothing" WantCommentLine WantMode = "CommentLine" WantIdentifier WantMode = "Identifier" // G1 attributes are special, as the whole text inside the brackets has // to be lexed as one CharData token. We need several new WantModes to // properly expect all tokens in "@key{value}" after a "@" appeared. WantG1AttributeIdent WantMode = "G1AttributeIdent" WantG1AttributeStart WantMode = "G1AttributeStart" WantG1AttributeCharData WantMode = "G1AttributeCharData" WantG1AttributeEnd WantMode = "G1AttributeEnd" // WantG2AttributeValue is used when we parsed a '=' in G2 and now expect chardata. WantG2AttributeValue WantMode = "WantG2AttributeValue" )