Reuse isWhitespace and isNewline, also refactoring readAtFile

This commit is contained in:
Rangi42
2025-08-05 13:46:53 -04:00
parent 98c5c7f776
commit 504a45a4ed
5 changed files with 34 additions and 61 deletions

View File

@@ -60,14 +60,6 @@ void lexer_IncLineNo() {
++lexerStack.back().lineNo;
}
static bool isWhiteSpace(int c) {
return c == ' ' || c == '\t';
}
static bool isNewline(int c) {
return c == '\r' || c == '\n';
}
yy::parser::symbol_type yylex(); // Forward declaration for `yywrap`
static yy::parser::symbol_type yywrap() {
@@ -268,7 +260,7 @@ yy::parser::symbol_type yylex() {
int c = context.file.sbumpc();
// First, skip leading whitespace.
while (isWhiteSpace(c)) {
while (isWhitespace(c)) {
c = context.file.sbumpc();
}
// Then, skip a comment if applicable.