From 389691f4d11bf86c8be75927a2fbc01cff9c7059 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Sat, 18 Apr 2026 18:19:30 +0200 Subject: feat(ast): parse content --- src/lexer/Lexer.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/lexer') 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); -- cgit v1.2.3