From 0c85240b97af874a8245e2111e00effcdc6c3700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Tue, 20 Feb 2018 23:54:37 +0000 Subject: [PATCH] Allow line continuations in list of macro args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/asm/lexer.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/asm/lexer.c b/src/asm/lexer.c index cdb91c25..8696b140 100644 --- a/src/asm/lexer.c +++ b/src/asm/lexer.c @@ -775,6 +775,32 @@ static uint32_t yylex_MACROARGS(void) case '}': ch = '}'; 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: maxLength = MAXSTRLEN - index; length = CopyMacroArg(&yylval.tzString[index],