diff options
author | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
---|---|---|
committer | Qrius <[email protected]> | 2024-09-26 00:11:05 +0200 |
commit | 4b3670fc6b037911be8a1320b5994eb89886e41f (patch) | |
tree | a91e3c8672bc7430aca9151b7876a854c3369442 /src/macro_processor | |
parent | 1aa00ad16b140b93d893166ce1b7e93f3b847069 (diff) | |
download | skaldpress-4b3670fc6b037911be8a1320b5994eb89886e41f.tar.gz skaldpress-4b3670fc6b037911be8a1320b5994eb89886e41f.zip |
Add man pages, add array function to SMP
Diffstat (limited to 'src/macro_processor')
-rw-r--r-- | src/macro_processor/macro_processor.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/macro_processor/macro_processor.rs b/src/macro_processor/macro_processor.rs index 85bf8e1..96d5471 100644 --- a/src/macro_processor/macro_processor.rs +++ b/src/macro_processor/macro_processor.rs @@ -246,6 +246,7 @@ pub enum MacroType { ), /// Will be expanded in-place to the String String(String), + Array(Vec<MacroType>), } /// Possible parser states @@ -339,6 +340,17 @@ impl MacroProcessor { self.macros.insert(name, macro_expansion); } + pub fn array_push(&mut self, name: String, element: MacroType) -> Result<(), SMPError> { + let Some(macro_body) = self.macros.get_mut(&name) else { + return Err(SMPError::UnknownError(4, None)); + }; + let MacroType::Array(array) = macro_body else { + return Err(SMPError::UnknownError(5, None)); + }; + array.push(element); + Ok(()) + } + /// This expands a macro definition, and it executes builtin functions, like define /// /// # Arguments |