mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
test top level expr parsing
This commit is contained in:
parent
d14d67172c
commit
9756862091
7 changed files with 129 additions and 82 deletions
|
|
@ -9,9 +9,12 @@ use crate::*;
|
|||
impl<'a> ViewContext<'a, $Output> for $State {
|
||||
fn get_content_custom (&'a $self, value: &Value<'a>) -> Option<RenderBox<'a, $Output>> {
|
||||
if let Value::Sym(s) = value {
|
||||
match *s { $($sym => Some($body),)* _ => None }
|
||||
match *s {
|
||||
$($sym => Some($body),)*
|
||||
_ => None
|
||||
}
|
||||
} else {
|
||||
panic!("expected symbol")
|
||||
panic!("expected content, got: {value:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -72,12 +75,10 @@ pub trait ViewContext<'a, E: Output + 'a>: Send + Sync
|
|||
}
|
||||
}
|
||||
#[macro_export] macro_rules! try_from_expr {
|
||||
(<$l:lifetime, $E:ident>: $Struct:ty: |$state:ident, $atoms:ident|$body:expr) => {
|
||||
(<$l:lifetime, $E:ident>: $Struct:ty: |$state:ident, $iter:ident|$body:expr) => {
|
||||
impl<$l, $E: Output + $l, T: ViewContext<$l, $E>> TryFromAtom<$l, T> for $Struct {
|
||||
fn try_from_atom ($state: &$l T, atom: Value<$l>) -> Option<Self> {
|
||||
if let Value::Exp(0, $atoms) = atom {
|
||||
$body;
|
||||
}
|
||||
fn try_from_expr ($state: &$l T, $iter: TokenIter<'a>) -> Option<Self> {
|
||||
$body;
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue