From 0eed237517f8dda6f931653ab1272f6c31355116 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Sun, 20 Jul 2025 11:21:44 -0400 Subject: [PATCH] Refactor peeking at macro args to be like peeking at interpolations --- src/asm/lexer.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index fe2cd6e8..12d5d291 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -816,22 +816,12 @@ static int peek() { return c; } + // If character is a macro arg char, do macro arg expansion shiftChar(); - - std::shared_ptr str = readMacroArg(); - // 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 + if (std::shared_ptr str = readMacroArg(); str) { + beginExpansion(str, std::nullopt); } - - 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(); + return peek(); // Tail recursion } else if (c == '{' && !lexerState->disableInterpolation) { // If character is an open brace, do symbol interpolation shiftChar();