Documentation ¶
Overview ¶
Package lex provides a token and tree lexer, tree splitter and string quoting code.
Index ¶
- Constants
- Variables
- func ErrorAt(t Token, err error) error
- func ErrorAtPos(p Pos, err error) error
- func ErrorSkip(t Token, err error, want rune, skip int) error
- func ErrorWant(t Token, err error, want rune) error
- func TokStr(r rune) string
- type Error
- type Lexer
- type Pos
- type Src
- type Token
- type Tree
Constants ¶
View Source
const ( EOF rune // EOF rune indicates the end of file or another error. // Number rune indicates a number literal token. Number // String rune indicates a string literal token. String // Symbol rune indicates a identifier symbol token. Symbol // Tag rune indicates a tag token. Tag )
Special token runes. If not in this list the token rune represent an input rune.
Variables ¶
View Source
var ( // ErrUnexpected denotes an unexpected input rune. ErrUnexpected = cor.StrError("unexpected") // ErrUnterminated denotes an unterminated quote or open bracket. ErrUnterminated = cor.StrError("unterminated") // ErrExpectDigit denotes missing digits in a floating point format. ErrExpectDigit = cor.StrError("expect digit") )
Functions ¶
func ErrorAtPos ¶
Types ¶
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer is simple token lexer.
type Token ¶
Token represent a token recognized by the lexer with start offset and line position. The tok field hold either the special rune Number, String or Symbol or is itself the input rune. Special tokens also contain the read token input as string.
type Tree ¶
Tree represents either a single token or a sequence of trees starting with an open bracket. Trees contain the tokens file positions. A sequence tree token and position refers to the opening bracket and the end tree to its matching closing bracket.
Click to show internal directories.
Click to hide internal directories.