`__FILE__ now expands to a string, per draft SystemVerilog 2010(ish).

This commit is contained in:
Wilson Snyder 2009-05-19 07:15:13 -04:00
parent f9484a894f
commit 663f3592ba
5 changed files with 12 additions and 5 deletions

View File

@ -7,8 +7,10 @@ indicates the contributor was also the author of the fix; Thanks!
** Verilator is now licensed under LGPL v3 and/or Artistic v2.0.
*** `__FILE__ now expands to a string, per draft SystemVerilog 2010(ish).
**** The front end parser has been re-factored to enable more SV parsing.
Code should parse the same, but minor parsing bugs may pop up now.
Code should parse the same, but minor parsing bugs may pop up.
**** Verilator_includer is no longer installed twice, bug48. [Lane Brooks]

View File

@ -91,8 +91,10 @@ psl [p]sl
/* Optional directives we recognize */
<INITIAL>"`__FILE__" { if (!pedantic()) {
yytext = (char*)V3PreLex::s_currentLexp->m_curFilelinep->cfilename();
yyleng = strlen(yytext); return (VP_TEXT);
static string rtnfile;
rtnfile = '"'; rtnfile += V3PreLex::s_currentLexp->m_curFilelinep->cfilename();
rtnfile += '"'; yytext=(char*)rtnfile.c_str(); yyleng = rtnfile.length();
return (VP_STRING);
} else return(VP_DEFREF); }
<INITIAL>"`__LINE__" { if (!pedantic()) {
static char buf[10];

View File

@ -25,6 +25,7 @@ na: "nana"
left side: "right side"
left side : "right side "
twoline: "first second"
Line 38 File "t/t_pp_display.v"
*-* All Finished *-*
'));

View File

@ -35,6 +35,8 @@ module t;
second
$display(`msg(twoline, `twoline));
$display("Line %0d File \"%s\"",`__LINE__,`__FILE__);
//$display(`msg(left side, \ right side \ )); // Not sure \{space} is legal.
$write("*-* All Finished *-*\n");
$finish;

View File

@ -13,7 +13,7 @@
At file t/t_preproc_inc2.v line 4
At file "t/t_preproc_inc2.v" line 4
`line 6 "t/t_preproc_inc2.v" 0
@ -27,7 +27,7 @@ At file t/t_preproc_inc2.v line 4
At file inc3_a_filename_from_line_directive line 10
At file "inc3_a_filename_from_line_directive" line 10