feat: improved parsing and regression test suite

This commit is contained in:
Brett Broadhurst 2026-02-27 18:07:02 -07:00
parent 4ebdd3c66e
commit 619eb3b338
Failed to generate hash of commit
39 changed files with 1116 additions and 339 deletions

View file

@ -31,11 +31,25 @@ fn mainArgs(
) !void {
var source_path: ?[]const u8 = null;
var arg_index: usize = 1;
var compile_only: bool = false;
var dump_ast: bool = false;
var use_stdin: bool = false;
var use_color: bool = false;
while (arg_index < args_list.len) : (arg_index += 1) {
const arg = args_list[arg_index];
if (std.mem.startsWith(u8, arg, "-")) {
// TODO: Parse CLI options.
if (std.mem.eql(u8, arg, "--stdin")) {
use_stdin = true;
} else if (std.mem.eql(u8, arg, "--compile-only")) {
compile_only = true;
} else if (std.mem.eql(u8, arg, "--dump-ast")) {
dump_ast = true;
} else if (std.mem.eql(u8, arg, "--use-color")) {
use_color = true;
} else {
fatal("invalid parameter: '{s}'", .{arg});
}
} else if (source_path == null) {
source_path = arg;
} else {
@ -62,7 +76,8 @@ fn mainArgs(
var stdout_writer = stdout.writer(&stdout_buffer);
var story = try ink.Story.loadFromString(gpa, source_bytes, .{
.stream_writer = &stdout_writer.interface,
.dump_writer = &stdout_writer.interface,
.dump_use_color = use_color,
});
defer story.deinit();
}