diff --git a/src/asm/lexer.c b/src/asm/lexer.c index 7f9f48a6..9bd4a5bd 100644 --- a/src/asm/lexer.c +++ b/src/asm/lexer.c @@ -903,7 +903,7 @@ restart: char const *str = readMacroArg(c); /* - * If the argument is an empty string, it cannot be + * If the macro arg is an empty string, it cannot be * expanded, so skip it and keep peeking. */ if (!str[0]) { @@ -2164,6 +2164,16 @@ static int yylex_RAW(void) dbgPrint("Read raw string \"%s\"\n", yylval.tzString); return T_STRING; + case '/': /* Block comments inside macro args */ + shiftChars(1); /* Shift the slash */ + if (peek(0) == '*') { + shiftChars(1); + discardBlockComment(); + continue; + } + append_yylval_tzString(c); /* Append the slash */ + break; + case '\\': /* Character escape */ shiftChars(1); /* Shift the backslash */ c = peek(0); diff --git a/test/asm/macro-arguments.asm b/test/asm/macro-arguments.asm new file mode 100644 index 00000000..9ca1f946 --- /dev/null +++ b/test/asm/macro-arguments.asm @@ -0,0 +1,16 @@ +mac: MACRO + println "'mac \#':" + for i, _NARG + println strfmt("\\%d: <\1>", i+1) + shift + endr + println +ENDM + + mac /* block + ...comment */ ; comment + mac /*a*/ 1 , 2 /*b*/ + mac \ + c, d + mac 1, 2 + /* another ; + ; comment */ 2, 3 diff --git a/test/asm/macro-arguments.err b/test/asm/macro-arguments.err new file mode 100644 index 00000000..e69de29b diff --git a/test/asm/macro-arguments.out b/test/asm/macro-arguments.out new file mode 100644 index 00000000..e25d20c3 --- /dev/null +++ b/test/asm/macro-arguments.out @@ -0,0 +1,15 @@ +'mac ': + +'mac 1,2': +\1: < 1> +\2: <2> + +'mac c,d': +\1: < c> +\2: + +'mac 1,2 + 2,3': +\1: <1> +\2: <2 + 2> +\3: <3> +