[antlr-interest] "code too large" / can't split AST output into smaller files

Jim Idle jimi at temporal-wave.com
Fri Oct 8 08:51:03 PDT 2010

I don't know why you are seeing a difference other than you are not
compiling what you think you are in Works, or a different version of ABTLR
is in use between the two systems. Anyway, you are correct to use Maven, and
should be using version 3.2.1 at the moment.

Importing of tree walking and tree generating grammars works fine, just
remember that the order of the statements is a bit fragile in 3.2 and so you
have to get the statements in the correct order. Your grammar files should
be in the antlr3/com/my/package/r.g order and your includes in the
antlr3/imports directory. Then your importing grammar should be:

parser grammar x;
options {}
import i1, i2, i3, i4, etc;
tokens {}

rule1 : ....

The grammars you import are:

parser grammar myimport;

rulenm: ...;

Without you including any specific errors or your grammar files, it is
difficult to see what else you are doing wrong, if anything.


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Stephen Winnall
> Sent: Friday, October 08, 2010 6:45 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] "code too large" / can't split AST output into
> files
> I'm using Antlr 3.2 with Java 1.6.0_20 under Mac OS X 10.6.4.
> I have a composite grammar which generates AST trees. I can run and debug
> the grammar from AntlrWorks 1.4 without any problem.
> However, my grammar is part of a larger project, which I am developing
> NetBeans 6.9.1 and Maven, using the antlr3-maven-plugin. When I try to
> build my project, the grammar file gets translated into Java alright, but
> resultant Java parser file causes a "code too large" error.
> I don't understand why AntlrWorks can compile the grammar but NetBeans
> cannot. Can anyone enlighten me? The generated parser file is 13756 lines
> long and the "code too large" error under NetBeans appears on line 7204,
> there seems to be a fundamental difference in what NetBeans/Maven and
> AntlrWorks are doing.
> I have tried to split the grammar into smaller bits to work round this
> I took some parser rules and put them into a different parser grammar,
> which I imported into the main one. However, nearly all my parser rules
> include "-> ^( ... )" to generate AST stuff. Antlr complains when it sees
a "^("
> in the imported file. I have included "output=AST;" in the options for the
> imported file.
> None of the examples of composite grammars that I have been able to find
> in the net deal with AST output from the imported file. Is there some
trick I
> should be aware of?
> Regards
> Steve
> --
> This message has been scanned for viruses and dangerous content by
> MailScanner, and is believed to be clean.
> 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