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

[Bug] Scanner does not clean zzFin appropriately [sf#118] #119

Closed
lsf37 opened this Issue Feb 15, 2015 · 5 comments

Comments

Projects
None yet
2 participants
@lsf37
Member

lsf37 commented Feb 15, 2015

*Reported by anonymous on 2011-11-10 20:40 UTC
I think, there is a bug on the line 1207 of the Emitter.java
Instead of " println(" if ((zzAttrL[zzFState] & 1) == 1) { zzFinL[zzFPos] = true; } ");"
it should read " println(" zzFinL[zzFPos] = ((zzAttrL[zzFState] & 1) == 1;");"

Otherwise, zzFin buffer is not cleared correctly (it is reused, but in the current code elements are never reset to false. See the patch attached.

@lsf37 lsf37 changed the title from Scanner does not clean zzFin appropriately to [Bug] Scanner does not clean zzFin appropriately [sf#118] Feb 15, 2015

@lsf37 lsf37 added this to the jflex bug milestone Feb 15, 2015

@lsf37 lsf37 closed this Feb 15, 2015

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

*Commented by anonymous on 2011-11-10 20:40 UTC
patch

Member

lsf37 commented Feb 15, 2015

*Commented by anonymous on 2011-11-10 20:40 UTC
patch

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Commented by steve_rowe on 2013-10-11 08:55 UTC
Is this related to http://sourceforge.net/p/jflex/bugs/110/ ?

Member

lsf37 commented Feb 15, 2015

Commented by steve_rowe on 2013-10-11 08:55 UTC
Is this related to http://sourceforge.net/p/jflex/bugs/110/ ?

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Commented by steve_rowe on 2013-12-21 23:12 UTC
I committed a fix in r723.

The patch for Emitter.java was a bit more involved though, since zzFin wasn't being fully updated with the original patch on this issue - here's what I committed:

@@ -1212,11 +1212,14 @@
         println("            if (zzFin.length <= zzBufferL.length) { zzFin = new boolean[zzBufferL.length+1]; }");
         println("            boolean zzFinL[] = zzFin;");
         println("            while (zzFState != -1 && zzFPos < zzMarkedPos) {");
-        println("              if ((zzAttrL[zzFState] & 1) == 1) { zzFinL[zzFPos] = true; } ");
+        println("              zzFinL[zzFPos] = ((zzAttrL[zzFState] & 1) == 1);");
         println("              zzInput = zzBufferL[zzFPos++];");
         println("              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];");
         println("            }");
-        println("            if (zzFState != -1 && (zzAttrL[zzFState] & 1) == 1) { zzFinL[zzFPos] = true; } ");
+        println("            if (zzFState != -1) { zzFinL[zzFPos++] = ((zzAttrL[zzFState] & 1) == 1); } ");
+        println("            while (zzFPos <= zzMarkedPos) {");
+        println("              zzFinL[zzFPos++] = false;");
+        println("            }");
         println();                
         println("            zzFState = "+dfa.entryState[action.getEntryState()+1]+";");
         println("            zzFPos = zzMarkedPos;");

I also added a new test case named genlook2 that failed without the above patch and succeeded with it.

Member

lsf37 commented Feb 15, 2015

Commented by steve_rowe on 2013-12-21 23:12 UTC
I committed a fix in r723.

The patch for Emitter.java was a bit more involved though, since zzFin wasn't being fully updated with the original patch on this issue - here's what I committed:

@@ -1212,11 +1212,14 @@
         println("            if (zzFin.length <= zzBufferL.length) { zzFin = new boolean[zzBufferL.length+1]; }");
         println("            boolean zzFinL[] = zzFin;");
         println("            while (zzFState != -1 && zzFPos < zzMarkedPos) {");
-        println("              if ((zzAttrL[zzFState] & 1) == 1) { zzFinL[zzFPos] = true; } ");
+        println("              zzFinL[zzFPos] = ((zzAttrL[zzFState] & 1) == 1);");
         println("              zzInput = zzBufferL[zzFPos++];");
         println("              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];");
         println("            }");
-        println("            if (zzFState != -1 && (zzAttrL[zzFState] & 1) == 1) { zzFinL[zzFPos] = true; } ");
+        println("            if (zzFState != -1) { zzFinL[zzFPos++] = ((zzAttrL[zzFState] & 1) == 1); } ");
+        println("            while (zzFPos <= zzMarkedPos) {");
+        println("              zzFinL[zzFPos++] = false;");
+        println("            }");
         println();                
         println("            zzFState = "+dfa.entryState[action.getEntryState()+1]+";");
         println("            zzFPos = zzMarkedPos;");

I also added a new test case named genlook2 that failed without the above patch and succeeded with it.

@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Updated by lsf37 on 2014-01-16 06:47 UTC

  • status: open --> open-fixed
  • Group: --> jflex bug
Member

lsf37 commented Feb 15, 2015

Updated by lsf37 on 2014-01-16 06:47 UTC

  • status: open --> open-fixed
  • Group: --> jflex bug
@lsf37

This comment has been minimized.

Show comment
Hide comment
@lsf37

lsf37 Feb 15, 2015

Member

Updated by lsf37 on 2014-03-01 00:21 UTC

  • status: open-fixed --> closed
Member

lsf37 commented Feb 15, 2015

Updated by lsf37 on 2014-03-01 00:21 UTC

  • status: open-fixed --> closed

@lsf37 lsf37 added bug and removed bug labels Feb 17, 2015

@lsf37 lsf37 modified the milestone: jflex bug Feb 17, 2015

@regisd regisd added this to the 1.5.0 milestone Nov 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment