Documentation
¶
Index ¶
Constants ¶
View Source
const EOF = 0
View Source
const ERROR = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // StateMachine is the Lox-generated state machine. StateMachine StateMachine // File is a go/token.File which is used to efficiently tag tokens with file // positions. File *gotoken.File // Input is input to be parsed by the Lexer. Input []byte }
Config configures a Lexer.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer is a simple lexer implementation to be used with lexer state machines produced by Lox. It produces tokens containing byte slices of the original input which may not be appropriate for very large or stream inputs.
type StateMachine ¶
type StateMachine interface { // PushRune pushes a rune to the state machine. It can return one of the // following: // 0 (consume): consume the rune and include it in the token. // 1 (accept): accept the current token. The token id is specified by Token(). // 2 (discard): discard current token. // 3 (try-again): Call PushRune again with the same rune. // 4 (EOF): We are done. // -1 (error): That's an error. PushRune(r rune) int // Token returns the token-id of the recognized token when PushRune // returns 1 (accept). Token() int // Reset resets the state machine so it can be used again. Reset() }
StateMachine is an interface that is satisfied by a state machine implementation generated by Lox.
type UnexpectedCharacterError ¶
type UnexpectedCharacterError struct {
Char rune
}
UnexpectedCharacterError is the error returned in Token when the lexer encounters an unexpected character.
func (UnexpectedCharacterError) Error ¶
func (e UnexpectedCharacterError) Error() string
Error implements the 'error' interface.
Click to show internal directories.
Click to hide internal directories.