Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  IPC::Locker
  Parallel::Forker
  Voneline
General Info
  Papers

Issue #1252

flex v 2.6.4: comment in VParseLex.l is causing my flex to barf...

Added by Rob Stoddard almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
% Done:

0%


Description

The comment on line 591:

// No FL; it's at comment begin

is causing my lexer to throw chunks. I have no idea why, it looks like a perfectly valid comment. It's the apostrophe (single quote) that is causing my lexer to give me the following error:

/usr/bin/m4:stdin:2854: ERROR: end of file in string

which itself is amazingly misleading and annoying. I had to find the issue by cutting out chunks of the lexer and running it until the issue went away.


diff --git a/Parser/VParseLex.l b/Parser/VParseLex.l
index 18c69ef..f20a073 100644
--- a/Parser/VParseLex.l
+++ b/Parser/VParseLex.l
@@ -588,7 +588,7 @@ vnum        {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
   /* Multi-line COMMENTS */
 <CMTMODE>"*"+[^*/\n]*  { yymore(); }
 <CMTMODE>\n            { yymore(); NEXTLINE(); }
-<CMTMODE>"*"+"/"       { VALTEXT; CALLBACK(commentCb); yy_pop_state(); } // No FL; it's at comment begin
+<CMTMODE>"*"+"/"       { VALTEXT; CALLBACK(commentCb); yy_pop_state(); } // No FL; it is at comment begin
 <CMTMODE>{word}                { yymore(); }
 <CMTMODE>.             { yymore(); }
 <CMTMODE><<EOF>>       { yyerrorf("EOF in '/* ... */' block comment");

History

#1 Updated by Wilson Snyder almost 2 years ago

  • Status changed from New to AskedReporter

Wow, good job debugging that.

I'm wondering if the below patch also works for you? That is use C style comments. My worry is at some point there might be another ' added by mistake and perhaps C style is better supported?

diff --git a/Parser/VParseLex.l b/Parser/VParseLex.l
index 18c69ef..c649036 100644
--- a/Parser/VParseLex.l
+++ b/Parser/VParseLex.l
@@ -588,7 +588,7 @@ vnum        {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
   /* Multi-line COMMENTS */
 <CMTMODE>"*"+[^*/\n]*  { yymore(); }
 <CMTMODE>\n            { yymore(); NEXTLINE(); }
-<CMTMODE>"*"+"/"       { VALTEXT; CALLBACK(commentCb); yy_pop_state(); } // No FL; it's at comment begin
+<CMTMODE>"*"+"/"       { VALTEXT; CALLBACK(commentCb); yy_pop_state(); } /* No FL; it's at comment begin */
 <CMTMODE>{word}                { yymore(); }
 <CMTMODE>.             { yymore(); }
 <CMTMODE><<EOF>>       { yyerrorf("EOF in '/* ... */' block comment");
@@ -617,7 +617,7 @@ vnum        {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
   /* Attributes */
   /* Note simulators vary in support for "(* /_*something*_/ foo*)" where _ doesn't exist */
 <V95,V01,V05,S05,S09,S12>{
-    "(*"({ws}|{crnl})*({id}|{escid})   { yymore(); yy_push_state(ATTRMODE); }  // Doesn't match (*), but (* attr_spec
+    "(*"({ws}|{crnl})*({id}|{escid})   { yymore(); yy_push_state(ATTRMODE); }  /* Doesn't match (*), but (* attr_spec */
 }

   /************************************************************************/
@@ -676,7 +676,7 @@ vnum        {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
                          if (LPARSEP->sigParser()) { yyerrorf("Define or directive not defined: %s",yytext); }
                          else { CALLBACK(preprocCb); } }
   "//"[^\n]*           { FL; VALTEXT; CALLBACK(commentCb); }  /* throw away single line comments */
-  "/*"                 { FL; yy_push_state(CMTMODE); yymore(); }  // FL; marks start for COMMENT callback
+  "/*"                 { FL; yy_push_state(CMTMODE); yymore(); }  /* FL; marks start for COMMENT callback */
   .                    { FL; VALTEXT; CALLBACK(operatorCb); return ygenOPERATOR; } /* return single char ops. */
 }

#2 Updated by Rob Stoddard almost 2 years ago

Looks like a C style comment does fix this issue.

diff --git a/Parser/VParseLex.l b/Parser/VParseLex.l
index 18c69ef..f963c70 100644
--- a/Parser/VParseLex.l
+++ b/Parser/VParseLex.l
@@ -588,7 +588,7 @@ vnum        {vnum1}|{vnum2}|{vnum3}|{vnum4}|{vnum5}
   /* Multi-line COMMENTS */
 <CMTMODE>"*"+[^*/\n]*  { yymore(); }
 <CMTMODE>\n            { yymore(); NEXTLINE(); }
-<CMTMODE>"*"+"/"       { VALTEXT; CALLBACK(commentCb); yy_pop_state(); } // No FL; it's at comment begin
+<CMTMODE>"*"+"/"       { VALTEXT; CALLBACK(commentCb); yy_pop_state(); } /* No FL; it's at comment begin */
 <CMTMODE>{word}                { yymore(); }
 <CMTMODE>.             { yymore(); }
 <CMTMODE><<EOF>>       { yyerrorf("EOF in '/* ... */' block comment");

#3 Updated by Wilson Snyder almost 2 years ago

  • Assignee set to Rob Stoddard

Fixed in git towards 3.448.

#4 Updated by Wilson Snyder almost 2 years ago

  • Status changed from AskedReporter to Resolved

#5 Updated by Wilson Snyder almost 2 years ago

  • Status changed from Resolved to Closed

In 3.448.

Also available in: Atom