diff options
| author | Tolmachev Igor <me@igorek.dev> | 2026-05-09 15:25:49 +0300 |
|---|---|---|
| committer | Tolmachev Igor <me@igorek.dev> | 2026-05-09 15:38:35 +0300 |
| commit | 60ad7b994c2126346c19769a1a5f5c8f679a05ee (patch) | |
| tree | 702b5dad7b34d1ca81fd9918345f648c26d088a2 /compiler/src/lexer/mod.rs | |
| parent | f898f3c3a17a7c71236cafff34f507b10d71f835 (diff) | |
| download | crisp-60ad7b994c2126346c19769a1a5f5c8f679a05ee.tar.gz crisp-60ad7b994c2126346c19769a1a5f5c8f679a05ee.zip | |
Fix lexer processing [+-].\d as symbol instead of number
Extended lookahead in the number branch to 3 chars.
Added tests for "-.5", "+.5", "-.0" in test_numbers and for
"-.", "+.", ".", "+.a", "-.a" in test_ambiguous.
Diffstat (limited to 'compiler/src/lexer/mod.rs')
| -rw-r--r-- | compiler/src/lexer/mod.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/src/lexer/mod.rs b/compiler/src/lexer/mod.rs index 464d88e..f3c8b76 100644 --- a/compiler/src/lexer/mod.rs +++ b/compiler/src/lexer/mod.rs | |||
| @@ -146,8 +146,12 @@ impl<'a> Iterator for Lexer<'a> { | |||
| 146 | 146 | ||
| 147 | // Number | 147 | // Number |
| 148 | ch if ch.is_ascii_digit() | 148 | ch if ch.is_ascii_digit() |
| 149 | || matches!(ch, '+' | '-' | '.') | 149 | || ch == '.' && self.peek_nth(1).is_some_and(|ch| ch.is_ascii_digit()) |
| 150 | && self.peek_nth(1).is_some_and(|ch| ch.is_ascii_digit()) => | 150 | || matches!(ch, '+' | '-') |
| 151 | && self.peek_nth(1).is_some_and(|ch| ch.is_ascii_digit()) | ||
| 152 | || matches!(ch, '+' | '-') | ||
| 153 | && self.peek_nth(1).is_some_and(|ch| ch == '.') | ||
| 154 | && self.peek_nth(2).is_some_and(|ch| ch.is_ascii_digit()) => | ||
| 151 | { | 155 | { |
| 152 | Token::Number(self.next_atom()) | 156 | Token::Number(self.next_atom()) |
| 153 | } | 157 | } |
