fix scanner peek/peekNext
This commit is contained in:
parent
765cef87db
commit
1e47b29685
1 changed files with 3 additions and 2 deletions
|
@ -148,12 +148,13 @@ pub const Scanner = struct {
|
||||||
|
|
||||||
fn peek(self: *Scanner) u8 {
|
fn peek(self: *Scanner) u8 {
|
||||||
if (self.isAtEnd()) return 0;
|
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 {
|
fn peekNext(self: *Scanner) u8 {
|
||||||
if (self.current + 1 >= self.source.len) return 0;
|
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 {
|
fn skipWhitespace(self: *Scanner) void {
|
||||||
|
|
Loading…
Reference in a new issue