diff options
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig index da72d72..d9f6a13 100644 --- a/src/main.zig +++ b/src/main.zig @@ -17,8 +17,8 @@ pub fn main() !void { if (deinit_status == .leak) @panic("Memory leak detected!"); } - // const source_evaluator = try evaluator.Evaluator.init(allocator); - // defer source_evaluator.deinit(); + const source_evaluator = try evaluator.Evaluator.init(allocator); + defer source_evaluator.deinit(); var arena = std.heap.ArenaAllocator.init(allocator); defer arena.deinit(); @@ -30,7 +30,7 @@ pub fn main() !void { const buf = try stdin.readUntilDelimiterAlloc(allocator, '\n', 1024); defer allocator.free(buf); - process_buf(buf, allocator, &arena) catch |err| { + process_buf(buf, allocator, &arena, source_evaluator) catch |err| { try stdout.print("Error processing line: {any}\n", .{err}); }; } @@ -39,11 +39,11 @@ pub fn main() !void { const file = try std.fs.cwd().openFile(path, .{}); const buf = try file.readToEndAlloc(allocator, 1 * 1024 * 1024); defer allocator.free(buf); - try process_buf(buf, allocator, &arena); + try process_buf(buf, allocator, &arena, source_evaluator); } } -fn process_buf(buf: []u8, allocator: std.mem.Allocator, arena: *std.heap.ArenaAllocator) !void { +fn process_buf(buf: []u8, allocator: std.mem.Allocator, arena: *std.heap.ArenaAllocator, source_evaluator: *evaluator.Evaluator) !void { std.debug.print("Buf:\n{s}\n", .{buf}); var token_list = std.ArrayList(tokenizer.Token).init(allocator); @@ -59,8 +59,8 @@ fn process_buf(buf: []u8, allocator: std.mem.Allocator, arena: *std.heap.ArenaAl const ast = try source_parser.parse(); std.debug.print("AST: {any}\n", .{ast}); - // const result = try source_evaluator.evaluate_ast(ast); - // std.debug.print("Evaluation result: {any}\n", .{result}); + const result = try source_evaluator.evaluate_ast(ast); + std.debug.print("Evaluation result: {any}\n", .{result}); } test { |