fix identifier lexemes

This commit is contained in:
Luna 2019-07-01 15:06:53 -03:00
parent b0e123f83a
commit ac23c0d2d7

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