From 2c5ebd636fd2f3c66c05850e4f4ebd6390f34420 Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 29 Apr 2018 22:17:10 -0700 Subject: [PATCH] Pass EvalOptions to macro --- schala-lang/src/lib.rs | 2 +- schala-repl/src/language.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/schala-lang/src/lib.rs b/schala-lang/src/lib.rs index b994304..a124b1f 100644 --- a/schala-lang/src/lib.rs +++ b/schala-lang/src/lib.rs @@ -105,7 +105,7 @@ impl ProgrammingLanguageInterface for Schala { fn execute_pipeline(&mut self, input: &str, options: &EvalOptions) -> FinishedComputation { //let chain = pass_chain![tokenizing::tokenize, parsing::parse]; - let mut chain = pass_chain![self; + let mut chain = pass_chain![self, options; tokenizing_stage, parsing_stage, symbol_table_stage, diff --git a/schala-repl/src/language.rs b/schala-repl/src/language.rs index 956bd4b..d5e4868 100644 --- a/schala-repl/src/language.rs +++ b/schala-repl/src/language.rs @@ -194,17 +194,17 @@ pub trait ProgrammingLanguageInterface { #[macro_export] macro_rules! pass_chain { - ($state:expr; $($pass:path), *) => { + ($state:expr, $options:expr; $($pass:path), *) => { |text_input| { let mut comp = UnfinishedComputation::default(); - pass_chain_helper! { $state, comp; text_input $(, $pass)* } + pass_chain_helper! { ($state, comp, $options); text_input $(, $pass)* } } }; } #[macro_export] macro_rules! pass_chain_helper { - ($state:expr, $comp:expr; $input:expr, $pass:path $(, $rest:path)*) => { + (($state:expr, $comp:expr, $options:expr); $input:expr, $pass:path $(, $rest:path)*) => { { let pass_name = stringify!($pass); println!("Running pass {}", pass_name); @@ -213,7 +213,7 @@ macro_rules! pass_chain_helper { $pass($state, $input, debug_pointer) }; match output { - Ok(result) => pass_chain_helper! { $state, $comp; result $(, $rest)* }, + Ok(result) => pass_chain_helper! { ($state, $comp, $options); result $(, $rest)* }, Err(err) => { $comp.output(Err(format!("Pass {} failed with {:?}", pass_name, err))) } @@ -221,7 +221,7 @@ macro_rules! pass_chain_helper { } }; // Done - ($state:expr, $comp:expr; $final_output:expr) => { + (($state:expr, $comp:expr, $options:expr); $final_output:expr) => { { let final_output: FinishedComputation = $comp.finish(Ok($final_output)); final_output