aboutsummaryrefslogtreecommitdiff
path: root/src/lexer
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-18 18:19:30 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-18 18:19:30 +0200
commit389691f4d11bf86c8be75927a2fbc01cff9c7059 (patch)
tree42ea2d556b415daa361d73f1ffca2d521235f3fd /src/lexer
parentc4f41ad2502567f641652eb745707d2c2817973b (diff)
feat(ast): parse content
Diffstat (limited to 'src/lexer')
-rw-r--r--src/lexer/Lexer.zig8
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);