diff options
| author | Martin Haug <mhaug@live.de> | 2021-06-01 14:56:02 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-06-09 22:44:40 +0200 |
| commit | 73fa2eda2c23bd3baeb9e22b99eb0bfb183fc638 (patch) | |
| tree | de42d0b6807b862cc28db5197751d5c503663c3c /src/parse | |
| parent | 9983634cd59b75a5842a096cc5fbf6472e65b5cb (diff) | |
Introduce `fr`s
Diffstat (limited to 'src/parse')
| -rw-r--r-- | src/parse/mod.rs | 1 | ||||
| -rw-r--r-- | src/parse/tokens.rs | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 048bcb1c..3d4cc2ac 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -335,6 +335,7 @@ fn literal(p: &mut Parser) -> Option<Expr> { Token::Length(val, unit) => Expr::Length(span, val, unit), Token::Angle(val, unit) => Expr::Angle(span, val, unit), Token::Percent(p) => Expr::Percent(span, p), + Token::Fraction(p) => Expr::Fractional(span, p), Token::Color(color) => Expr::Color(span, color), Token::Str(token) => Expr::Str(span, { if !token.terminated { diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs index 74051801..9d3cbc9a 100644 --- a/src/parse/tokens.rs +++ b/src/parse/tokens.rs @@ -393,6 +393,7 @@ impl<'s> Tokens<'s> { // Otherwise parse into the fitting numeric type. let build = match suffix { "%" => Token::Percent, + "fr" => Token::Fraction, "pt" => |x| Token::Length(x, LengthUnit::Pt), "mm" => |x| Token::Length(x, LengthUnit::Mm), "cm" => |x| Token::Length(x, LengthUnit::Cm), @@ -880,6 +881,7 @@ mod tests { let suffixes = [ ("%", Percent as fn(f64) -> Token<'static>), + ("fr", Fraction as fn(f64) -> Token<'static>), ("mm", |x| Length(x, LengthUnit::Mm)), ("pt", |x| Length(x, LengthUnit::Pt)), ("cm", |x| Length(x, LengthUnit::Cm)), |
