[antlr-interest] How can I ignore reserved words in certaincases ?

Terence Parr parrt at cs.usfca.edu
Thu Nov 30 10:12:08 PST 2006


On Nov 30, 2006, at 9:44 AM, VAUCHER Laurent wrote:

> Isn't there a performance penalty in this case?

Most definitely.

> I mean, almost all tokens look like IDs, so the parser is forced to  
> use the predicates to choose the right rule. There is no  
> possibility to precompute jump-tables (or whatever you call them).

The other alternative is to do

identifier : KEY1 | KEY2 | ... | ID ;

which is a set comparison and should be faster.

Ter
>
>
> Laurent.
>
>
> -----Message d'origine-----
> De : antlr-interest-bounces at antlr.org [mailto:antlr-interest- 
> bounces at antlr.org] De la part de Terence Parr
> Envoyé : 30 November 2006 18:17
> À : ANTLR Interest
> Objet : Re: [antlr-interest] How can I ignore reserved words in  
> certaincases ?
>
> Hi.  An example from the book on predicated LL(*) parsing:
>
> http://www.antlr.org/wiki/pages/viewpage.action?pageId=1741
>
> Ter
>
>



More information about the antlr-interest mailing list