Began implementing fully isomorphic macros
Like Rust's Proc macros. Now we have preprocessor recursion to worry about. I also made a cool macro for enums
This commit is contained in:
20
orchid-host/src/macros.rs
Normal file
20
orchid-host/src/macros.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use std::sync::RwLock;
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use lazy_static::lazy_static;
|
||||
use orchid_base::macros::MTree;
|
||||
use trait_set::trait_set;
|
||||
use crate::api::ParsId;
|
||||
|
||||
trait_set!{
|
||||
trait MacroCB = Fn(Vec<MTree>) -> Option<Vec<MTree>> + Send + Sync;
|
||||
}
|
||||
|
||||
lazy_static!{
|
||||
static ref RECURSION: RwLock<HashMap<ParsId, Box<dyn MacroCB>>> = RwLock::default();
|
||||
}
|
||||
|
||||
pub fn macro_recur(run_id: ParsId, input: Vec<MTree>) -> Option<Vec<MTree>> {
|
||||
(RECURSION.read().unwrap()[&run_id])(input)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user