From b4be25e43b1ee9da924d13b7f2e8289f12bd2c3b Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 24 Oct 2019 19:10:03 +0200 Subject: =?UTF-8?q?Prettify=20peeking=20and=20rearrange=20syntax/parsing?= =?UTF-8?q?=20modules=20=F0=9F=A7=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/func/helpers.rs | 11 +++++++---- src/func/mod.rs | 8 +++----- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/func') 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::*; } -- cgit v1.2.3