mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-07 04:06:48 +01:00
output: more big refactors
This commit is contained in:
parent
194f2f9874
commit
5e6338fad8
68 changed files with 1604 additions and 1016 deletions
|
|
@ -16,3 +16,31 @@ pub trait DslNs<'a, T: 'a>: DslNsWords<'a, T> + DslNsExprs<'a, T> {
|
|||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export] macro_rules! dsl_ns {
|
||||
($State:ty: $Type:ty {
|
||||
$(literal = |$dsl:ident| $literal:expr;)?
|
||||
$(word = |$state_w:ident| {
|
||||
$($word:literal => $body_w:expr),* $(,)?
|
||||
};)?
|
||||
$(expr = |$state_e:ident| {
|
||||
$($head:literal $args:tt => $body_e:expr),* $(,)?
|
||||
};)?
|
||||
}) => {
|
||||
impl<'a> DslNs<'a, $Type> for $State {
|
||||
$(fn from_literal (&self, $dsl: impl Dsl) -> Perhaps<$Type> {
|
||||
$literal
|
||||
})?
|
||||
}
|
||||
impl<'a> DslNsWords<'a, $Type> for $State {
|
||||
$(dsl_words! { 'a |$state_w| -> $Type {
|
||||
$($word => $body_w),*
|
||||
} })?
|
||||
}
|
||||
impl<'a> DslNsExprs<'a, $Type> for $State {
|
||||
$(dsl_exprs! { 'a |$state_e| -> $Type {
|
||||
$($head $args => $body_e),*
|
||||
} })?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue