[antlr-interest] Code too large, java error

Jim Idle jimi at temporal-wave.com
Tue Jun 30 08:10:20 PDT 2009


Gustaf Johansson wrote:
> Hello,
>
> I have implemented the grammar for a fairly complex language, using 
> it's BNF definition as base.
> (Basically just reformatting the syntax to match Antlr).
>
> Now this worked fine although the generated java code got pretty 
> large, ~60´000 lines in the parser and ~7´500 in the lexer.
>
> Now there has arrived a new revision of the language and i started to 
> implement the additions and changes and thats where i hit the wall.
>
> Using just plain Antlr and generate a non-debug version works as 
> before, but in AntlrWorks when generating a debug version i get:
>
> [12:56:12] C:\antlr\output\ExtendedParser.java:15: code too large
> [12:56:12]     public static final String[] tokenNames = new String[] {
> [12:56:12]                                  ^
> [12:56:12] 1 error
>
> The debug versions are ~85´500 lines in the parser and ~7´800 lines in 
> the lexer.
>
> If i comment out the "tokenNames" and "ruleNames" string and the 
> "getTokenNames" function it compiles and runs, but id rather not do 
> this manually each time i compile.
You need to split your grammar into a number of component parts and use 
import. This generates separate classes and you won't get the problem. 
However, Works is not yet dealing with imports perfectly so while you 
can edit and so on, you will need to debug remotely from Works.

Jim


More information about the antlr-interest mailing list