1
0
Fork 0

Closing items channel in one place

This commit is contained in:
Gregory Eremin 2015-02-18 00:26:19 +07:00
parent 87f8cdded6
commit b3068f0e16
1 changed files with 1 additions and 4 deletions

View File

@ -75,6 +75,7 @@ func (l *Lexer) Run() {
for state := lexInitial; state != nil; { for state := lexInitial; state != nil; {
state = state(l) state = state(l)
} }
close(l.items)
} }
// Returns the next scanned item and a boolean, which is false on EOF // 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, Column: l.startCol,
} }
l.ignore() // Cleaning up input l.ignore() // Cleaning up input
if t == EOF {
close(l.items)
}
} }
// Emits an error token with given string as a value and stops lexing // 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, Line: l.startLine,
Column: l.startCol, Column: l.startCol,
} }
close(l.items)
return nil return nil
} }