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

Stephen Winnall steve at winnall.ch
Fri Oct 8 06:44:42 PDT 2010


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 with 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 the 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, so 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 problem. 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.



More information about the antlr-interest mailing list