diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-08-04 19:02:27 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-08-04 19:02:27 +0200 |
| commit | a10b091d78208907397a6d49791b27e04e675161 (patch) | |
| tree | bc695613559f14ce69baeb268bb23414dd05ad7e /src/z/parser/lexer.zig | |
| parent | 0bc6d195195d1e126b535554a4a4105468cd06d9 (diff) | |
add tokenizer for all other variants
Diffstat (limited to 'src/z/parser/lexer.zig')
| -rw-r--r-- | src/z/parser/lexer.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/z/parser/lexer.zig b/src/z/parser/lexer.zig index d9a2868..40e1209 100644 --- a/src/z/parser/lexer.zig +++ b/src/z/parser/lexer.zig @@ -69,6 +69,20 @@ pub fn Lexer(TokenKind: type) type { return null; } + pub fn consume(self: *Self) !u8 { + return (try self.consumeTo(1))[0]; + } + + pub fn consumeTo(self: *Self, n: usize) ![]const u8 { + if (n <= self.buffer.len) { + const slice = self.buffer[0..n]; + self.buffer = self.buffer[n..]; + return slice; + } else { + return Error.EndOfBuffer; + } + } + pub fn skip(self: *Self) !void { return self.skipTo(1); } |