From 415f3971c49de45704630bd45abe03ef641f47bf Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Fri, 20 Dec 2024 18:59:28 -0500 Subject: fixed memory leaks and added some print debugging --- src/main.zig | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/main.zig') 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); } -- cgit v1.2.3