summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-01-21 17:09:31 +0100
committerLaurenz <laurmaedje@gmail.com>2020-01-21 17:09:31 +0100
commit78da2bdd5d77d1b8572e5e9da119bfa68127a3fa (patch)
tree020c8c39268690d34226eb7e33e75f86304988d6 /src/library
parent1c1c994c46f7dc30ee34dbc99b02f2342c4617f3 (diff)
Decoupled function parser 🔗 [WIP]
Diffstat (limited to 'src/library')
-rw-r--r--src/library/maps/mod.rs8
-rw-r--r--src/library/mod.rs12
2 files changed, 10 insertions, 10 deletions
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<Expression>) -> ParseResult<Self> {
- if let Expression::Ident(ident) = expr.v {
+ fn from_expr(expr: Spanned<Expr>) -> ParseResult<Self> {
+ 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<T> Into<Option<T>> for DefaultKey<T> {
impl<T> ExpressionKind for DefaultKey<T> where T: ExpressionKind {
const NAME: &'static str = T::NAME;
- fn from_expr(expr: Spanned<Expression>) -> ParseResult<DefaultKey<T>> {
- if let Expression::Ident(ident) = &expr.v {
+ fn from_expr(expr: Spanned<Expr>) -> ParseResult<DefaultKey<T>> {
+ 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::<LayoutResult<Vec<_>>>()?
}
@@ -117,8 +117,8 @@ function! {
parse(header, body, ctx) {
FontWeightFunc {
body: parse!(optional: body, ctx),
- weight: match header.args.get_pos::<Expression>()? {
- Expression::Number(weight) => {
+ weight: match header.args.get_pos::<Expr>()? {
+ 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::<Spanned<Expression>>()?
+ header.args.get_pos::<Spanned<Expr>>()?
)?,
}
} else {