diff --git a/schala-lang/src/lib.rs b/schala-lang/src/lib.rs index 46d3430..535ac34 100644 --- a/schala-lang/src/lib.rs +++ b/schala-lang/src/lib.rs @@ -111,4 +111,14 @@ impl ProgrammingLanguageInterface for Schala { ]; chain(input) } + + fn get_stages(&self) -> Vec { + vec![ + format!("tokenizing"), + format!("parsing"), //TODO handle both types of this + format!("symbol_table"), + format!("typechecking"), + format!("eval") + ] + } } diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index b4e7c63..52dcd4d 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -22,6 +22,7 @@ use std::process::exit; use std::default::Default; use std::fmt::Write as FmtWrite; +use itertools::Itertools; use rustyline::error::ReadlineError; use rustyline::Editor; use self::colored::*; @@ -148,6 +149,10 @@ impl Repl { } } + fn get_cur_language(&self) -> &ProgrammingLanguageInterface { + self.languages[self.current_language_index].as_ref() + } + fn get_options() -> EvalOptions { File::open(".schala_repl") .and_then(|mut file| { @@ -284,14 +289,20 @@ impl Repl { } } fn handle_debug(&mut self, commands: Vec<&str>) -> Option { + let stages = self.get_cur_language().get_stages(); match commands.get(1) { + Some(&"stages") => Some(stages.into_iter().intersperse(format!(" -> ")).collect()), b @ Some(&"show") | b @ Some(&"hide") => { let show = b == Some(&"show"); let debug_stage = match commands.get(2) { Some(s) => s, None => return Some(format!("Must specify a stage to debug")), }; - None + let maybe_debug = stages.iter().find(|stage_name| stage_name == debug_stage); + match maybe_debug { + Some(s) => Some(format!("Will debug {}", s)), + None => Some(format!("couldn't find it")) + } }, _ => Some(format!("Unknown debug command")) }