fix identifier lexemes

This commit is contained in:
Luna 2019-07-01 15:06:53 -03:00
parent b0e123f83a
commit ac23c0d2d7
1 changed files with 7 additions and 0 deletions

View File

@ -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);
}