aboutsummaryrefslogtreecommitdiff
path: root/src/lexer/Lexer.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer/Lexer.zig')
-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);