Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
veripoolbot opened this issue Dec 19, 2017 · 4 comments
Closed

Comments

@veripoolbot
Copy link
Collaborator


Author Name: Rob Stoddard
Original Redmine Issue: 1252 from https://www.veripool.org

Original Assignee: Rob Stoddard


The comment on line 591:


// No FL; it's at comment begin

</code>

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
</code>

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");

</code>
@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2017-12-21T00:41:58Z


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. */
 }

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Rob Stoddard
Original Date: 2017-12-21T01:28:59Z


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");

</code>

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2017-12-21T02:37:18Z


Fixed in git towards 3.448.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2018-01-02T23:04:41Z


In 3.448.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant