From fb4de6f2d694194dddbc8c0dc82dc92ecf6bab85 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 29 Apr 2018 20:58:08 -0700 Subject: [PATCH] Making use of UnfinishedComputation --- schala-repl/src/language.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index ae41806..88df780 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -197,32 +197,30 @@ macro_rules! pass_chain { ($state:expr, $($pass:path), *) => { |text_input| { let mut comp = UnfinishedComputation::default(); - pass_chain_helper! { $state; text_input $(, $pass)* } + pass_chain_helper! { $state, comp; text_input $(, $pass)* } } }; } #[macro_export] macro_rules! pass_chain_helper { - ($state:expr; $input:expr, $pass:path $(, $rest:path)*) => { + ($state:expr, $comp:expr; $input:expr, $pass:path $(, $rest:path)*) => { { let pass_name = stringify!($pass); println!("Running pass {}", pass_name); let output = $pass($state, $input); match output { - Ok(result) => pass_chain_helper! { $state; result $(, $rest)* }, + Ok(result) => pass_chain_helper! { $state, $comp; result $(, $rest)* }, Err(err) => { - let comp = UnfinishedComputation::default(); - comp.output(Err(format!("Pass {} failed with {:?}", pass_name, err))) + $comp.output(Err(format!("Pass {} failed with {:?}", pass_name, err))) } } } }; // Done - ($state:expr; $final_output:expr) => { + ($state:expr, $comp:expr; $final_output:expr) => { { - let comp = UnfinishedComputation::default(); - let final_output: FinishedComputation = comp.finish(Ok($final_output)); + let final_output: FinishedComputation = $comp.finish(Ok($final_output)); final_output } };