2

I am trying to create a Scanner with JFlex. I created my .jflex file and it compiles and everything. The problem is that when I try to prove it, some times it gives me and error of ArrayIndexOutOfBoundsException: 769 in the .java class that JFlex created.

I am using Cup Parser generator too. I don't know if the problem can be related with the part of Cup Analysis, but here is how I called my analyzers.

    ScannerLexico lexico = new ScannerLexico(new BufferedReader(new StringReader( jTextPane1.getText())));
    ParserSintactico sintaxis = new ParserSintactico(lexico);

I don't know how to fix it. Please help me.

Here are the links to my code:

JFlex File "ScannerFranklin.jflex"

Java Class generated "ScannerLexico.java"

The part where I have the problem in the .java class created by JFlex, in next_token() function (Line 899 in java file).

      int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
      if (zzNext == -1) break zzForAction;
      zzState = zzNext;

Thanks.

rds
  • 26,253
  • 19
  • 107
  • 134
  • For future reference, please note that questions should contain the relevant code in the question itself, not just as a link to a paste bin. You should also make sure that your code is as small as possible, while still compiling and reproducing the error (this is known as an [MCVE](https://stackoverflow.com/help/mcve)). In this case you could have easily produced a jflex file with 20 lines or less that still produces the same error. While doing that, you should also translate your method and variable names to English to make it easier for us to make sense of the code. Thank you. – sepp2k Aug 18 '18 at 11:38

1 Answers1

4

According to its documentation, JFlex throws ArrayIndexOutOfBounds exceptions whenever it encounters Unicode characters using the %7bit or %8bit/%full encoding options. It recommends to always use the %unicode option instead, which is the default.

You are using the %unicode option, but you're also using %full. Apparently when you have both options, %full takes precedence. So remove %full and the error should go away.

sepp2k
  • 363,768
  • 54
  • 674
  • 675