mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Simplify switch with one case to if
This commit is contained in:
@@ -2418,9 +2418,8 @@ Capture lexer_CaptureRept() {
|
|||||||
Defer reenableExpansions = scopedDisableExpansions();
|
Defer reenableExpansions = scopedDisableExpansions();
|
||||||
|
|
||||||
size_t depth = 0;
|
size_t depth = 0;
|
||||||
int c = EOF;
|
|
||||||
|
|
||||||
for (;;) {
|
for (int c;;) {
|
||||||
nextLine();
|
nextLine();
|
||||||
// We're at line start, so attempt to match a `REPT` or `ENDR` token
|
// We're at line start, so attempt to match a `REPT` or `ENDR` token
|
||||||
do { // Discard initial whitespace
|
do { // Discard initial whitespace
|
||||||
@@ -2471,27 +2470,19 @@ Capture lexer_CaptureMacro() {
|
|||||||
|
|
||||||
Defer reenableExpansions = scopedDisableExpansions();
|
Defer reenableExpansions = scopedDisableExpansions();
|
||||||
|
|
||||||
int c = EOF;
|
for (int c;;) {
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
nextLine();
|
nextLine();
|
||||||
// We're at line start, so attempt to match an `ENDM` token
|
// We're at line start, so attempt to match an `ENDM` token
|
||||||
do { // Discard initial whitespace
|
do { // Discard initial whitespace
|
||||||
c = nextChar();
|
c = nextChar();
|
||||||
} while (isWhitespace(c));
|
} while (isWhitespace(c));
|
||||||
// Now, try to match `ENDM` as a **whole** keyword
|
// Now, try to match `ENDM` as a **whole** keyword
|
||||||
if (startsIdentifier(c)) {
|
if (startsIdentifier(c) && readIdentifier(c, false).type == T_(POP_ENDM)) {
|
||||||
switch (readIdentifier(c, false).type) {
|
|
||||||
case T_(POP_ENDM):
|
|
||||||
endCapture(capture);
|
endCapture(capture);
|
||||||
// The ENDM has been captured, but we don't want it!
|
// The ENDM has been captured, but we don't want it!
|
||||||
// We know we have read exactly "ENDM", not e.g. an EQUS
|
// We know we have read exactly "ENDM", not e.g. an EQUS
|
||||||
capture.span.size -= literal_strlen("ENDM");
|
capture.span.size -= literal_strlen("ENDM");
|
||||||
return capture;
|
return capture;
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just consume characters until EOL or EOF
|
// Just consume characters until EOL or EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user