mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Allow line continuations in list of macro args
For example:
PrintMacro : MACRO
PRINTT \1
ENDM
PrintMacro STRCAT(\"Hello\"\, \
\" world\\n\")
It is possible to have spaces after the '\' and before the newline
character. This is needed because Windows line endings "\r\n" are
converted to " \n" before the lexer has a chance to handle them.
Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -775,6 +775,32 @@ static uint32_t yylex_MACROARGS(void)
|
|||||||
case '}':
|
case '}':
|
||||||
ch = '}';
|
ch = '}';
|
||||||
break;
|
break;
|
||||||
|
case ' ':
|
||||||
|
/*
|
||||||
|
* Look for line continuation character after a
|
||||||
|
* series of spaces. This is also useful for
|
||||||
|
* files that use Windows line endings: "\r\n"
|
||||||
|
* is replaced by " \n" before the lexer has the
|
||||||
|
* opportunity to see it.
|
||||||
|
*/
|
||||||
|
while (1) {
|
||||||
|
if (*pLexBuffer == ' ') {
|
||||||
|
pLexBuffer++;
|
||||||
|
} else if (*pLexBuffer == '\n') {
|
||||||
|
pLexBuffer++;
|
||||||
|
nLineNo += 1;
|
||||||
|
ch = 0;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
errx(1, "Expected a new line after the continuation character.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
/* Line continuation character */
|
||||||
|
nLineNo += 1;
|
||||||
|
ch = 0;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
maxLength = MAXSTRLEN - index;
|
maxLength = MAXSTRLEN - index;
|
||||||
length = CopyMacroArg(&yylval.tzString[index],
|
length = CopyMacroArg(&yylval.tzString[index],
|
||||||
|
|||||||
Reference in New Issue
Block a user