1
0
Fork 0

Lexer doen't need to store state

This commit is contained in:
Gregory Eremin 2015-02-17 00:23:27 +07:00
parent d38122a34f
commit bf670810f8
1 changed files with 2 additions and 3 deletions

View File

@ -10,7 +10,6 @@ type (
// lexer holds the state of the scanner. // lexer holds the state of the scanner.
Lexer struct { Lexer struct {
input string // the string being scanned input string // the string being scanned
state stateFn // the next lexing function to enter
lineNum int // Line number lineNum int // Line number
pos int // current position in the input pos int // current position in the input
start int // start position of this item start int // start position of this item
@ -64,8 +63,8 @@ func New(input string) *Lexer {
// run runs the state machine for the lexer. // run runs the state machine for the lexer.
func (l *Lexer) Run() { func (l *Lexer) Run() {
for l.state = lexInitial; l.state != nil; { for state := lexInitial; state != nil; {
l.state = l.state(l) state = state(l)
} }
} }