mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 01:54:01 +02:00
Fix preprocessing stringified newline escapes, bug915.
This commit is contained in:
+20
-9
@@ -58,6 +58,7 @@ static void appendDefValue(const char* t, size_t l) { LEXP->appendDefValue(t,l);
|
||||
%x DEFFORM
|
||||
%x DEFVAL
|
||||
%x DEFCMT
|
||||
%x STRIFY
|
||||
%x ARGMODE
|
||||
%x INCMODE
|
||||
%x PRTMODE
|
||||
@@ -80,8 +81,8 @@ drop [\032]
|
||||
/**************************************************************/
|
||||
%%
|
||||
|
||||
<INITIAL>^{ws}*"`line"{ws}+.*{crnl} { LEXP->lineDirective(yytext);
|
||||
return(VP_LINE); }
|
||||
<INITIAL,STRIFY>^{ws}*"`line"{ws}+.*{crnl} { LEXP->lineDirective(yytext);
|
||||
return(VP_LINE); }
|
||||
|
||||
/* Special directives we recognize */
|
||||
<INITIAL>"`define" { return(VP_DEFINE); }
|
||||
@@ -93,17 +94,15 @@ drop [\032]
|
||||
<INITIAL>"`include" { return(VP_INCLUDE); }
|
||||
<INITIAL>"`undef" { return(VP_UNDEF); }
|
||||
<INITIAL>"`undefineall" { return(VP_UNDEFINEALL); }
|
||||
|
||||
/* Optional directives we recognize */
|
||||
<INITIAL>"`__FILE__" { static string rtnfile;
|
||||
<INITIAL>"`error" { if (!pedantic()) return (VP_ERROR); else return(VP_DEFREF); }
|
||||
<INITIAL,STRIFY>"`__FILE__" { static string rtnfile;
|
||||
rtnfile = '"'; rtnfile += LEXP->curFilelinep()->filename();
|
||||
rtnfile += '"'; yytext=(char*)rtnfile.c_str(); yyleng = rtnfile.length();
|
||||
return (VP_STRING); }
|
||||
<INITIAL>"`__LINE__" { static char buf[10];
|
||||
<INITIAL,STRIFY>"`__LINE__" { static char buf[10];
|
||||
sprintf(buf, "%d",LEXP->curFilelinep()->lineno());
|
||||
yytext = buf; yyleng = strlen(yytext);
|
||||
return (VP_TEXT); }
|
||||
<INITIAL>"`error" { if (!pedantic()) return (VP_ERROR); else return(VP_DEFREF); }
|
||||
|
||||
/* Pass-through strings */
|
||||
<INITIAL>{quote} { yy_push_state(STRMODE); yymore(); }
|
||||
@@ -118,8 +117,20 @@ drop [\032]
|
||||
else return (VP_STRING); }
|
||||
|
||||
/* Stringification */
|
||||
<INITIAL>{tickquote} { return VP_STRIFY; }
|
||||
<INITIAL>"`\\`\"" { return VP_BACKQUOTE; }
|
||||
<INITIAL>{tickquote} { yy_push_state(STRIFY); return VP_STRIFY; }
|
||||
<STRIFY><<EOF>> { linenoInc(); yyerrorf("EOF in unterminated '\""); yyleng=0; yyterminate(); }
|
||||
<STRIFY>"`\\`\"" { return VP_BACKQUOTE; }
|
||||
<STRIFY>{quote} { yy_push_state(STRMODE); yymore(); }
|
||||
<STRIFY>{tickquote} { yy_pop_state(); return VP_STRIFY; }
|
||||
<STRIFY>{symbdef} { return (VP_SYMBOL); }
|
||||
<STRIFY>{symbdef}`` { yyleng-=2; return (VP_SYMBOL_JOIN); }
|
||||
<STRIFY>"`"{symbdef} { return (VP_DEFREF); }
|
||||
<STRIFY>"`"{symbdef}`` { yyleng-=2; return (VP_DEFREF_JOIN); }
|
||||
<STRIFY>{crnl} { linenoInc(); yytext=(char*)"\n"; yyleng=1; return(VP_WHITE); }
|
||||
<STRIFY>{wsn}+ { return (VP_WHITE); }
|
||||
<STRIFY>{drop} { }
|
||||
<STRIFY>[\r] { }
|
||||
<STRIFY>. { return (VP_TEXT); }
|
||||
|
||||
/* Protected blocks */
|
||||
<INITIAL>"`protected" { yy_push_state(PRTMODE); yymore(); }
|
||||
|
||||
Reference in New Issue
Block a user