summaryrefslogtreecommitdiff
path: root/src/func
diff options
context:
space:
mode:
Diffstat (limited to 'src/func')
-rw-r--r--src/func/args.rs10
-rw-r--r--src/func/macros.rs23
-rw-r--r--src/func/mod.rs5
3 files changed, 15 insertions, 23 deletions
diff --git a/src/func/args.rs b/src/func/args.rs
index 2e9e80cc..d1d49b6a 100644
--- a/src/func/args.rs
+++ b/src/func/args.rs
@@ -64,14 +64,14 @@ impl<'a> ArgParser<'a> {
if self.positional_index == self.args.positional.len() {
Ok(())
} else {
- pr!("unexpected argument");
+ error!(unexpected_argument);
}
}
/// Covert an option to a result with an error on `None`.
fn expected<T>(val: Option<Spanned<T::Output>>) -> ParseResult<Spanned<T::Output>>
where T: Argument<'a> {
- val.ok_or_else(|| pr!(@"expected {}", T::ERROR_MESSAGE))
+ val.ok_or_else(|| error!(@"expected {}", T::ERROR_MESSAGE))
}
}
@@ -93,10 +93,10 @@ macro_rules! arg {
const ERROR_MESSAGE: &'static str = $err;
fn from_expr(expr: &'a Spanned<Expression>) -> ParseResult<Spanned<Self::Output>> {
- #[allow(unreachable_patterns)]
+ #[allow(unreachable_code)]
match &expr.val {
$wanted => Ok(Spanned::new($converted, expr.span)),
- _ => pr!("expected {}", $err),
+ _ => error!("expected {}", $err),
}
}
}
@@ -179,7 +179,7 @@ impl AlignmentKey {
Right if horizontal => axes.right(),
Top if !horizontal => axes.top(),
Bottom if !horizontal => axes.bottom(),
- _ => lr!(
+ _ => error!(
"invalid alignment `{}` for {} axis",
format!("{:?}", self).to_lowercase(),
format!("{:?}", axis).to_lowercase()
diff --git a/src/func/macros.rs b/src/func/macros.rs
index 78cf1f56..0ffdc857 100644
--- a/src/func/macros.rs
+++ b/src/func/macros.rs
@@ -111,7 +111,7 @@ macro_rules! function {
macro_rules! parse {
(forbidden: $body:expr) => {
if $body.is_some() {
- pr!("unexpected body");
+ error!("unexpected body");
}
};
@@ -127,23 +127,16 @@ macro_rules! parse {
if let Some(body) = $body {
$crate::syntax::parse(body, $ctx)?
} else {
- pr!("expected body");
+ error!("expected body");
}
)
}
-/// Early-return with a formatted parsing error or yield
-/// an error expression without returning when prefixed with `@`.
+/// Early-return with a formatted typesetting error or construct an error
+/// expression without returning when prefixed with `@`.
#[macro_export]
-macro_rules! pr {
- (@$($tts:tt)*) => ($crate::syntax::ParseError::new(format!($($tts)*)));
- ($($tts:tt)*) => (return Err(pr!(@$($tts)*)););
-}
-
-/// Early-return with a formatted layouting error or yield
-/// an error expression without returning when prefixed with `@`.
-#[macro_export]
-macro_rules! lr {
- (@$($tts:tt)*) => ($crate::layout::LayoutError::new(format!($($tts)*)));
- ($($tts:tt)*) => (return Err(lr!(@$($tts)*)););
+macro_rules! error {
+ (@unexpected_argument) => (error!(@"unexpected argument"));
+ (@$($tts:tt)*) => ($crate::TypesetError::with_message(format!($($tts)*)));
+ ($($tts:tt)*) => (return Err(error!(@$($tts)*)););
}
diff --git a/src/func/mod.rs b/src/func/mod.rs
index b16eecb8..31e31592 100644
--- a/src/func/mod.rs
+++ b/src/func/mod.rs
@@ -16,7 +16,7 @@ pub mod prelude {
pub use super::args::*;
pub use super::{Scope, ParseFunc, LayoutFunc, Command, Commands};
pub use crate::syntax::{SyntaxTree, FuncHeader, FuncArgs, Expression, Spanned, Span};
- pub use crate::syntax::{parse, ParseContext, ParseError, ParseResult};
+ pub use crate::syntax::{parse, ParseContext, ParseResult};
pub use crate::size::{Size, Size2D, SizeBox};
pub use crate::style::{PageStyle, TextStyle};
pub use crate::layout::{
@@ -24,8 +24,7 @@ pub mod prelude {
LayoutContext, LayoutSpace, LayoutSpaces,
LayoutAxes, Axis, GenericAxisKind, SpecificAxisKind,
LayoutAlignment, Alignment,
- SpacingKind,
- LayoutError, LayoutResult,
+ SpacingKind, LayoutResult,
};
}