Pass EvalOptions to macro

This commit is contained in:
greg 2018-04-29 22:17:10 -07:00
parent 06638dc030
commit 2c5ebd636f
2 changed files with 6 additions and 6 deletions

View File

@ -105,7 +105,7 @@ impl ProgrammingLanguageInterface for Schala {
fn execute_pipeline(&mut self, input: &str, options: &EvalOptions) -> FinishedComputation { fn execute_pipeline(&mut self, input: &str, options: &EvalOptions) -> FinishedComputation {
//let chain = pass_chain![tokenizing::tokenize, parsing::parse]; //let chain = pass_chain![tokenizing::tokenize, parsing::parse];
let mut chain = pass_chain![self; let mut chain = pass_chain![self, options;
tokenizing_stage, tokenizing_stage,
parsing_stage, parsing_stage,
symbol_table_stage, symbol_table_stage,

View File

@ -194,17 +194,17 @@ pub trait ProgrammingLanguageInterface {
#[macro_export] #[macro_export]
macro_rules! pass_chain { macro_rules! pass_chain {
($state:expr; $($pass:path), *) => { ($state:expr, $options:expr; $($pass:path), *) => {
|text_input| { |text_input| {
let mut comp = UnfinishedComputation::default(); 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_export]
macro_rules! pass_chain_helper { 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); let pass_name = stringify!($pass);
println!("Running pass {}", pass_name); println!("Running pass {}", pass_name);
@ -213,7 +213,7 @@ macro_rules! pass_chain_helper {
$pass($state, $input, debug_pointer) $pass($state, $input, debug_pointer)
}; };
match output { match output {
Ok(result) => pass_chain_helper! { $state, $comp; result $(, $rest)* }, Ok(result) => pass_chain_helper! { ($state, $comp, $options); result $(, $rest)* },
Err(err) => { Err(err) => {
$comp.output(Err(format!("Pass {} failed with {:?}", pass_name, err))) $comp.output(Err(format!("Pass {} failed with {:?}", pass_name, err)))
} }
@ -221,7 +221,7 @@ macro_rules! pass_chain_helper {
} }
}; };
// Done // 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)); let final_output: FinishedComputation = $comp.finish(Ok($final_output));
final_output final_output