Lexer doen't need to store state
This commit is contained in:
parent
d38122a34f
commit
bf670810f8
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue