From 996afe7d95ad4b85d2cc389bdb6503a1ca4e5c40 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 22 Oct 2009 16:51:34 -0400 Subject: [PATCH] Cleanup handling DOS CRs to match preprocessor Fix missing line number increment for `pragma --- src/verilog.l | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/verilog.l b/src/verilog.l index 695d005f4..80bc47e9e 100644 --- a/src/verilog.l +++ b/src/verilog.l @@ -136,6 +136,7 @@ void yyerrorf(const char* format, ...) { ws [ \t\f\r]+ wsnr [ \t\f]+ +crnl [\r]*[\n] /* identifier */ id [a-zA-Z_][a-zA-Z0-9_$]* /* escaped identifier */ @@ -148,7 +149,7 @@ escid \\[^ \t\f\r\n]+ /* Verilog 1995 */ { {ws} { } /* otherwise ignore white-space */ - \n { NEXTLINE(); } /* Count line numbers */ + {crnl} { NEXTLINE(); } /* Count line numbers */ /* Extensions to Verilog set, some specified by PSL */ "$c"[0-9]* { FL; return yD_C; } /*Verilator only*/ /* System Tasks */ @@ -765,17 +766,18 @@ escid \\[^ \t\f\r\n]+ /************************************************************************/ /* STRINGS */ -\n { yyerrorf("Unterminated string\n"); } -\r ; -[^\"\\]* { yymore(); } +{crnl} { yyerrorf("Unterminated string"); } \\. { yymore(); } \" { yy_pop_state(); yylval.strp = V3Read::newString(yytext+1,yyleng-2); return yaSTRING; } +. { yymore(); } +<> { yyerrorf("EOF in string"); + yyleng = 0; yy_pop_state(); } /************************************************************************/ /* Attributes */ -\n { yymore(); NEXTLINE(); } +{crnl} { yymore(); NEXTLINE(); } "*)" { yy_pop_state(); } . { yymore(); } <> { yyerrorf("EOF in (*"); @@ -795,7 +797,7 @@ escid \\[^ \t\f\r\n]+ "`accelerate" { } // Verilog-XL compatibility "`autoexpand_vectornets" { } // Verilog-XL compatibility "`celldefine" { V3Read::inCellDefine(true); } - "`default_decay_time"{ws}+[^\n]* { } // Verilog spec - delays only + "`default_decay_time"{ws}+[^\n\r]* { } // Verilog spec - delays only "`delay_mode_distributed" { } // Verilog spec - delays only "`delay_mode_path" { } // Verilog spec - delays only "`delay_mode_unit" { } // Verilog spec - delays only @@ -806,7 +808,7 @@ escid \\[^ \t\f\r\n]+ "`endprotect" { } "`expand_vectornets" { } // Verilog-XL compatibility "`inline" { } - "`line"{ws}+[^\n]*\n { V3Read::ppline(yytext); } + "`line"{ws}+[^\n\r]*{crnl} { V3Read::ppline(yytext); } "`noaccelerate" { } // Verilog-XL compatibility "`noexpand_vectornets" { } // Verilog-XL compatibility "`noremove_gatenames" { } // Verilog-XL compatibility @@ -814,7 +816,7 @@ escid \\[^ \t\f\r\n]+ "`nosuppress_faults" { } // Verilog-XL compatibility "`nounconnected_drive" { } // Verilog-XL compatibility "`portcoerce" { } - "`pragma"{ws}+[^\n]*\n { } // Verilog 2005 + "`pragma"{ws}+[^\n\r]* { } // Verilog 2005 "`protect" { } "`psl" { if (V3Read::optPsl()) { BEGIN PSL; } else { BEGIN IGNORE; } } "`remove_gatenames" { } // Verilog-XL compatibility @@ -827,7 +829,7 @@ escid \\[^ \t\f\r\n]+ "`systemc_imp_header" { BEGIN SYSCIMPH; } "`systemc_implementation" { BEGIN SYSCIMP; } "`systemc_interface" { BEGIN SYSCINT; } - "`timescale"{ws}+[^\n]*\n { NEXTLINE(); } // Verilog spec - not supported + "`timescale"{ws}+[^\n\r]* { } // Verilog spec - not supported "`verilog" { BEGIN V3Read::lastVerilogState(); } "`begin_keywords"[ \t]*\"1364-1995\" { yy_push_state(V95); V3Read::pushBeginKeywords(YY_START); } @@ -838,19 +840,18 @@ escid \\[^ \t\f\r\n]+ "`end_keywords" { yy_pop_state(); if (!V3Read::popBeginKeywords()) yyerrorf("`end_keywords when not inside `begin_keywords block"); } } -[ \t]*[^` \t\n][^\n]*\n { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCHDR; } -[ \t]*[^` \t\n][^\n]*\n { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCINT; } -[ \t]*[^` \t\n][^\n]*\n { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCIMP; } -[ \t]*[^` \t\n][^\n]*\n { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCIMPH; } -[ \t]*[^` \t\n][^\n]*\n { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCCTOR; } -[ \t]*[^` \t\n][^\n]*\n { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCDTOR; } -[ \t]*[^` \t\n][^\n]*\n { NEXTLINE(); } +[ \t]*[^` \t\n\r][^\n\r]*{crnl} { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCHDR; } +[ \t]*[^` \t\n\r][^\n\r]*{crnl} { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCINT; } +[ \t]*[^` \t\n\r][^\n\r]*{crnl} { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCIMP; } +[ \t]*[^` \t\n\r][^\n\r]*{crnl} { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCIMPH; } +[ \t]*[^` \t\n\r][^\n\r]*{crnl} { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCCTOR; } +[ \t]*[^` \t\n\r][^\n\r]*{crnl} { NEXTLINE(); yylval.strp = V3Read::newString(yytext); return yaSCDTOR; } +[ \t]*[^` \t\n\r][^\n\r]*{crnl} { NEXTLINE(); } /* Pick up text-type data */ { {wsnr}* { yymore(); } - \n { NEXTLINE(); yymore(); } - \r ; + {crnl} { NEXTLINE(); yymore(); } } /************************************************************************/