diff options
Diffstat (limited to 'src/macro_processor')
-rw-r--r-- | src/macro_processor/macro_processor.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/macro_processor/macro_processor.rs b/src/macro_processor/macro_processor.rs index 326b28f..85bf8e1 100644 --- a/src/macro_processor/macro_processor.rs +++ b/src/macro_processor/macro_processor.rs @@ -347,7 +347,18 @@ impl MacroProcessor { /// * `args` - List of arguments parsed along with macro invokation (empty list if no arguments were parsed) fn expand_macro(&mut self, macro_name: &str, args: &mut [String]) -> Result<String, SMPError> { let Some(macro_body) = self.macros.get(macro_name) else { - return Ok(format!("{}", macro_name)); + if args.len() == 0 { + return Ok(format!("{}", macro_name)); + } + let mut out = format!("{}(", macro_name); + for (i, arg) in args.iter().enumerate() { + out.push_str(&self.process_input(arg)?); + if i < (args.len() - 1) { + out.push(','); + } + } + out.push(')'); + return Ok(out); }; match macro_body { |