diff --git a/schala-repl/src/repl/mod.rs b/schala-repl/src/repl/mod.rs index 0c2b527..276f968 100644 --- a/schala-repl/src/repl/mod.rs +++ b/schala-repl/src/repl/mod.rs @@ -287,140 +287,6 @@ impl Repl { */ -/* - fn handle_interpreter_directive(&mut self, input: &str) -> Option { - let mut iter = input.chars(); - iter.next(); - let commands: Vec<&str> = iter - .as_str() - .split_whitespace() - .collect(); - - let initial_cmd: &str = match commands.get(0).clone() { - None => return None, - Some(s) => s - }; - - match initial_cmd { - "exit" | "quit" => { - self.save_options(); - ::std::process::exit(0) - }, - "lang" | "language" => match commands.get(1) { - Some(&"show") => { - let mut buf = String::new(); - for (i, lang) in self.languages.iter().enumerate() { - write!(buf, "{}{}\n", if i == self.current_language_index { "* "} else { "" }, lang.get_language_name()).unwrap(); - } - Some(buf) - }, - Some(&"go") => match commands.get(2) { - None => Some(format!("Must specify a language name")), - Some(&desired_name) => { - for (i, _) in self.languages.iter().enumerate() { - let lang_name = self.languages[i].get_language_name(); - if lang_name.to_lowercase() == desired_name.to_lowercase() { - self.current_language_index = i; - return Some(format!("Switching to {}", self.languages[self.current_language_index].get_language_name())); - } - } - Some(format!("Language {} not found", desired_name)) - } - }, - Some(&"next") | Some(&"n") => { - self.current_language_index = (self.current_language_index + 1) % self.languages.len(); - Some(format!("Switching to {}", self.languages[self.current_language_index].get_language_name())) - }, - Some(&"previous") | Some(&"p") | Some(&"prev") => { - self.current_language_index = if self.current_language_index == 0 { self.languages.len() - 1 } else { self.current_language_index - 1 }; - Some(format!("Switching to {}", self.languages[self.current_language_index].get_language_name())) - }, - Some(e) => Some(format!("Bad `lang(uage)` argument: {}", e)), - None => Some(format!("Valid arguments for `lang(uage)` are `show`, `next`|`n`, `previous`|`prev`|`n`")) - }, - "help" => { - let mut buf = String::new(); - let ref lang = self.languages[self.current_language_index]; - let directives = match self.get_directives() { - CommandTree::Top(children) => children, - _ => panic!("Top-level CommandTree not Top") - }; - - writeln!(buf, "MetaInterpreter options").unwrap(); - writeln!(buf, "-----------------------").unwrap(); - - for directive in directives { - let trailer = " "; - writeln!(buf, "{}{}- {}", directive.get_cmd(), trailer, directive.get_help()).unwrap(); - } - - writeln!(buf, "").unwrap(); - writeln!(buf, "Language-specific help for {}", lang.get_language_name()).unwrap(); - writeln!(buf, "-----------------------").unwrap(); - writeln!(buf, "{}", lang.custom_interpreter_directives_help()).unwrap(); - Some(buf) - }, - "debug" => self.handle_debug(commands), - "doc" => self.languages[self.current_language_index] - .get_doc(&commands) - .or(Some(format!("No docs implemented"))), - 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 { - let passes = self.get_cur_language().get_passes(); - match commands.get(1) { - Some(&"timing") => match commands.get(2) { - Some(&"on") => { self.options.debug_timing = true; None } - Some(&"off") => { self.options.debug_timing = false; None } - _ => return Some(format!(r#"Argument to "timing" must be "on" or "off""#)), - }, - Some(&"passes") => Some( - passes.into_iter() - .map(|desc| { - if self.options.debug_passes.contains_key(&desc.name) { - let color = "green"; - format!("*{}", desc.name.color(color)) - } else { - desc.name - } - }) - .intersperse(format!(" -> ")) - .collect()), - b @ Some(&"show") | b @ Some(&"hide") => { - let show = b == Some(&"show"); - let debug_pass: String = match commands.get(2) { - Some(s) => s.to_string(), - None => return Some(format!("Must specify a stage to debug")), - }; - let pass_opt = commands.get(3); - if let Some(desc) = passes.iter().find(|desc| desc.name == debug_pass) { - let mut opts = vec![]; - if let Some(opt) = pass_opt { - opts.push(opt.to_string()); - } - let msg = format!("{} debug for pass {}", if show { "Enabling" } else { "Disabling" }, debug_pass); - if show { - self.options.debug_passes.insert(desc.name.clone(), PassDebugOptionsDescriptor { opts }); - } else { - self.options.debug_passes.remove(&desc.name); - } - Some(msg) - } else { - Some(format!("Couldn't find stage: {}", debug_pass)) - } - }, - _ => Some(format!("Unknown debug command")) - } - } - */ - struct TabCompleteHandler { sigil: char, top_level_commands: CommandTree,