diff --git a/trunk_lexer/src/lexer.rs b/trunk_lexer/src/lexer.rs index 139a8a1..a4bf8c7 100644 --- a/trunk_lexer/src/lexer.rs +++ b/trunk_lexer/src/lexer.rs @@ -956,7 +956,9 @@ impl Lexer { // Remaining cases: decimal integer, legacy octal integer, or float. let is_float = match self.peek_buf() { - [b'.', ..] | [b'e' | b'E', b'0'..=b'9', ..] => true, + [b'.', ..] + | [b'e' | b'E', b'-' | b'+', b'0'..=b'9', ..] + | [b'e' | b'E', b'0'..=b'9', ..] => true, _ => false, }; if !is_float { @@ -977,6 +979,10 @@ impl Lexer { if let Some(b'e' | b'E') = self.current { buffer.push('e'); self.next(); + if let Some(b @ (b'-' | b'+')) = self.current { + buffer.push(b as char); + self.next(); + } self.read_digits(&mut buffer, 10); } @@ -1640,21 +1646,29 @@ function hello_world() { #[test] fn floats() { assert_tokens( - " self.statement()? + _ => self.statement()?, }; self.clear_comments();