Documentation ¶
Index ¶
- type LexFn
- type Lexer
- func (l *Lexer) Backup()
- func (l *Lexer) CurrentInput() string
- func (l *Lexer) Dec()
- func (l *Lexer) Emit(tokenType lexertoken.TokenType)
- func (l *Lexer) Errorf(format string, args ...interface{}) LexFn
- func (l *Lexer) Ignore()
- func (l *Lexer) Inc()
- func (l *Lexer) InputToEnd() string
- func (l *Lexer) IsEOF() bool
- func (l *Lexer) IsWhitespace() bool
- func (l *Lexer) Next() rune
- func (l *Lexer) NextToken() chan lexertoken.Token
- func (l *Lexer) Peek() rune
- func (l *Lexer) Run()
- func (l *Lexer) SetInput(b string)
- func (l *Lexer) Shutdown()
- func (l *Lexer) SkipWhitespace()
- type LexerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lexer ¶
type Lexer struct { Input string Tokens chan lexertoken.Token State LexFn Start int Pos int Width int }
func New ¶
func New(opts ...LexerOption) (*Lexer, error)
func (*Lexer) CurrentInput ¶
Returns a slice of the current input from the current lexer start position to the current position.
func (*Lexer) Emit ¶
func (l *Lexer) Emit(tokenType lexertoken.TokenType)
Puts a token onto the token channel. The value of l token is read from the input based on the current lexer position.
func (*Lexer) Ignore ¶
func (l *Lexer) Ignore()
Ignores the current token by setting the lexer's start position to the current reading position.
func (*Lexer) InputToEnd ¶
Return a slice of the input from the current lexer position to the end of the input string.
func (*Lexer) IsWhitespace ¶
Returns true/false if then next character is whitespace
func (*Lexer) Next ¶
Reads the next rune (character) from the input stream and advances the lexer position.
func (*Lexer) NextToken ¶
func (l *Lexer) NextToken() chan lexertoken.Token
func (*Lexer) Peek ¶
Returns the next rune in the stream, then puts the lexer position back. Basically reads the next rune without consuming it.
func (*Lexer) Run ¶
func (l *Lexer) Run()
Starts the lexical analysis and feeding tokens into the token channel.
func (*Lexer) SkipWhitespace ¶
func (l *Lexer) SkipWhitespace()
Skips whitespace until we get something meaningful.
type LexerOption ¶
type LexerOption func(*Lexer)
func WihInitalState ¶
func WihInitalState(lf LexFn) LexerOption
func WithInput ¶
func WithInput(i string) LexerOption