diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-01-14 20:17:50 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-01-14 20:17:50 +0100 |
| commit | 15ad30555bdad8e7b192fdcf7d4543c0d3fb18ce (patch) | |
| tree | 814a1863e6a50d433613e5b362d30ede2df0bb21 /src/func/macros.rs | |
| parent | dde69276d47818174c35523c8ed86b6888b6d02b (diff) | |
Parser testing prototype 🥥
Diffstat (limited to 'src/func/macros.rs')
| -rw-r--r-- | src/func/macros.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/func/macros.rs b/src/func/macros.rs index 9e931ea2..1083e53c 100644 --- a/src/func/macros.rs +++ b/src/func/macros.rs @@ -75,6 +75,8 @@ macro_rules! function { parse($args:ident, $body:pat, $ctx:pat, $metadata:pat) $code:block $($rest:tt)* ) => { + use $crate::func::prelude::*; + impl $crate::func::ParseFunc for $type { type Meta = $meta; @@ -88,7 +90,8 @@ macro_rules! function { let mut $args = args; let val = $code; if !$args.is_empty() { - error!(unexpected_argument); + return Err($crate::TypesetError + ::with_message("unexpected arguments")); } Ok(val) } @@ -109,6 +112,8 @@ macro_rules! function { // (2-arg) Parse a layout-definition with all arguments. (@layout $type:ident | layout($this:ident, $ctx:pat) $code:block) => { + use $crate::func::prelude::*; + impl LayoutFunc for $type { fn layout<'a, 'life0, 'life1, 'async_trait>( &'a $this, @@ -138,13 +143,13 @@ macro_rules! function { macro_rules! parse { (forbidden: $body:expr) => { if $body.is_some() { - error!("unexpected body"); + return Err($crate::TypesetError::with_message("unexpected body")); } }; (optional: $body:expr, $ctx:expr) => ( if let Some(body) = $body { - Some($crate::syntax::parse(body, $ctx)) + Some($crate::syntax::parse(body, $ctx).0) } else { None } @@ -152,9 +157,9 @@ macro_rules! parse { (expected: $body:expr, $ctx:expr) => ( if let Some(body) = $body { - $crate::syntax::parse(body, $ctx)? + $crate::syntax::parse(body, $ctx).0 } else { - error!("expected body"); + Err($crate::TypesetError::with_message("unexpected body")) } ) } |
