diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-10-24 19:10:03 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-10-24 19:10:03 +0200 |
| commit | b4be25e43b1ee9da924d13b7f2e8289f12bd2c3b (patch) | |
| tree | a21fbec7e6907993463d57b8c75758d2014cebeb /src/func | |
| parent | ecf0ff4d054f11c79ec0ddbbdf45f3dfcf9fc8d7 (diff) | |
Prettify peeking and rearrange syntax/parsing modules 🧶
Diffstat (limited to 'src/func')
| -rw-r--r-- | src/func/helpers.rs | 11 | ||||
| -rw-r--r-- | src/func/mod.rs | 8 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/func/helpers.rs b/src/func/helpers.rs index d562284f..ea0f6b2f 100644 --- a/src/func/helpers.rs +++ b/src/func/helpers.rs @@ -1,11 +1,14 @@ -use super::prelude::*; use std::iter::Peekable; use std::slice::Iter; +use super::prelude::*; /// Implement the function trait more concisely. #[macro_export] macro_rules! function { (data: $ident:ident, $($tts:tt)*) => { + #[allow(unused_imports)] + use $crate::func::prelude::*; + impl Function for $ident { function!(@parse $ident, $($tts)*); } @@ -64,7 +67,7 @@ macro_rules! parse { (optional: $body:expr, $ctx:expr) => { if let Some(body) = $body { - Some($crate::parsing::parse(body, $ctx)?) + Some($crate::syntax::parse(body, $ctx)?) } else { None } @@ -72,7 +75,7 @@ macro_rules! parse { (required: $body:expr, $ctx:expr) => { if let Some(body) = $body { - $crate::parsing::parse(body, $ctx)? + $crate::syntax::parse(body, $ctx)? } else { err!("expected body"); } @@ -83,7 +86,7 @@ macro_rules! parse { #[macro_export] macro_rules! err { ($($tts:tt)*) => { - return Err(ParseError::new(format!($($tts)*))); + return Err($crate::syntax::ParseError::new(format!($($tts)*))); }; } diff --git a/src/func/mod.rs b/src/func/mod.rs index 9a6fcbd1..b3918253 100644 --- a/src/func/mod.rs +++ b/src/func/mod.rs @@ -4,10 +4,7 @@ use std::any::Any; use std::collections::HashMap; use std::fmt::{self, Debug, Formatter}; -use crate::layout::{Layout, LayoutContext, Alignment, LayoutResult, MultiLayout}; -use crate::parsing::{ParseContext, ParseResult}; -use crate::style::TextStyle; -use crate::syntax::{FuncHeader, SyntaxTree}; +use self::prelude::*; #[macro_use] mod helpers; @@ -18,9 +15,10 @@ pub mod prelude { pub use crate::func::{Command, CommandList, Function}; pub use crate::layout::{layout_tree, Layout, LayoutContext, MultiLayout}; pub use crate::layout::{Flow, Alignment, LayoutError, LayoutResult}; - pub use crate::parsing::{parse, ParseContext, ParseError, ParseResult}; pub use crate::syntax::{Expression, FuncHeader, SyntaxTree}; + pub use crate::syntax::{parse, ParseContext, ParseError, ParseResult}; pub use crate::size::{Size, Size2D, SizeBox}; + pub use crate::style::{PageStyle, TextStyle}; pub use super::helpers::*; } |
