[antlr-interest] Big grammar => static initializer/method size is exceeding the 65535 bytes limit

Alex Marin alex.marin at amiq.ro
Wed Nov 4 05:26:56 PST 2009

Hello again,

The issue appeared when generating a parser grammar, it (mostly) had to do
with the static initializer code for prediction DFAs. We modified the
StringTemplate to enclose such declarations:

static final String DFA1_eotS =
static final String DFA1_eofS =
static final String DFA1_minS =
static final String DFA1_maxS =
static final String DFA1_acceptS =
static final String DFA1_specialS =
static final String[] DFA1_transitionS = {

in static classes. Happily, this fixed the problem.

Best regards,
Alex Marin

On Tue, 03 Nov 2009 12:28:19 -0800, "Jim Idle" <jimi at temporal-wave.com>
> I think that the issue is more likely something to do with your lexer
> specification. You should not need to worry about having lots of
> so one of the other rules must be causing the huge expansion. For
> I have problems with the complete lexer for TSQL, which has more keywords
> than you can shake a stick at. 
> Did you ever post your complete lexer spec? I was out of the country when
> you first started this thread.
> Jim
>> -----Original Message-----
>> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>> bounces at antlr.org] On Behalf Of Alex Marin
>> Sent: Tuesday, November 03, 2009 10:43 AM
>> To: Antlr interest
>> Cc: Etools
>> Subject: [antlr-interest] Big grammar => static initializer/method size
>> is exceeding the 65535 bytes limit
>> Hello,
>> I've managed to find an automated solution for one of the previously
>> reported errors, namely for:
>> The code for the static initializer is exceeding the 65535 bytes limit
>> The "fix" consists of modifying the StringTemplate that generates the
>> parser code so that static initializers are automatically included in
>> speparate classes (and properly referenced). By using static classes,
>> all of the code is contained in a single file, so the change is
>> transparent from a user's point of view.
>> You can find the modified code in the attached file.
>> Best regards,
>> Alex Marin
>> PS: In order to use the fix you have to replace the Java.stg from
>> org.antlr.codegen.templates.Java with this one and recompile antlr.
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address

More information about the antlr-interest mailing list