Menu

#118 Scanner does not clean zzFin appropriately

jflex bug
closed-fixed
nobody
None
5
2014-08-25
2011-11-10
Anonymous
No

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.

Discussion

  • Steve Rowe

    Steve Rowe - 2013-10-11
     
  • Steve Rowe

    Steve Rowe - 2013-12-21

    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.

     
  • Gerwin Klein

    Gerwin Klein - 2014-01-16
    • status: open --> open-fixed
    • Group: --> jflex bug
     
  • Gerwin Klein

    Gerwin Klein - 2014-03-01
    • status: open-fixed --> closed-fixed