mirror of
https://github.com/gbdev/rgbds.git
synced 2026-05-08 19:09:36 +00:00
Fix some fixed-point literal lexing issues (#1914)
- No fractional digits are necessary after the decimal point, e.g. `42.` is valid instead of `42.0` - Error messages refer to "fixed-point" not "integer" constants - Test more carefully for lexing unrelated to underscores
This commit is contained in:
+8
-2
@@ -958,12 +958,17 @@ static uint32_t readFractionalPart(uint32_t integer) {
|
||||
READFRACTIONALPART_PRECISION,
|
||||
READFRACTIONALPART_PRECISION_DIGITS,
|
||||
} state = READFRACTIONALPART_DIGITS;
|
||||
bool nonDigit = true;
|
||||
bool anyDigit = false;
|
||||
bool nonDigit = false;
|
||||
|
||||
for (int c = peek();; c = nextChar()) {
|
||||
if (state == READFRACTIONALPART_DIGITS) {
|
||||
if (c == '_') {
|
||||
checkDigitSeparator(nonDigit);
|
||||
if (nonDigit) {
|
||||
error("Invalid fixed-point constant, '_' after another '_'");
|
||||
} else if (!anyDigit) {
|
||||
error("Invalid fixed-point constant, '_' after '.'");
|
||||
}
|
||||
nonDigit = true;
|
||||
continue;
|
||||
}
|
||||
@@ -976,6 +981,7 @@ static uint32_t readFractionalPart(uint32_t integer) {
|
||||
break;
|
||||
}
|
||||
c -= '0';
|
||||
anyDigit = true;
|
||||
nonDigit = false;
|
||||
|
||||
if (divisor > (UINT32_MAX - c) / 10) {
|
||||
|
||||
Reference in New Issue
Block a user