As stated in the link you provided, there is nothing you have to do to get
this functionality. But 'identifier' should be a lexer rule. I guess your
grammar should be something like this:

 

APPLY                   :               'apply';

BROWSE              :               'browse'

.

 

ID            :               ('A'..'Z' | 'a'..'z') ('A'..'Z' | 'a'..'z' |
'0'..'9' | '_')*;

                

Now, if you write a rule like

 

r              :               ID;

 

only ID that is not a keyword will match this.

 

Am I oversimplifying the problem. Did I miss something?

 

Cheers, Indhu

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Avid Trober
Sent: Thursday, June 11, 2009 9:10 AM
To: [email protected]
Subject: [antlr-interest] Excluding keywords

 

I saw something close to my problem on the wiki,
http://www.antlr.org/pipermail/antlr-interest/2006-June/016563.html

 

But, I've got an "extra rule", filter.  Must I resort to an action, or is
there a way to do this purely in the grammar file?

 

 

filter : // identifier, but *not* a keyword

              ;

    

 

keyword :  APPLY

              | BROWSE 

              | CLOSE

              | OPEN

        ;

 

identifier : ('A'..'Z' | 'a'..'z') ('A'..'Z' | 'a'..'z' | '0'..'9' | '_')*

             ;

 

 

 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to