From bf670810f8138b9bfc445a2da716a46cd33f3744 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Tue, 17 Feb 2015 00:23:27 +0700 Subject: [PATCH] Lexer doen't need to store state --- lexer/lexer.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lexer/lexer.go b/lexer/lexer.go index be59e2a..d10bdf3 100644 --- a/lexer/lexer.go +++ b/lexer/lexer.go @@ -10,7 +10,6 @@ type ( // lexer holds the state of the scanner. Lexer struct { input string // the string being scanned - state stateFn // the next lexing function to enter lineNum int // Line number pos int // current position in the input start int // start position of this item @@ -64,8 +63,8 @@ func New(input string) *Lexer { // run runs the state machine for the lexer. func (l *Lexer) Run() { - for l.state = lexInitial; l.state != nil; { - l.state = l.state(l) + for state := lexInitial; state != nil; { + state = state(l) } }