ref: 3e219dee369e24912cbe7de23997dbf91b28e3c7
parent: 6ad5bd232504801b1b6b911c918677a7aff2c698
author: Antonio Niño Díaz <antonio_nd@outlook.com>
date: Tue Feb 20 18:39:30 EST 2018
Allow to continuate lines except inside macros Lines can be continuated after a newline character ('\n'): DB 1, 2, 3, 4 \ 5, 6, 7, 8 This doesn't work for now in lists of arguments of macros. 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>
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -638,6 +638,44 @@
}
}
+ /* Check for line continuation character */
+ if (*pLexBuffer == '\\') {
+
+ /*
+ * 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.
+ */
+ if (pLexBuffer[1] == ' ') {
+ pLexBuffer += 2;
+ while (1) {
+ if (*pLexBuffer == ' ') {
+ pLexBuffer++;
+ } else if (*pLexBuffer == '\n') {
+ pLexBuffer++;
+ nLineNo += 1;
+ goto scanagain;
+ } else {
+ errx(1, "Expected a new line after the continuation character.");
+ }
+ }
+ }
+
+ /* Line continuation character */
+ if (pLexBuffer[1] == '\n') {
+ pLexBuffer += 2;
+ nLineNo += 1;
+ goto scanagain;
+ }
+
+ /*
+ * If there isn't a newline character or a space, ignore the
+ * character '\'. It will eventually be handled by other
+ * functions like PutMacroArg().
+ */
+ }
+
/*
* Try to match an identifier, macro argument (e.g. \1),
* or numeric literal.