Implement 0x/0o/0b number prefixes (#1533)

This commit is contained in:
Sylvie
2024-10-08 15:56:00 -04:00
committed by GitHub
parent cf85146353
commit a13723c523
3 changed files with 41 additions and 7 deletions

View File

@@ -1733,7 +1733,25 @@ static Token yylex_NORMAL() {
// Handle numbers
case '0': // Decimal or fixed-point number
case '0': // Decimal, fixed-point, or base-prefix number
switch (peek()) {
case 'x':
case 'X':
shiftChar();
return Token(T_(NUMBER), readHexNumber());
case 'o':
case 'O':
shiftChar();
return Token(T_(NUMBER), readNumber(8, 0));
case 'b':
case 'B':
shiftChar();
return Token(T_(NUMBER), readBinaryNumber());
}
[[fallthrough]];
// Decimal or fixed-point number
case '1':
case '2':
case '3':