mirror of
https://github.com/gbdev/rgbds.git
synced 2026-05-08 10:59:36 +00:00
Small optimization to skipToLeadingKeyword
This commit is contained in:
+6
-1
@@ -2148,17 +2148,22 @@ finish: // Can't `break` out of a nested `for`-`switch`
|
|||||||
// valid at the start of their lines, which enables ignoring everything except
|
// valid at the start of their lines, which enables ignoring everything except
|
||||||
// the leading keyword in lines that have one (as well as line continuations).
|
// the leading keyword in lines that have one (as well as line continuations).
|
||||||
//
|
//
|
||||||
|
// The only keywords it needs to recognize are case-insensitive `IF`, `ELIF`,
|
||||||
|
// `ELSE`, `ENDC`, `REPT`, `FOR`, `ENDR`, and `ENDM` (not `MACRO`).
|
||||||
|
//
|
||||||
// Note that when these constructs are *evaluated*, they can perform expansions
|
// Note that when these constructs are *evaluated*, they can perform expansions
|
||||||
// (for macro args, interpolations, and macro invocations) which may produce
|
// (for macro args, interpolations, and macro invocations) which may produce
|
||||||
// tokens that would change how these constructs were captured or skipped, if
|
// tokens that would change how these constructs were captured or skipped, if
|
||||||
// they had been produced during the capture/skip non-evaluating phase.
|
// they had been produced during the capture/skip non-evaluating phase.
|
||||||
static Token skipToLeadingKeyword() {
|
static Token skipToLeadingKeyword() {
|
||||||
|
assume(lexerState->disableExpansions);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (lexerState->atLineStart) {
|
if (lexerState->atLineStart) {
|
||||||
lexerState->atLineStart = false;
|
lexerState->atLineStart = false;
|
||||||
if (int c = skipChars(isBlankSpace); c == EOF) {
|
if (int c = skipChars(isBlankSpace); c == EOF) {
|
||||||
return Token(T_(YYEOF));
|
return Token(T_(YYEOF));
|
||||||
} else if (startsIdentifier(c) && c != '.') {
|
} else if (isLetter(c)) {
|
||||||
shiftChar();
|
shiftChar();
|
||||||
std::string keyword(1, c);
|
std::string keyword(1, c);
|
||||||
for (c = peek(); continuesIdentifier(c) && c != '.'; c = nextChar()) {
|
for (c = peek(); continuesIdentifier(c) && c != '.'; c = nextChar()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user