[antlr-interest] Parser code is too large(1.68)! (newbie)

Randall R Schulz rschulz at sonic.net
Sun Jul 15 17:49:45 PDT 2007

On Sunday 15 July 2007 17:14, ali azimi wrote:
> Hi,
>   Thank you very much for all your helps.
>   I have produced a lexer and parser. But the parser is so large that
> causes some messages to be produced. the following message comes up
> when I try to compile my parser which is 1.68 Mb, using NetBeans:
>   "Question: The file FinalProject.java seems to be too large (1 Mb)
> to safely open. Opening the file could cause OutOfMemoryError, which
> would make the IDE unusable. Do you really want to open it?"

I suppose 1.6 megabytes is pretty big for a Java source file and the 
odds are good that once compiled the resulting class file will exceed 
the limits of the JVM itself.

On the other hand, other editors, Vim e.g., easily handle files far 
larger than this! Of course, such editors don't need to build such a 
complex model of the file it's editing.

>   I am not sometimes able to see the code for parser on the screen
> whereas I can see the code for the lexer and the Test file. However I
> can successfully compile them all.(In parser case, after answering
> "Yes" to the error message )
>   How can I deal with this?

Now we get to the question of whether ANTLR is the proper tool to use to 
produce a URI parser. Still, there are always better and worse ways to 
craft a concrete grammar specification that captures a given 

Is your ANTLR grammar something you could disclose to us, or is it 
proprietary? If others with more experience than you (or me) could look 
at it, they might be able to suggest ways to pare down the size of the 
resulting parser code.

>   Best wishes,
>   Al

Randall Schulz

More information about the antlr-interest mailing list