[antlr-interest] How to implement case insensitive keyword inantlr3

Jim Idle jimi at temporal-wave.com
Fri Aug 17 08:51:59 PDT 2007


For C, there is a function/method available on the input stream:

 

input->setUCaseLA(input, ANTLR3_TRUE);

 

Which causes all the tokens to be matched against UPPER CASE, so you specify your keywords in upper case and it will match any mixed case, while preserving the case for the actual text of the token.

 

In java (and I believe this was adapted for C# easily, but not sure about the other targets, see:

 

http://www.antlr.org/pipermail/antlr-interest/2007-January/019008.html

 

C# example at:

 

http://www.antlr.org/wiki/pages/viewpage.action?pageId=1782

 

Again, you specify your keywords in UPPER case only.

 

Jim

 

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Hub Dog
Sent: Friday, August 17, 2007 6:49 AM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] How to implement case insensitive keyword inantlr3

 

Thank all friends very much for your quick answer.

best regards
ma lifang 

On 8/17/07, 文少华 <shaohua.wen at gmail.com > wrote:

You can check thread : ANTLR3 with -Xmultithreaded problem? 
In the attachment of that message, I've implemented a keyword case insensitive grammar.
but for other IDs are case sensitive. 

BR.Holy

 

On 8/17/07, Hub Dog < hubdog at gmail.com <mailto:hubdog at gmail.com> > wrote:

Dear Friends,

        I am just porting an antlr v2 project to antlr3.The keyword of language is  case insensitive.In the antlr v2, there is a caseSensitiveLiterals option for lexer.
But it seems there is not such an option in v3. Does someone know how to implement case insensitive keyword  in antlr3 . 


best regards
ma lifang

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070817/30d71dae/attachment-0001.html 


More information about the antlr-interest mailing list