Pass EvalOptions to macro
This commit is contained in:
parent
06638dc030
commit
2c5ebd636f
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user