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:
2024-10-14 00:13:09 +02:00
parent 84cbcdd4fe
commit 3a3ae98aff
66 changed files with 2302 additions and 1164 deletions

20
orchid-host/src/macros.rs Normal file
View 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)
}