diff --git a/schala-repl/src/repl/mod.rs b/schala-repl/src/repl/mod.rs index efab953..8bd0e28 100644 --- a/schala-repl/src/repl/mod.rs +++ b/schala-repl/src/repl/mod.rs @@ -93,7 +93,33 @@ impl Repl { } fn handle_interpreter_directive(&mut self, input: &str) -> Option { - Some(format!("you typed {}, which is unsupported", input)) + let mut iter = input.chars(); + iter.next(); + let commands: Vec<&str> = iter + .as_str() + .split_whitespace() + .collect(); + + if commands.len() < 1 { + return None; + } + + let directives = self.get_directives(); + + let mut dir_pointer: &CommandTree = &directives; + for command in commands.iter() { + match dir_pointer { + CommandTree::Top(subcommands) | CommandTree::NonTerminal { children: subcommands, .. } => { + let q = subcommands; + + + }, + CommandTree::Terminal { name, .. } => { + + } + } + } + Some(format!("you typed {:?}", commands)) } fn get_cur_language_state(&mut self) -> &mut Box { @@ -141,7 +167,10 @@ impl Repl { */ CommandTree::Top(vec![ - CommandTree::term("exit", Some("exit the REPL")), + CommandTree::term_with_function("exit", Some("exit the REPL"), Box::new(|repl: &mut Repl, cmds: Vec| { + repl.save_before_exit(); + ::std::process::exit(0) + })), CommandTree::term_with_function("quit", Some("exit the REPL"), Box::new(|repl: &mut Repl, cmds: Vec| { repl.save_before_exit(); ::std::process::exit(0)