[antlr-interest] Grammars with too many keywords?

Vadim Tropashko vadimtro at yahoo.com
Thu Mar 1 15:19:34 PST 2007


OK, handling keywords as identifiers turned out to be
FAQ question. There is another issue with big grammar
though. The size of mTokens() method appears to grow
quadratically with the number of keywords. At some
point it is overflowing JVM java method length
constraint. At 380 rules I'm already getting

"Exceeding 65535 bytes java method limit."

and I have 200 more rules to go.

BTW, what is the biggest antlr showcase?  





--- Vadim Tropashko <vadimtro at yahoo.com> wrote:

> The grammar that I'm working on allows keywords as
> identifiers. For example, "A" is a keyword, as a
> part
> a part of very reasonable declaration: 
> 
> set_predicate:
>   is_prefix d_o_tNOTd_o_t 'A' 'SET'
> ;
> 
> Naturally, the "A" can be identifier as well:  
> 
> IDENTIFIER: 
>          ('a'..'z'|'A'..'Z') ( 'a'..'z'|'A'..'Z'
> ...)*;
> 
> So whenever I feed into the parser text like this:
> 
> A := ...
> 
> I'm getting 
> 
> mismatched input 'A' expecting IDENTIFIER
> 
> Is there a standard way to approach this problem?
> Preferably, the solution should contain as little
> redundancies as possible. For example, I could
> collect
> all the keywords and declare them as such, but do I
> really have to? Isn't grammar terminal symbol
> already
> assumed to be a keyword?  
> 
> 
>  
>
____________________________________________________________________________________
> Looking for earth-friendly autos? 
> Browse Top Cars by "Green Rating" at Yahoo! Autos'
> Green Center.
> http://autos.yahoo.com/green_center/
> 



 
____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time 
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news


More information about the antlr-interest mailing list