mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 17:05:36 +01:00
fix number parser
the added test case was failing
This commit is contained in:
@@ -140,12 +140,13 @@ impl<'a> Lexer<'a> {
|
||||
self.eat_while(|b| b.is_some() && b.unwrap().is_ascii_digit());
|
||||
match self.peek() {
|
||||
Some(b'_') => {
|
||||
self.eat_and_assert(|b| b == b'_');
|
||||
|
||||
if start == self.offset {
|
||||
// before the underscore, there was no digit
|
||||
return Err(Error::BadNumber((start, self.offset - start).into()));
|
||||
}
|
||||
|
||||
self.eat_and_assert(|b| b == b'_');
|
||||
match self.peek() {
|
||||
Some(b) if b.is_ascii_digit() => continue, // Continue if next is a digit
|
||||
_ => {
|
||||
@@ -953,6 +954,13 @@ mod tests {
|
||||
token_type: Some(TokenType::TK_INTEGER),
|
||||
},
|
||||
),
|
||||
(
|
||||
b"9_223_372_036_854_775_807".as_slice(),
|
||||
Token {
|
||||
value: b"9_223_372_036_854_775_807".as_slice(),
|
||||
token_type: Some(TokenType::TK_INTEGER),
|
||||
},
|
||||
),
|
||||
(
|
||||
b"123.456".as_slice(),
|
||||
Token {
|
||||
|
||||
Reference in New Issue
Block a user