mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Refactor peeking at macro args to be like peeking at interpolations
This commit is contained in:
@@ -816,22 +816,12 @@ static int peek() {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If character is a macro arg char, do macro arg expansion
|
||||||
shiftChar();
|
shiftChar();
|
||||||
|
if (std::shared_ptr<std::string> str = readMacroArg(); str) {
|
||||||
std::shared_ptr<std::string> str = readMacroArg();
|
beginExpansion(str, std::nullopt);
|
||||||
// If the macro arg is invalid or an empty string, it cannot be expanded,
|
|
||||||
// so skip it and keep peeking.
|
|
||||||
if (!str || str->empty()) {
|
|
||||||
return peek(); // Tail recursion
|
|
||||||
}
|
}
|
||||||
|
return peek(); // Tail recursion
|
||||||
beginExpansion(str, std::nullopt);
|
|
||||||
|
|
||||||
// Assuming macro args can't be recursive (I'll be damned if a way
|
|
||||||
// is found...), then we mark the entire macro arg as scanned.
|
|
||||||
lexerState->macroArgScanDistance += str->length();
|
|
||||||
|
|
||||||
return str->front();
|
|
||||||
} else if (c == '{' && !lexerState->disableInterpolation) {
|
} else if (c == '{' && !lexerState->disableInterpolation) {
|
||||||
// If character is an open brace, do symbol interpolation
|
// If character is an open brace, do symbol interpolation
|
||||||
shiftChar();
|
shiftChar();
|
||||||
|
|||||||
Reference in New Issue
Block a user