[antlr-interest] Code too large, java error

Dermot ONeill dermot_oneill at hotmail.com
Wed Jul 1 07:57:26 PDT 2009


Hi Gustaf,
I encountered this problem as well.Javac pointed to tokenNames being too long, but after a bit of messing around it looked like it was due to the overall size of the static initialization in the generated java files. 
In my case there where thousands of FOLLOW_... static final vars defined at the end of the generated Java file.public static final BitSet FOLLOW_ ... 

I wrote a post processing script to pull these out into a separate interface(s) , and then brought them back in by "implementing" those interfaces.This allowed Javac to build.
I set this up in ant as well.http://dermotoneill.blogspot.com/2009/07/antlr3-can-generate-very-large-java.html

Wont work with AntlrWorks, but may be of some use.Regards,Dermot.
> Date: Tue, 30 Jun 2009 08:10:20 -0700
> From: jimi at temporal-wave.com
> CC: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Code too large, java error
> 
> 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
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address

_________________________________________________________________
See all the ways you can stay connected to friends and family
http://www.microsoft.com/windows/windowslive/default.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090701/145b7a4d/attachment.html 


More information about the antlr-interest mailing list