Browse Source

lexer: to simplify states, Lexer.EmitError() assumes EOF if nil is passed

Signed-off-by: Alejandro Mery <amery@jpi.io>
v0.2.x v0.2.0
Alejandro Mery 4 years ago
parent
commit
be53431904
  1. 5
      lexer/lexer.go

5
lexer/lexer.go

@ -101,6 +101,11 @@ func (lex *lexer) Emit(typ TokenType) {
}
func (lex *lexer) EmitError(err error) {
// if no error is passed, assume they mean EOF
if err == nil {
err = EOF
}
lex.tokens <- NewErrorToken(err, lex.pos)
}

Loading…
Cancel
Save