diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-18 18:19:30 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-18 18:19:30 +0200 |
| commit | 389691f4d11bf86c8be75927a2fbc01cff9c7059 (patch) | |
| tree | 42ea2d556b415daa361d73f1ffca2d521235f3fd /src/lexer | |
| parent | c4f41ad2502567f641652eb745707d2c2817973b (diff) | |
feat(ast): parse content
Diffstat (limited to 'src/lexer')
| -rw-r--r-- | src/lexer/Lexer.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lexer/Lexer.zig b/src/lexer/Lexer.zig index f492be6..7524479 100644 --- a/src/lexer/Lexer.zig +++ b/src/lexer/Lexer.zig @@ -13,11 +13,17 @@ pub const Error = error{ InvalidUtf8, } || Allocator.Error; -pub fn init(content: []const u8) Error!Self { +pub fn init(content: []const u8) error{InvalidUtf8}!Self { const view = try unicode.Utf8View.init(content); return .{ .iter = view.iterator() }; } +pub fn nextKind(self: *Self) ?Lexed.Kind { + const next_rune = self.iter.peek(1); + if (next_rune.len == 0) return null; + return self.getCurrentKind(null, next_rune, &[0]u8{}).kind; +} + pub fn next(self: *Self, alloc: Allocator) Error!?Lexed { var acc = try std.ArrayList(u8).initCapacity(alloc, 2); errdefer acc.deinit(alloc); |
