A macro can only have `" and add `\`" for pragma comments

We want to support `" and `\`" when a pragma comment is part of a macro
definition, but this cannot be part of a normal pragma comment.
This commit is contained in:
Cary R 2023-09-03 21:30:45 -07:00
parent d938654c36
commit b12977d61a
2 changed files with 5 additions and 4 deletions

View File

@ -268,7 +268,8 @@ keywords (line|include|define|undef|ifdef|ifndef|else|elsif|endif)
<PCOMENT>`[a-zA-Z][a-zA-Z0-9_$]* {
if (macro_needs_args(yytext+1)) yy_push_state(MA_START); else do_expand(0);
}
<PCOMENT>`\" { fputc('\"', yyout); }
<PCOMENT>`\" { if (!istack->file) fputc('"', yyout); else REJECT; }
<PCOMENT>`\\`\" { if (!istack->file) fputs("\\\"", yyout); else REJECT; }
/* Strings do not contain preprocessor directives or macro expansions.
*/

View File

@ -74,9 +74,9 @@ endfunction
(* attr = fn(10) *) reg attr46;
// Macro escaped
`define A_MACRO(arg) (* attr = `"arg`" *)
`A_MACRO(test) reg attr47;
// Macro escape only in a macro declaration
`define MACRO(arg) (* attr = `"`\`"arg`\`"`" *)
`MACRO(test) reg attr47;
initial begin
$display("PASSED");