From 26c258b0157e4e4e0b3005496828a406f49f609d Mon Sep 17 00:00:00 2001 From: Baitinq Date: Wed, 8 Jan 2025 21:32:26 +0100 Subject: Parser: Use arena allocator --- src/parser.zig | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'src/parser.zig') diff --git a/src/parser.zig b/src/parser.zig index 7fb6372..e855cbd 100644 --- a/src/parser.zig +++ b/src/parser.zig @@ -49,31 +49,6 @@ pub const Parser = struct { return parser; } - //TODO: We maybe should use an arena alocator or smth - pub fn deinit(self: *Parser, ast: ?*Node) void { - if (ast != null) { - std.debug.assert(ast.?.* == .PROGRAM); - for (ast.?.PROGRAM.statements) |statement| { - switch (statement.*) { - .STATEMENT => |x| { - switch (x.statement.*) { - .PRINT_STATEMENT => |p| { - self.allocator.destroy(p.expression); - }, - else => @panic("NOT IMPLEMENTED"), - } - self.allocator.destroy(x.statement); - }, - else => @panic("NOT IMPLEMENTED"), - } - self.allocator.destroy(statement); - } - self.allocator.free(ast.?.PROGRAM.statements); - self.allocator.destroy(ast.?); - } - self.allocator.destroy(self); - } - pub fn parse(self: *Parser) !*Node { return self.parse_program(); } -- cgit 1.4.1