From b3068f0e16ffc4bb20cad6f74de5c5f815f6ed9d Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Wed, 18 Feb 2015 00:26:19 +0700 Subject: [PATCH] Closing items channel in one place --- lexer/lexer.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lexer/lexer.go b/lexer/lexer.go index b3e0557..03f475d 100644 --- a/lexer/lexer.go +++ b/lexer/lexer.go @@ -75,6 +75,7 @@ func (l *Lexer) Run() { for state := lexInitial; state != nil; { state = state(l) } + close(l.items) } // Returns the next scanned item and a boolean, which is false on EOF @@ -151,9 +152,6 @@ func (l *Lexer) emit(t Token) { Column: l.startCol, } l.ignore() // Cleaning up input - if t == EOF { - close(l.items) - } } // Emits an error token with given string as a value and stops lexing @@ -165,7 +163,6 @@ func (l *Lexer) errorf(format string, args ...interface{}) stateFn { Line: l.startLine, Column: l.startCol, } - close(l.items) return nil }