[antlr-interest] Code too large, java error

Gustaf Johansson gustaf.j at gmail.com
Thu Jul 2 00:45:07 PDT 2009


On Wed, Jul 1, 2009 at 8:53 PM, Jim Idle<jimi at temporal-wave.com> wrote:
> Gustaf Johansson wrote:
>
> 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
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
> I have noticed it being slow with lots of errors using open JDK, but using
> Sun JDK it seems to be a lot better. I think that Jean is working on all the
> composite grammar stuff though. You might try his beta version.
>
> Jim
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>

Thanks for the suggestion, i was using Works 1.3b and after a switch
to 1.2.3 i have no more delays (using Sun JDK 1.6.0_13) so perhaps
something is broken in the new beta release.
/Gustaf


More information about the antlr-interest mailing list