Factor out isBinDigit and parseHexDigit utility functions

This commit is contained in:
Rangi42
2025-09-04 13:14:27 -04:00
parent 891e6f98df
commit 1dfc1d3231
5 changed files with 32 additions and 48 deletions

View File

@@ -108,7 +108,7 @@ static yy::parser::symbol_type parseDecNumber(int c) {
}
static bool isBinDigit(int c) {
return c >= '0' && c <= '1';
return c == '0' || c == '1';
}
static yy::parser::symbol_type parseBinNumber(char const *prefix) {
@@ -149,18 +149,6 @@ static yy::parser::symbol_type parseOctNumber(char const *prefix) {
return yy::parser::make_number(number);
}
static uint8_t parseHexDigit(int c) {
if (isDigit(c)) {
return c - '0';
} else if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
} else if (c >= 'a' && c <= 'f') {
return c - 'a' + 10;
} else {
unreachable_(); // LCOV_EXCL_LINE
}
}
static yy::parser::symbol_type parseHexNumber(char const *prefix) {
LexerStackEntry &context = lexerStack.back();
int c = context.file.sgetc();