diff --git a/src/scanner.zig b/src/scanner.zig index 491f1f2..56084a5 100644 --- a/src/scanner.zig +++ b/src/scanner.zig @@ -110,6 +110,10 @@ pub const Scanner = struct { return self.source[self.current - 1]; } + fn rollback(self: *Scanner) void { + self.current -= 1; + } + pub fn currentLexeme(self: *Scanner) []const u8 { return self.source[self.start..self.current]; } @@ -257,6 +261,9 @@ pub const Scanner = struct { toktype = TokenType.Identifier; } + // ugly hack. + self.rollback(); + return self.makeToken(toktype); }