Fixed panic in lexer.fetchToken

This commit is contained in:
Andrew Po
2016-04-21 20:20:33 +03:00
parent af01f9e8dc
commit 83f0a26bae
+6
View File
@@ -53,6 +53,12 @@ func (r *Lexer) fetchToken() {
r.token.kind = tokenUndef
r.start = r.pos
// Check if r.Data has r.pos element
// If it doesn't, it mean corrupted input data
if len(r.Data) < r.pos {
r.errParse("Unexpected end of data")
return
}
// Determine the type of a token by skipping whitespace and reading the
// first character.
for _, c := range r.Data[r.pos:] {