From aaf98db2b7dc949e2274f59962214bf9bab13d49 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 1 May 2018 00:38:01 -0700 Subject: [PATCH] Starting to move debug options around + add method to ProgrammingLanguageInterface that is a list of stages --- schala-repl/src/language.rs | 3 +++ schala-repl/src/lib.rs | 30 +++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 9164450..4bb57a0 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -169,6 +169,9 @@ pub trait ProgrammingLanguageInterface { fn get_language_name(&self) -> String; fn get_source_file_suffix(&self) -> String; + fn get_stages(&self) -> Vec { + vec![] + } fn handle_custom_interpreter_directives(&mut self, _commands: &Vec<&str>) -> Option { None } diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index 1d36e65..b4e7c63 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -277,7 +277,26 @@ impl Repl { writeln!(buf, "{}", lang.custom_interpreter_directives_help()).unwrap(); Some(buf) }, - "debug" => { + "debug" => self.handle_debug(commands), + e => self.languages[self.current_language_index] + .handle_custom_interpreter_directives(&commands) + .or(Some(format!("Unknown command: {}", e))) + } + } + fn handle_debug(&mut self, commands: Vec<&str>) -> Option { + match commands.get(1) { + 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 + }, + _ => Some(format!("Unknown debug command")) + } + /* + * { let show = match commands.get(1) { Some(&"show") => true, Some(&"hide") => false, @@ -299,6 +318,9 @@ impl Repl { }; None }, + + AND DEBUG OPTIONS + "options" => { let ref d = self.options.debug; let tokens = if d.tokens { "true".green() } else { "false".red() }; @@ -308,10 +330,8 @@ impl Repl { Some(format!(r#"Debug: tokens: {}, parse: {}, ast: {}, symbols: {}"#, tokens, parse_tree, ast, symbol_table)) }, - e => self.languages[self.current_language_index] - .handle_custom_interpreter_directives(&commands) - .or(Some(format!("Unknown command: {}", e))) - } + + */ } }