const std = @import("std"); const tokenize = @import("tokenizer.zig").tokenize; const parse = @import("parser.zig").parse; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); const args = try std.process.argsAlloc(allocator); defer std.process.argsFree(allocator, args); const file = try std.fs.cwd().openFile(args[1], .{}); defer file.close(); const content = try file.readToEndAlloc(allocator, 13000); defer allocator.free(content); const tokens = try tokenize(content, allocator); defer { var i: usize = 0; while(i < tokens.len) { switch(tokens[i].tokenData) { .string => |*data| { allocator.free(data.*); }, else => {} } i += 1; } allocator.free(tokens); } var parserAllocator = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer parserAllocator.deinit(); const root = try parse(tokens, &parserAllocator); root.dump(0); }