Parse decimals as a unit

Fixes #257.
This commit is contained in:
Laurenz 2023-03-27 12:50:00 +02:00
parent 2bbd8040c8
commit 2c7f2c005a
3 changed files with 5 additions and 0 deletions

View File

@ -430,6 +430,10 @@ impl Lexer<'_> {
// Keep numbers and grapheme clusters together.
if c.is_numeric() {
self.s.eat_while(char::is_numeric);
let mut s = self.s;
if s.eat_if('.') && !s.eat_while(char::is_numeric).is_empty() {
self.s = s;
}
} else {
let len = self
.s

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -27,6 +27,7 @@ $ 1/2/3 = (1/2)/3 = 1/(2/3) $
---
// Test precedence.
$ a_1/b_2, 1/f(x), zeta(x)/2, "foo"[|x|]/2 \
1.2/3.7, 2.3^3.4 \
🏳️‍🌈[x]/2, f [x]/2, phi [x]/2, 🏳️‍🌈 [x]/2 \
+[x]/2, 1(x)/2, 2[x]/2 \
(a)b/2, b(a)[b]/2 $