2

I have a pretty big grammar I don't want to break it into multiple smaller grammars. But The generated Lexer file is giving the following error:

The code of method specialStateTransition(int, IntStream) is exceeding the 65535 bytes

I am using ANTLR-3.2. Please tell me how to remove this compiler error.

Thanks

Preeti

Preeti
  • 93
  • 10

3 Answers3

4

Method specialStateTransition is not always generated. It may be related to some tokens that share common prefixes with other tokens.

See this question/answer for a case where specialStateTransition completely vanished by reformulating just one such token.

Community
  • 1
  • 1
Gunther
  • 5,146
  • 1
  • 24
  • 35
2

I had the same problem recently and managed to fix it by changing the options for the Antlr code generation tool..

C: java org.antlr.Tool –Xmaxinlinedfastates [a number less than 60] grammar.g

Using this option forces the code generator to create a table of DFA states rather than many nested if statements

Jimmy
  • 6,001
  • 1
  • 22
  • 21
1

You can't: you will have to refactor your code. The limit is inherent to Java class files.

From Section 4.10 (Limitations of the Java Virtual Machine) of the VM specification:

The amount of code per non-native, non-abstract method is limited to 65536 bytes by the sizes of the indices in the exception_table of the Code attribute (§4.7.3), in the LineNumberTable attribute (§4.7.8), and in the LocalVariableTable attribute (§4.7.9).

Matteo
  • 14,696
  • 9
  • 68
  • 106