mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Reduce nesting depth in some functions (#1739)
This commit is contained in:
@@ -2287,10 +2287,28 @@ static Token skipIfBlock(bool toEndc) {
|
||||
|
||||
Defer reenableExpansions = scopedDisableExpansions();
|
||||
|
||||
for (;;) {
|
||||
if (atLineStart) {
|
||||
int c;
|
||||
for (int c;; atLineStart = false) {
|
||||
// Read chars until EOL
|
||||
while (!atLineStart) {
|
||||
c = nextChar();
|
||||
|
||||
if (c == EOF) {
|
||||
return Token(T_(YYEOF));
|
||||
} else if (c == '\\') {
|
||||
// Unconditionally skip the next char, including line continuations
|
||||
c = nextChar();
|
||||
} else if (c == '\r' || c == '\n') {
|
||||
atLineStart = true;
|
||||
}
|
||||
|
||||
if (c == '\r' || c == '\n') {
|
||||
handleCRLF(c);
|
||||
// Do this both on line continuations and plain EOLs
|
||||
nextLine();
|
||||
}
|
||||
}
|
||||
|
||||
// Skip leading whitespace
|
||||
for (;; shiftChar()) {
|
||||
c = peek();
|
||||
if (!isWhitespace(c)) {
|
||||
@@ -2298,7 +2316,9 @@ static Token skipIfBlock(bool toEndc) {
|
||||
}
|
||||
}
|
||||
|
||||
if (startsIdentifier(c)) {
|
||||
if (!startsIdentifier(c)) {
|
||||
continue;
|
||||
}
|
||||
shiftChar();
|
||||
switch (Token token = readIdentifier(c, false); token.type) {
|
||||
case T_(POP_IF):
|
||||
@@ -2336,29 +2356,6 @@ static Token skipIfBlock(bool toEndc) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
atLineStart = false;
|
||||
}
|
||||
|
||||
// Read chars until EOL
|
||||
do {
|
||||
int c = nextChar();
|
||||
|
||||
if (c == EOF) {
|
||||
return Token(T_(YYEOF));
|
||||
} else if (c == '\\') {
|
||||
// Unconditionally skip the next char, including line continuations
|
||||
c = nextChar();
|
||||
} else if (c == '\r' || c == '\n') {
|
||||
atLineStart = true;
|
||||
}
|
||||
|
||||
if (c == '\r' || c == '\n') {
|
||||
handleCRLF(c);
|
||||
// Do this both on line continuations and plain EOLs
|
||||
nextLine();
|
||||
}
|
||||
} while (!atLineStart);
|
||||
}
|
||||
}
|
||||
|
||||
static Token yylex_SKIP_TO_ELIF() {
|
||||
@@ -2378,10 +2375,28 @@ static Token yylex_SKIP_TO_ENDR() {
|
||||
|
||||
Defer reenableExpansions = scopedDisableExpansions();
|
||||
|
||||
for (;;) {
|
||||
if (atLineStart) {
|
||||
int c;
|
||||
for (int c;; atLineStart = false) {
|
||||
// Read chars until EOL
|
||||
while (!atLineStart) {
|
||||
c = nextChar();
|
||||
|
||||
if (c == EOF) {
|
||||
return Token(T_(YYEOF));
|
||||
} else if (c == '\\') {
|
||||
// Unconditionally skip the next char, including line continuations
|
||||
c = nextChar();
|
||||
} else if (c == '\r' || c == '\n') {
|
||||
atLineStart = true;
|
||||
}
|
||||
|
||||
if (c == '\r' || c == '\n') {
|
||||
handleCRLF(c);
|
||||
// Do this both on line continuations and plain EOLs
|
||||
nextLine();
|
||||
}
|
||||
}
|
||||
|
||||
// Skip whitespace
|
||||
for (;;) {
|
||||
c = peek();
|
||||
if (!isWhitespace(c)) {
|
||||
@@ -2390,7 +2405,9 @@ static Token yylex_SKIP_TO_ENDR() {
|
||||
shiftChar();
|
||||
}
|
||||
|
||||
if (startsIdentifier(c)) {
|
||||
if (!startsIdentifier(c)) {
|
||||
continue;
|
||||
}
|
||||
shiftChar();
|
||||
switch (readIdentifier(c, false).type) {
|
||||
case T_(POP_FOR):
|
||||
@@ -2416,29 +2433,6 @@ static Token yylex_SKIP_TO_ENDR() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
atLineStart = false;
|
||||
}
|
||||
|
||||
// Read chars until EOL
|
||||
do {
|
||||
int c = nextChar();
|
||||
|
||||
if (c == EOF) {
|
||||
return Token(T_(YYEOF));
|
||||
} else if (c == '\\') {
|
||||
// Unconditionally skip the next char, including line continuations
|
||||
c = nextChar();
|
||||
} else if (c == '\r' || c == '\n') {
|
||||
atLineStart = true;
|
||||
}
|
||||
|
||||
if (c == '\r' || c == '\n') {
|
||||
handleCRLF(c);
|
||||
// Do this both on line continuations and plain EOLs
|
||||
nextLine();
|
||||
}
|
||||
} while (!atLineStart);
|
||||
}
|
||||
}
|
||||
|
||||
yy::parser::symbol_type yylex() {
|
||||
|
||||
Reference in New Issue
Block a user