diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-15 00:46:15 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2025-01-15 00:46:15 +0100 |
commit | 875efb6a01514996ed7fff9d6714acc472928767 (patch) | |
tree | f389b076a0bcf2451f7a88595fc63016b1725e7c /src/main.zig | |
parent | Parser: clean (diff) | |
download | interpreter-875efb6a01514996ed7fff9d6714acc472928767.tar.gz interpreter-875efb6a01514996ed7fff9d6714acc472928767.tar.bz2 interpreter-875efb6a01514996ed7fff9d6714acc472928767.zip |
Add basic support for parsing functions
Diffstat (limited to 'src/main.zig')
-rw-r--r-- | src/main.zig | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main.zig b/src/main.zig index e7ebba3..da72d72 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, source_evaluator) catch |err| { + process_buf(buf, allocator, &arena) 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, source_evaluator); + try process_buf(buf, allocator, &arena); } } -fn process_buf(buf: []u8, allocator: std.mem.Allocator, arena: *std.heap.ArenaAllocator, source_evaluator: *evaluator.Evaluator) !void { +fn process_buf(buf: []u8, allocator: std.mem.Allocator, arena: *std.heap.ArenaAllocator) !void { std.debug.print("Buf:\n{s}\n", .{buf}); var token_list = std.ArrayList(tokenizer.Token).init(allocator); @@ -55,12 +55,12 @@ fn process_buf(buf: []u8, allocator: std.mem.Allocator, arena: *std.heap.ArenaAl try token_list.append(token); } - const source_parser = try parser.Parser.init(token_list.items, arena.allocator()); + const source_parser = try parser.Parser.init(token_list.items, arena); 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 { |