use clap::Parser; use std::io::Write as _; use std::path::{Path, PathBuf}; use nescript::analyzer; use nescript::assets::{BackgroundData, PaletteData}; use nescript::errors::render_diagnostics; use nescript::linker::{render_dbg, render_mlb, render_source_map, LinkedRom}; use nescript::pipeline::{compile_source, CompileError, CompileOptions as PipelineOptions}; #[derive(Parser)] #[command(name = "nescript", about = "NEScript compiler — NES game development")] enum Cli { /// Compile a .ne source file into a .nes ROM Build { /// Input source file input: PathBuf, /// Output ROM file (default: input with .nes extension) #[arg(short, long)] output: Option, /// Enable debug mode (runtime checks, debug.log) #[arg(long)] debug: bool, /// Dump generated 6502 assembly to stdout #[arg(long)] asm_dump: bool, /// Dump the lowered IR program to stdout (after optimization) #[arg(long)] dump_ir: bool, /// Dump a human-readable memory map of variable allocations /// to stdout. #[arg(long)] memory_map: bool, /// Dump a call graph showing which functions call which. #[arg(long)] call_graph: bool, /// Skip the IR optimizer pass. Useful for bisecting /// optimizer-introduced miscompiles: if a program misbehaves /// with the optimizer on but works with `--no-opt`, the bug /// lives in `src/optimizer/`. #[arg(long)] no_opt: bool, /// Write a Mesen-compatible symbol file (`.mlb`) next to the /// ROM. Contains one `:
: