aboutsummaryrefslogtreecommitdiff
path: root/src/lexer/Token.zig
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-24 17:40:33 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-24 17:40:33 +0200
commite7fa254387e450154f03b2d1bdef361a0adb80d1 (patch)
treefd655516c0f1e3d4925ede5d54d729a88507369b /src/lexer/Token.zig
parent263190b15ebcb1188df6fbc2bc90dca6e4ea5d8d (diff)
perf(lexer): do not alloc
Diffstat (limited to 'src/lexer/Token.zig')
-rw-r--r--src/lexer/Token.zig47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lexer/Token.zig b/src/lexer/Token.zig
new file mode 100644
index 0000000..cfe78f3
--- /dev/null
+++ b/src/lexer/Token.zig
@@ -0,0 +1,47 @@
+const std = @import("std");
+const Allocator = std.mem.Allocator;
+
+pub const Kind = enum {
+ literal,
+ weak_delimiter,
+ strong_delimiter,
+ title,
+ quote,
+ code,
+ code_block,
+ math,
+ math_block,
+ image,
+ link,
+ bold,
+ italic,
+ ref,
+ callout,
+ list_ordored,
+ list_unordored,
+ tag,
+
+ pub fn isDelimiter(self: @This()) bool {
+ return switch (self) {
+ .weak_delimiter, .strong_delimiter => true,
+ else => false,
+ };
+ }
+};
+
+pub const Loc = struct {
+ begin: usize,
+ end: usize,
+
+ pub fn get(self: @This(), content: []const u8) []const u8 {
+ return content[self.begin..self.end];
+ }
+};
+
+kind: Kind,
+content: []const u8,
+
+pub fn equals(self: @This(), kind: Kind, v: []const u8) bool {
+ if (self.kind != kind) return false;
+ return std.mem.eql(u8, self.content, v);
+}