Documentation ¶
Index ¶
- Variables
- type Cursor
- type Error
- type Lexer
- func (l *Lexer) AcceptFunc(fn func(rune) bool) (rune, error)
- func (l *Lexer) AcceptRune(exp rune) (rune, error)
- func (l *Lexer) AcceptString(exp string) (string, error)
- func (l *Lexer) AcceptUntil(fn func(rune) bool) (string, error)
- func (l *Lexer) Discard()
- func (l *Lexer) Emit(typ TokenType, val interface{})
- func (l *Lexer) Error(err error) StateFunc
- func (l *Lexer) Errorf(format string, args ...interface{}) StateFunc
- func (l *Lexer) Next() Token
- func (l *Lexer) PeekRune() (rune, int, error)
- func (l *Lexer) ReadRune() (r rune, w int, err error)
- func (l *Lexer) Reset()
- func (l *Lexer) Token() string
- func (l *Lexer) UnreadRune() error
- type Marshaler
- type Node
- type NodeType
- type Parser
- type Regexp
- type StateFunc
- type Token
- type TokenType
- type TokenTypeError
- type UnexpectedTokenError
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrUnexpectedToken = UnexpectedTokenError{}
)
Functions ¶
This section is empty.
Types ¶
type Cursor ¶
type Cursor struct {
Line, Column int
}
Cursor represents a cursor position within a document, i.e. a line and a column number, both starting at 1.
type Error ¶
type Error struct { // The file path in which the error occured (optional) Filename string // The cursor position of the error Cursor // The concrete error Err error }
Error represents a syntax error at a specific cursor position.
type Lexer ¶
type Lexer struct { // The input of this lexer. Typically a bufio.Reader. Input io.RuneReader // The cursor position marking the start of the current token. TokenPosition Cursor // The cursor position at which the lexer will be reading next. NextPosition Cursor // The cursor position of the current rune. Position Cursor // contains filtered or unexported fields }
func (*Lexer) UnreadRune ¶
type Node ¶
type Node struct { // The type of node Type NodeType // The interpreted value of the node Value interface{} // The starting position of the node in the file (ignoring comments and whitespace) Position Cursor // The immediate sibling of the node (may be nil if no sibling) Sibling *Node // The first child of the node (may be nil if no children) Child *Node // Tokens contains the tokens that are part of this node element Tokens []Token // Suffix contains the tokens that are part of this node, // but appear after its children Suffix []Token }
Node represents a node in a parse tree.
type Regexp ¶
type Regexp struct {
// contains filtered or unexported fields
}
Accept is a more consistently-behaving regexp matcher. It uses regexp/syntax under the covers, and guarantees that no runes are read unnecessarily. It's not particularly fast, and does not optimize at all the regexp bytecode, but it is correct and conservative in its rune reading.
func CompileRegexp ¶
func MustCompileRegexp ¶
type Token ¶
type TokenType ¶
type TokenType string
const ( TokenEOF TokenType = "" TokenError TokenType = "<error>" TokenComment TokenType = "<comment>" TokenInlineComment TokenType = "<inline-comment>" TokenString TokenType = "<string>" TokenNumber TokenType = "<number>" TokenBool TokenType = "<bool>" TokenIdentifier TokenType = "<identifier>" TokenNil TokenType = "<nil>" TokenNewline TokenType = "<newline>" TokenWhitespace TokenType = "<whitespace>" )
type TokenTypeError ¶
func (TokenTypeError) Error ¶
func (e TokenTypeError) Error() string
func (TokenTypeError) Unwrap ¶
func (e TokenTypeError) Unwrap() error
type UnexpectedTokenError ¶
type UnexpectedTokenError []TokenType
func (UnexpectedTokenError) Error ¶
func (e UnexpectedTokenError) Error() string
Click to show internal directories.
Click to hide internal directories.