fix identifier lexemes
This commit is contained in:
parent
b0e123f83a
commit
ac23c0d2d7
1 changed files with 7 additions and 0 deletions
|
@ -110,6 +110,10 @@ pub const Scanner = struct {
|
||||||
return self.source[self.current - 1];
|
return self.source[self.current - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn rollback(self: *Scanner) void {
|
||||||
|
self.current -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn currentLexeme(self: *Scanner) []const u8 {
|
pub fn currentLexeme(self: *Scanner) []const u8 {
|
||||||
return self.source[self.start..self.current];
|
return self.source[self.start..self.current];
|
||||||
}
|
}
|
||||||
|
@ -257,6 +261,9 @@ pub const Scanner = struct {
|
||||||
toktype = TokenType.Identifier;
|
toktype = TokenType.Identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ugly hack.
|
||||||
|
self.rollback();
|
||||||
|
|
||||||
return self.makeToken(toktype);
|
return self.makeToken(toktype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue