Add 'again' macro for recursive expansion
The 'again' macro is a new addition to the macro system, allowing for recursive macro expansion. This commit introduces the necessary AST nodes, macro expansion logic, and an integration test to ensure its functionality. The `soa_series.myc` example has also been updated to demonstrate its usage.
This commit is contained in:
@@ -275,6 +275,17 @@ impl<E: MacroEvaluator> MacroExpander<E> {
|
||||
})
|
||||
}
|
||||
|
||||
UntypedKind::Again { args } => {
|
||||
let expanded_args = self.expand_recursive(*args)?;
|
||||
Ok(Node {
|
||||
identity: node.identity,
|
||||
kind: UntypedKind::Again {
|
||||
args: Box::new(expanded_args),
|
||||
},
|
||||
ty: (),
|
||||
})
|
||||
}
|
||||
|
||||
_ => Ok(node),
|
||||
}
|
||||
}
|
||||
@@ -536,6 +547,17 @@ impl<E: MacroEvaluator> MacroExpander<E> {
|
||||
})
|
||||
}
|
||||
|
||||
UntypedKind::Again { args } => {
|
||||
let expanded_args = self.expand_template(*args, state)?;
|
||||
Ok(Node {
|
||||
identity: node.identity,
|
||||
kind: UntypedKind::Again {
|
||||
args: Box::new(expanded_args),
|
||||
},
|
||||
ty: (),
|
||||
})
|
||||
}
|
||||
|
||||
_ => Ok(node),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user