|
1 | 1 | const std = @import("std");
|
2 | 2 |
|
| 3 | +const converter = @import("converter"); |
| 4 | + |
3 | 5 | const zglfw = @import("zglfw");
|
4 | 6 | const zgpu = @import("zgpu");
|
5 | 7 | const zgui = @import("zgui");
|
@@ -54,6 +56,54 @@ pub fn main() !void {
|
54 | 56 | if (zgui.begin("Button list", .{})) {
|
55 | 57 | if (zgui.button("Convert", .{ .w = 200.0 })) {
|
56 | 58 | std.debug.print("Converting...\n", .{});
|
| 59 | + |
| 60 | + var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 61 | + defer arena.deinit(); |
| 62 | + var allocator = arena.allocator(); |
| 63 | + |
| 64 | + const cwd = std.fs.cwd(); |
| 65 | + |
| 66 | + var input_mod_path_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; |
| 67 | + const input_mod_path = try cwd.realpath("I:/Programming/Cortex-Command-Mod-Converter-Engine/tests/mod/in", &input_mod_path_buffer); |
| 68 | + |
| 69 | + var output_mod_path_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; |
| 70 | + const output_mod_path = try cwd.realpath("I:/Programming/Cortex-Command-Mod-Converter-Engine/tests/mod/out", &output_mod_path_buffer); |
| 71 | + |
| 72 | + var diagnostics: converter.Diagnostics = .{}; |
| 73 | + converter.convert( |
| 74 | + input_mod_path, |
| 75 | + output_mod_path, |
| 76 | + allocator, |
| 77 | + &diagnostics, |
| 78 | + ) catch |err| switch (err) { |
| 79 | + error.UnexpectedToken => { |
| 80 | + const token = diagnostics.token orelse "null"; |
| 81 | + const file_path = diagnostics.file_path orelse "null"; |
| 82 | + const line = diagnostics.line orelse -1; |
| 83 | + const column = diagnostics.column orelse -1; |
| 84 | + |
| 85 | + std.debug.print("Error: Unexpected token\nToken: '{s}'\nFile path: {s}\nLine: {}\nColumn: {} (roughly)\n", .{ |
| 86 | + token, |
| 87 | + file_path, |
| 88 | + line, |
| 89 | + column, |
| 90 | + }); |
| 91 | + }, |
| 92 | + error.TooManyTabs => { |
| 93 | + const file_path = diagnostics.file_path orelse "null"; |
| 94 | + const line = diagnostics.line orelse -1; |
| 95 | + const column = diagnostics.column orelse -1; |
| 96 | + |
| 97 | + std.debug.print("Error: Too many tabs\nFile path: {s}\nLine: {} (roughly)\nColumn: {} (roughly)\n", .{ |
| 98 | + file_path, |
| 99 | + line, |
| 100 | + column, |
| 101 | + }); |
| 102 | + }, |
| 103 | + else => |e| return e, |
| 104 | + }; |
| 105 | + |
| 106 | + std.debug.print("Done converting!\n", .{}); |
57 | 107 | }
|
58 | 108 | }
|
59 | 109 | zgui.end();
|
|
0 commit comments