From 78da2bdd5d77d1b8572e5e9da119bfa68127a3fa Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 21 Jan 2020 17:09:31 +0100 Subject: =?UTF-8?q?Decoupled=20function=20parser=20=F0=9F=94=97=20[WIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/library/maps/mod.rs | 8 ++++---- src/library/mod.rs | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/library') diff --git a/src/library/maps/mod.rs b/src/library/maps/mod.rs index a868ce6c..3538def7 100644 --- a/src/library/maps/mod.rs +++ b/src/library/maps/mod.rs @@ -21,8 +21,8 @@ macro_rules! key { impl ExpressionKind for $type { const NAME: &'static str = $name; - fn from_expr(expr: Spanned) -> ParseResult { - if let Expression::Ident(ident) = expr.v { + fn from_expr(expr: Spanned) -> ParseResult { + if let Expr::Ident(ident) = expr.v { Self::from_ident(&Spanned::new(ident, expr.span)) } else { error!("expected {}", Self::NAME); @@ -55,8 +55,8 @@ impl Into> for DefaultKey { impl ExpressionKind for DefaultKey where T: ExpressionKind { const NAME: &'static str = T::NAME; - fn from_expr(expr: Spanned) -> ParseResult> { - if let Expression::Ident(ident) = &expr.v { + fn from_expr(expr: Spanned) -> ParseResult> { + if let Expr::Ident(ident) = &expr.v { match ident.as_str() { "default" => return Ok(DefaultKey::None), _ => {}, diff --git a/src/library/mod.rs b/src/library/mod.rs index d91f1b35..8d16ccaf 100644 --- a/src/library/mod.rs +++ b/src/library/mod.rs @@ -63,8 +63,8 @@ function! { body: parse!(optional: body, ctx), list: { header.args.iter_pos().map(|arg| match arg.v { - Expression::Str(s) | - Expression::Ident(Ident(s)) => Ok(s.to_lowercase()), + Expr::Str(s) | + Expr::Ident(Ident(s)) => Ok(s.to_lowercase()), _ => error!("expected identifier or string"), }).collect::>>()? } @@ -117,8 +117,8 @@ function! { parse(header, body, ctx) { FontWeightFunc { body: parse!(optional: body, ctx), - weight: match header.args.get_pos::()? { - Expression::Number(weight) => { + weight: match header.args.get_pos::()? { + Expr::Number(weight) => { let weight = weight.round() as i16; FontWeight( if weight < 100 { 100 } @@ -126,7 +126,7 @@ function! { else { 900 } ) } - Expression::Ident(Ident(s)) => { + Expr::Ident(Ident(s)) => { match FontWeight::from_str(&s) { Some(weight) => weight, None => error!("invalid font weight: `{}`", s), @@ -263,7 +263,7 @@ function! { SpacingFunc { axis: AxisKey::Specific(axis), spacing: FSize::from_expr( - header.args.get_pos::>()? + header.args.get_pos::>()? )?, } } else { -- cgit v1.2.3