diff --git a/ivtest/ivltests/br_gh782e.v b/ivtest/ivltests/br_gh782e.v new file mode 100644 index 000000000..b00d64717 --- /dev/null +++ b/ivtest/ivltests/br_gh782e.v @@ -0,0 +1,22 @@ +// This is just a syntax test. + +/* comment */ `begin_keywords /* comment */ // comment +/* comment */ "1364-2005" /* comment */ // comment +module m1; +endmodule +/* comment */ `end_keywords /* comment */ // comment + +/* comment */`begin_keywords/* + comment */ +/* comment */"1364-2005"/* + comment */ +module m2; +endmodule +/* comment */`end_keywords/* + comment */ + +module test; + +initial $display("PASSED"); + +endmodule diff --git a/ivtest/regress-vlg.list b/ivtest/regress-vlg.list index b8c701897..57f4c21fa 100644 --- a/ivtest/regress-vlg.list +++ b/ivtest/regress-vlg.list @@ -351,6 +351,7 @@ br_gh674 normal ivltests br_gh732 normal ivltests gold=br_gh732.gold br_gh782c normal ivltests br_gh782d normal ivltests +br_gh782e normal ivltests br_gh788 normal,-gno-io-range-error,-Wno-anachronisms ivltests gold=br_gh788.gold br_gh793 normal ivltests br_ml20150315 normal ivltests gold=br_ml_20150315.gold diff --git a/lexor.lex b/lexor.lex index da165f73d..cad2d6350 100644 --- a/lexor.lex +++ b/lexor.lex @@ -153,6 +153,7 @@ void lex_in_package_scope(PPackage*pkg) %x PPUCDRIVE_ERROR %x PPDEFAULT_NETTYPE %x PPBEGIN_KEYWORDS +%x PPBEGIN_KEYWORDS_ERROR %s EDGES %x REAL_SCALE @@ -708,9 +709,9 @@ TU [munpf] ^{W}?`suppress_faults{W}?.* { } ^{W}?`uselib{W}?.* { } -^{W}?`begin_keywords{W}? { BEGIN(PPBEGIN_KEYWORDS); } +`begin_keywords { BEGIN(PPBEGIN_KEYWORDS); } -\"[a-zA-Z0-9 -\.]*\".* { +\"[a-zA-Z0-9 -\.]*\" { keyword_mask_stack.push_front(lexor_keyword_mask); char*word = yytext+1; @@ -764,19 +765,23 @@ TU [munpf] BEGIN(0); } -.* { - fprintf(stderr, "%s:%d: Malformed keywords specification: %s\n", - yylloc.text, yylloc.first_line, yytext); - BEGIN(0); - } +"//" { comment_enter = PPBEGIN_KEYWORDS; BEGIN(LCOMMENT); } +"/*" { comment_enter = PPBEGIN_KEYWORDS; BEGIN(CCOMMENT); } +"\n" { yylloc.first_line += 1; } +{W} { ; } +. { BEGIN(PPBEGIN_KEYWORDS_ERROR); } -^{W}?`end_keywords{W}?.* { + /* On error, try to recover by skipping to the end of the line. */ +[^\n]+ { + VLerror(yylloc, "error: Invalid `begin_keywords directive."); + BEGIN(0); } + +`end_keywords { if (!keyword_mask_stack.empty()) { lexor_keyword_mask = keyword_mask_stack.front(); keyword_mask_stack.pop_front(); } else { - fprintf(stderr, "%s:%d: Mismatched end_keywords directive\n", - yylloc.text, yylloc.first_line); + VLwarn(yylloc, "warning: Mismatched `end_keywords directive"); } }