Documentation ¶
Index ¶
- func NewRuneStack() runeStack
- func NewStateStack() stateStack
- type L
- func (l *L) Backup() bool
- func (l *L) Current() string
- func (l *L) Emit(t TokenType)
- func (l *L) Error(e string)
- func (l *L) Ignore()
- func (l *L) IgnoreCharacter()
- func (l *L) Next() rune
- func (l *L) NextToken() (*Token, bool)
- func (l *L) Peek() rune
- func (l *L) PeekMany(n int) rune
- func (l *L) RunLexer()
- func (l *L) RunLexerSync()
- func (l *L) Take(chars string) bool
- func (l *L) TakeMany(chars string)
- func (l *L) TakeManyPattern(p *regexp.Regexp)
- func (l *L) TakePattern(p *regexp.Regexp) bool
- type StateFunc
- type Token
- type TokenType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRuneStack ¶
func NewRuneStack() runeStack
func NewStateStack ¶
func NewStateStack() stateStack
Types ¶
type L ¶
type L struct { Input string Start, Position int StartState StateFunc Err error Tokens chan Token ErrorHandler func(e string) Rewind runeStack StateRecord stateStack }
func (*L) Backup ¶
Backup will take the last rune read (if any) and back up. Backups can occur more than once per call to Next, but you can never Backup past the last point a token was emitted.
func (*L) Emit ¶
Emit will receive a token type and push a new token with the current analyzed value into the Tokens channel.
func (*L) Ignore ¶
func (l *L) Ignore()
Ignore clears the Rewind stack and then sets the current beginning Position to the current Position in the Input, which effectively ignores the section of the Input being analyzed.
func (*L) IgnoreCharacter ¶
func (l *L) IgnoreCharacter()
IgnoreCharacter removes the current character from the output
func (*L) Next ¶
Next pulls the next rune from the Lexer and returns it, moving the Position forward in the Input.
func (*L) NextToken ¶
NextToken returns the next token from the lexer and a value to denote whether or not the token is finished.
func (*L) Peek ¶
Peek performs a Next operation immediately followed by a Backup returning the peeked rune.
func (*L) PeekMany ¶ added in v1.0.2
PeekMany performs n Next operations immediately followed by n Backup operations returning the last peeked rune.
func (*L) RunLexer ¶
func (l *L) RunLexer()
Start begins executing the Lexer in an asynchronous manner (using a goroutine).
func (*L) RunLexerSync ¶
func (l *L) RunLexerSync()
func (*L) Take ¶
Take receives a string containing all acceptable characters and will take the next rune if it matches an acceptable character
func (*L) TakeMany ¶
TakeMany receives a string containing all acceptable characters and will continue over each rune until it finds an unacceptable rune
func (*L) TakeManyPattern ¶
TakeManyPattern receives a regex pattern and will continue over each rune until a non-match is found