[antlr-interest] how to solve 'code too large' problem?

Kay Roepke kroepke at classdump.org
Fri Jul 13 16:13:36 PDT 2007


On Jul 13, 2007, at 11:04 PM, Randall R Schulz wrote:

>> Grammar-based XML parsing (whether ANTLR or ANTXR) can be very
>> effective for some XML parsing tasks.
>
> Of course, we've seen one example of what happens when you try to span
> all of XML's generic grammar plus a specific schema (generically
> speaking) in one shot with ANTLR: You can overload the Java class file
> size limit!

Quite honestly, that can happen real quick. Happened to me just last  
week
when doing a lexer implementation that had to recognize all top level  
domains,
to allow special handling of URLs. Obviously it was a bit more  
involved than
that, but this is the gist of it.

Apparently there was no way to restructure the grammar so it wouldn't  
blow
Java's stupid code size limits.
Basically what happened was that the predictor ended up being an immense
list of nested if's and then went beyond the code size limit.

Using the -Xnoinlinedfa switch helped, because that forces even small  
predictors
into a DFA object rather than being done with if's.

That might of help with this original issue, too.

cheers,
-k
-- 
Kay Röpke
http://classdump.org/






More information about the antlr-interest mailing list