From 1aa00ad16b140b93d893166ce1b7e93f3b847069 Mon Sep 17 00:00:00 2001 From: Qrius Date: Thu, 26 Sep 2024 00:11:05 +0200 Subject: Expand arguments of macro if it doesn't exist --- src/macro_processor/macro_processor.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 { 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 { -- cgit v1.2.3