Merge pull request #22 from absourdnoise/lexer-panic-fix

Fixed panic in lexer.fetchToken
This commit is contained in:
Victor Starodub
2016-04-21 23:30:53 +04:00
+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:] {