summaryrefslogtreecommitdiff
path: root/src/parse
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-01-10 18:22:06 +0100
committerLaurenz <laurmaedje@gmail.com>2021-01-10 18:22:06 +0100
commit515905d78db67005cdea1bec9e63e3a7172ce493 (patch)
tree6e16659701148194a0c3a875a664cc17900e1b7a /src/parse
parent9eac62c31a0f75c224cf4d6926e505cf02eafcde (diff)
Add angle value 📐
Diffstat (limited to 'src/parse')
-rw-r--r--src/parse/mod.rs1
-rw-r--r--src/parse/tests.rs6
2 files changed, 5 insertions, 2 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index c03cb63d..4bf6f925 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -331,6 +331,7 @@ fn value(p: &mut Parser) -> Option<Expr> {
Some(Token::Int(i)) => Expr::Int(i),
Some(Token::Float(f)) => Expr::Float(f),
Some(Token::Length(val, unit)) => Expr::Length(val, unit),
+ Some(Token::Angle(val, unit)) => Expr::Angle(val, unit),
Some(Token::Percent(p)) => Expr::Percent(p),
Some(Token::Hex(hex)) => Expr::Color(color(p, hex)),
Some(Token::Str(token)) => Expr::Str(str(p, token)),
diff --git a/src/parse/tests.rs b/src/parse/tests.rs
index fd8c63ca..ca09f454 100644
--- a/src/parse/tests.rs
+++ b/src/parse/tests.rs
@@ -5,11 +5,11 @@ use std::fmt::Debug;
use super::parse;
use crate::color::RgbaColor;
use crate::diag::{Diag, Level, Pass};
-use crate::geom::LengthUnit;
+use crate::geom::{AngularUnit, LengthUnit};
use crate::syntax::*;
use BinOp::*;
-use Expr::{Bool, Color, Float, Int, Length, Percent};
+use Expr::{Angle, Bool, Color, Float, Int, Length, Percent};
use Node::{Emph, Expr as Block, Linebreak, Parbreak, Space, Strong};
use UnOp::*;
@@ -601,6 +601,8 @@ fn test_parse_values() {
t!("{50%}" Block(Percent(50.0)));
t!("{4.5cm}" Block(Length(4.5, LengthUnit::Cm)));
t!("{12e1pt}" Block(Length(12e1, LengthUnit::Pt)));
+ t!("{13rad}" Block(Angle(13.0, AngularUnit::Rad)));
+ t!("{45deg}" Block(Angle(45.0, AngularUnit::Deg)));
// Strings.
t!(r#"{"hi"}"# Block(Str("hi")));