Bug with JFlex

Thank you Sascha for the guidance. I'm sure that not using the skeleton
will turn out to be my problem.

However, I now have a bug in the generated code. See below for the
generated advance() method. Perhaps the skeleton is out of sync with
that packaged JFlex.

The lines marked with >>> <<< below have the error that zzBufferL is a
CharSequence, yet is being used as an array. This is not mine, it code
from the idea-flex.skeleton.

/**

  • Resumes scanning until the next regular expression is matched,

  • the end of input is encountered or an I/O-Error occurs.

*

  • @return the next token

  • @exception java.io.IOException if any I/O-Error occurs

*/
public IElementType advance() throws java.io.IOException {
int zzInput;
int zzAction;

// cached fields:
int zzCurrentPosL;
int zzMarkedPosL;
int zzEndReadL = zzEndRead;
CharSequence zzBufferL = zzBuffer;
char[] zzBufferArrayL = zzBufferArray;
char [] zzCMapL = ZZ_CMAP;

int [] zzTransL = ZZ_TRANS;
int [] zzRowMapL = ZZ_ROWMAP;
int [] zzAttrL = ZZ_ATTRIBUTE;

while (true) {
zzMarkedPosL = zzMarkedPos;

zzAction = -1;

zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;

zzState = zzLexicalState;


zzForAction: {
while (true) {

if (zzCurrentPosL < zzEndReadL)
>>> zzInput = zzBufferL[zzCurrentPosL++]; <<<
else if (zzAtEOF) {
zzInput = YYEOF;
break zzForAction;
}
else {
// store back cached positions
zzCurrentPos = zzCurrentPosL;
zzMarkedPos = zzMarkedPosL;
boolean eof = zzRefill();
// get translated positions and possibly new buffer
zzCurrentPosL = zzCurrentPos;
zzMarkedPosL = zzMarkedPos;
zzBufferL = zzBuffer;
zzEndReadL = zzEndRead;
if (eof) {
zzInput = YYEOF;
break zzForAction;
}
else {
>>> zzInput = zzBufferL[zzCurrentPosL++]; <<<
}
}
int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
if (zzNext == -1) break zzForAction;
zzState = zzNext;

int zzAttributes = zzAttrL[zzState];
if ( (zzAttributes & 1) == 1 ) {
zzAction = zzState;
zzMarkedPosL = zzCurrentPosL;
if ( (zzAttributes & 8) == 8 ) break zzForAction;
}

}
}

2 comments
Comment actions Permalink

Hello Peter,

Thank you Sascha for the guidance. I'm sure that not using the skeleton
will turn out to be my problem.

However, I now have a bug in the generated code. See below for the
generated advance() method. Perhaps the skeleton is out of sync with
that packaged JFlex.


You have to use the (patched) JFlex that is packaged with IDEA and also instruct it to use
the correct way to access the charsequence by passing charat="true" to its Ant task. Also
see the example that I posted earlier.

Sascha

0
Comment actions Permalink

Here's the Ant-Task example again, the stupid forum software decided to drop it from my message posted via NNTP

<taskdef name="jflex" classname="JFlex.anttask.JFlexTask">
   <classpath location="${idea.home}/tools/jflex/lib/JFlex.jar"/>
</taskdef>
<jflex skeleton="${idea.home}/tools/jflex/idea-flex.skeleton" nobak="true"
       file="${src.dir}/.../lexer.flex" destdir="${src.dir}" charat="true" />

Sascha


Edit: Even the web interface messed up the the xml fragment.

0

Please sign in to leave a comment.