feat: allow underscores in integers

This commit is contained in:
Roman Godmaire 2024-05-04 19:33:39 -04:00
parent 527737f020
commit 936f557536
2 changed files with 6 additions and 0 deletions

View file

@ -87,6 +87,7 @@ mod test {
#[rstest] #[rstest]
// Raw values // Raw values
#[case("1", "1")] #[case("1", "1")]
#[case("1_000", "1000")]
#[case("\"uwu\"", "uwu")] #[case("\"uwu\"", "uwu")]
#[case(":owo", ":owo")] #[case(":owo", ":owo")]
#[case("()", "()")] #[case("()", "()")]

View file

@ -173,6 +173,11 @@ fn read_int(input: &mut Peekable<Chars>, first: char) -> Token {
let mut raw_int = vec![first]; let mut raw_int = vec![first];
while let Some(c) = input.peek() { while let Some(c) = input.peek() {
if *c == '_' {
input.next();
continue;
}
if !c.is_ascii_digit() { if !c.is_ascii_digit() {
break; break;
} }