Skip to content

Commit

Permalink
A macro can only have " and add \`" for pragma comments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
caryr committed Sep 4, 2023
1 parent d938654 commit b12977d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ivlpp/lexor.lex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
6 changes: 3 additions & 3 deletions ivtest/ivltests/attrib_expr.v
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit b12977d

Please sign in to comment.