[antlr-interest] Code too large, java error

Gustaf Johansson gustaf.j at gmail.com
Wed Jul 1 07:37:04 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

Thanks alot for the info Jim!
After some search on the antlr wiki i found:
http://www.antlr.org/wiki/display/ANTLR3/Composite+Grammars which is
what i need :).

As you said Works seems to have some problems with imports though,
basically it only produces valid syntax check on the root node.
Hopefully this will get fixed in a later version, but i can live
without the syntax check.

My problem is that Works is really slow when there are lots of errors,
so what i would like to know is; if there are some "hidden" setting in
Works to disable the syntax and grammar check?
This also affects remote debugging and gets really annoying after a while.

BR Gustaf


More information about the antlr-interest mailing list