cli: add --stage3 flag to enable Stage-3 acceptance for selfhost parser (sets NYASH_NY_COMPILER_STAGE3=1)

This commit is contained in:
Selfhosting Dev
2025-09-17 01:24:22 +09:00
parent adbfbb2c76
commit d3103cead8

View File

@ -105,6 +105,12 @@ impl CliConfig {
.value_name("FILE")
.help("Read Ny JSON IR v0 from a file and execute via MIR Interpreter")
)
.arg(
Arg::new("stage3")
.long("stage3")
.help("Enable Stage-3 syntax acceptance for selfhost parser (sets NYASH_NY_COMPILER_STAGE3=1)")
.action(clap::ArgAction::SetTrue)
)
.arg(
Arg::new("ny-compiler-args")
.long("ny-compiler-args")
@ -381,6 +387,10 @@ impl CliConfig {
/// Convert ArgMatches to CliConfig
fn from_matches(matches: &ArgMatches) -> Self {
// Stage-3 gate: when specified via CLI, set env for selfhost child
if matches.get_flag("stage3") {
std::env::set_var("NYASH_NY_COMPILER_STAGE3", "1");
}
// Side-effect: forward child args for selfhost compiler via env
if let Some(a) = matches.get_one::<String>("ny-compiler-args") {
std::env::set_var("NYASH_NY_COMPILER_CHILD_ARGS", a);