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 | fce39a1c9a44d4a7eb2234f5d15b86d1c3177ffa (patch) | |
tree | 8582ef41441a007fb5d59d71b6d8ed60b2696853 /src/macro_processor | |
parent | f8df856d45acb619ebc7766b17bded03bac8d851 (diff) | |
download | skaldpress-fce39a1c9a44d4a7eb2234f5d15b86d1c3177ffa.tar.gz skaldpress-fce39a1c9a44d4a7eb2234f5d15b86d1c3177ffa.zip |
Do a bunch of QOL things, add some skaldpress specific macros, add
second run, etc
Diffstat (limited to 'src/macro_processor')
-rw-r--r-- | src/macro_processor/error.rs | 8 | ||||
-rw-r--r-- | src/macro_processor/macro_processor.rs | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/macro_processor/error.rs b/src/macro_processor/error.rs index 074a8ef..cd94c4d 100644 --- a/src/macro_processor/error.rs +++ b/src/macro_processor/error.rs @@ -5,6 +5,7 @@ use std::fmt; pub enum SMPError { IncludeError(u8, std::io::Error, String), ShellCommandError(u8, Box<dyn Error>), + UnknownError(u8, Option<Box<dyn Error>>), } impl fmt::Display for SMPError { @@ -16,6 +17,13 @@ impl fmt::Display for SMPError { SMPError::ShellCommandError(code, e) => { write!(f, "[SMP{}] Error running shell command \"{:#?}\"", code, e) } + SMPError::UnknownError(code, e) => { + write!( + f, + "[SMP{}] Unknown macro processing error occurred \"{:#?}\"", + code, e + ) + } } } } diff --git a/src/macro_processor/macro_processor.rs b/src/macro_processor/macro_processor.rs index 82a94ef..68347d0 100644 --- a/src/macro_processor/macro_processor.rs +++ b/src/macro_processor/macro_processor.rs @@ -193,6 +193,7 @@ fn smp_builtin_expr( } /// Types of macros, this is to make it easy to store both functions and strings +#[derive(Clone)] pub enum MacroType { /// When expanded, the associated function will be expanded Function( @@ -217,9 +218,10 @@ enum ParserState { /// Defines a MacroProcessor object, with it's associated state /// the state mostly includes the defined macros +#[derive(Clone)] pub struct MacroProcessor { /// All currently defined macros in this MacroProcessor - macros: HashMap<String, MacroType>, + pub macros: HashMap<String, MacroType>, } impl MacroProcessor { |