feat: implement interactive debugger

Adds a REPL-based debugger with:
- Breakpoint management (set/delete by line number)
- Single-step and continue execution modes
- Source code listing with breakpoint markers
- Expression evaluation in debug context
- Variable inspection and call stack display

Usage: lux debug <file.lux>

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 10:37:02 -05:00
parent f786d18182
commit 1c59fdd735
2 changed files with 366 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
//! Lux - A functional programming language with first-class effects
mod ast;
mod debugger;
mod diagnostics;
mod exhaustiveness;
mod formatter;
@@ -121,6 +122,17 @@ fn main() {
}
check_file(&args[2]);
}
"debug" => {
// Start debugger
if args.len() < 3 {
eprintln!("Usage: lux debug <file.lux>");
std::process::exit(1);
}
if let Err(e) = debugger::Debugger::run(&args[2]) {
eprintln!("Debugger error: {}", e);
std::process::exit(1);
}
}
path => {
// Run a file
run_file(path);
@@ -142,6 +154,7 @@ fn print_help() {
println!(" lux check <file.lux> Type check without running");
println!(" lux test [pattern] Run tests (optional pattern filter)");
println!(" lux watch <file.lux> Watch and re-run on changes");
println!(" lux debug <file.lux> Start interactive debugger");
println!(" lux init [name] Initialize a new project");
println!(" lux --lsp Start LSP server (for IDE integration)");
println!(" lux --help Show this help");