fix scanner peek/peekNext

This commit is contained in:
Luna 2019-06-04 17:28:48 -03:00
parent 765cef87db
commit 1e47b29685

View file

@ -148,12 +148,13 @@ pub const Scanner = struct {
fn peek(self: *Scanner) u8 {
if (self.isAtEnd()) return 0;
return self.source[self.current];
if (self.current == 0) return 0;
return self.source[self.current - 1];
}
fn peekNext(self: *Scanner) u8 {
if (self.current + 1 >= self.source.len) return 0;
return self.source[self.current + 1];
return self.source[self.current];
}
fn skipWhitespace(self: *Scanner) void {