Fully implemented state

If I make the LanguageInterface trait over a pair of language and
evaluator, then it works :)
This commit is contained in:
greg 2017-02-01 19:04:52 -08:00
parent 4ea600d55c
commit 902c85ccd7
2 changed files with 4 additions and 4 deletions

View File

@ -46,7 +46,7 @@ pub trait LanguageInterface {
fn evaluate_in_repl(&mut self, input: &str, options: LanguageInterfaceOptions) -> String;
}
impl<PL, T, A, E> LanguageInterface for PL where PL: ProgrammingLanguage<Token=T, AST=A, Evaluator=E>, T: Debug, A: Debug, E: EvaluationMachine {
impl<PL, T, A, E> LanguageInterface for (PL, PL::Evaluator) where PL: ProgrammingLanguage<Token=T, AST=A, Evaluator=E>, T: Debug, A: Debug, E: EvaluationMachine {
fn evaluate_in_repl(&mut self, input: &str, options: LanguageInterfaceOptions) -> String {
let mut output = String::new();
@ -79,8 +79,8 @@ impl<PL, T, A, E> LanguageInterface for PL where PL: ProgrammingLanguage<Token=T
output.push_str(&s);
} else {
// for now only handle last output
let mut evaluator = PL::Evaluator::new();
let mut full_output: Vec<String> = PL::evaluate(ast, &mut evaluator);
let ref mut evaluator = self.1;
let mut full_output: Vec<String> = PL::evaluate(ast, evaluator);
output.push_str(&full_output.pop().unwrap_or("".to_string()));
}
output

View File

@ -116,7 +116,7 @@ impl<'a> Repl<'a> {
show_tokens: false,
show_parse: false,
show_llvm_ir: show_llvm,
languages: vec![Box::new(Schala::new())],
languages: vec![Box::new((Schala::new(), SchalaEvaluator::new(None)))],
evaluator: evaluator,
interpreter_directive_sigil: '.',
reader: reader,