mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
0.9.0: add get_value! and get_content! macros for dsl impl
This commit is contained in:
parent
1ad2d43d5a
commit
f11c27b8c9
3 changed files with 28 additions and 33 deletions
|
|
@ -67,6 +67,26 @@ pub(crate) use std::fmt::Debug;
|
|||
};
|
||||
}
|
||||
|
||||
#[macro_export] macro_rules! get_value {
|
||||
($state:expr => $token:expr) => {
|
||||
if let Some(value) = $state.get(&$token.value) {
|
||||
value
|
||||
} else {
|
||||
panic!("no value corresponding to for {:?}", &$token.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export] macro_rules! get_content {
|
||||
($state:expr => $token:expr) => {
|
||||
if let Some(content) = $state.get_content(&$token.value) {
|
||||
content
|
||||
} else {
|
||||
panic!("no content corresponding to for {:?}", &$token.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#[cfg(test)] #[test] fn test_examples () -> Result<(), ParseError> {
|
||||
//// Let's pretend to render some view.
|
||||
//let source = include_str!("../../tek/src/view_arranger.edn");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue