summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorStefan Weigl-Bosker <stefan@s00.xyz>2024-12-20 18:59:28 -0500
committerStefan Weigl-Bosker <stefan@s00.xyz>2024-12-20 18:59:28 -0500
commit415f3971c49de45704630bd45abe03ef641f47bf (patch)
tree100a81e0ddc6a7e4799c3862149511b320a13232 /src/main.zig
parent32d0ac56c27719c6fcde70c51238f11cf5f44141 (diff)
downloadlg-415f3971c49de45704630bd45abe03ef641f47bf.tar.gz
fixed memory leaks and added some print debugging
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/main.zig b/src/main.zig
index f28ab18..8741cd7 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -8,24 +8,16 @@ pub fn main() !void {
defer _ = gpa.deinit();
- const lexer = try allocator.create(Regex.Lexer);
+ var lexer = Regex.Lexer.init("bz*[a-z](l)", &allocator);
- lexer.* = Regex.Lexer.init("abc|123[a-Z]()+", &allocator);
+ _ = try lexer.scan();
- const tl = try lexer.scan();
+ var parser = Regex.Parser.init(&lexer.tokens, &allocator);
- var it = tl.first;
- while (it) |node| : (it = node.next) {
- try stdio.print("{}\n", .{&(node.data)});
- }
+ const pt = try parser.parse();
- const parser = try allocator.create(Regex.Parser);
-
- parser.* = Regex.Parser.init(&lexer.tokens, &allocator);
-
- _ = try parser.parseRe();
+ try stdio.print("{}\n", .{pt});
+ parser.deinit();
lexer.deinit();
- allocator.destroy(lexer);
- allocator.destroy(parser);
}