diff options
Diffstat (limited to 'src/lexer/Lexed.zig')
| -rw-r--r-- | src/lexer/Lexed.zig | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lexer/Lexed.zig b/src/lexer/Lexed.zig new file mode 100644 index 0000000..b7c3b2c --- /dev/null +++ b/src/lexer/Lexed.zig @@ -0,0 +1,49 @@ +const std = @import("std"); +const Allocator = std.mem.Allocator; + +pub const Kind = enum { + literal, + delimiter, + title, + quote, + code, + code_block, + math, + math_block, + image, + link, + bold, + italic, + ref, + callout, + list_ordored, + list_unordored, + tag, +}; + +allocator: Allocator, +kind: Kind, +content: std.ArrayList(u8), + +const Self = @This(); + +pub fn init(alloc: Allocator, kind: Kind, content: std.ArrayList(u8)) Self { + return .{ + .allocator = alloc, + .kind = kind, + .content = content, + }; +} + +pub fn deinit(self: *Self) void { + self.content.deinit(self.allocator); +} + +pub fn clone(self: *const Self, alloc: Allocator) Allocator.Error!std.ArrayList(u8) { + return self.content.clone(alloc); +} + +pub fn equals(self: *const Self, kind: Kind, content: []const u8) bool { + if (self.kind != kind) return false; + return std.mem.eql(u8, self.content.items, content); +} |
