[antlr-interest] New Guy Question...

Jim Idle jimi at temporal-wave.com
Mon Jun 6 15:56:24 PDT 2011


No, that is not correct, please look at the WIKI article. The input stream
merely MATCHES in upper case, it does NOT change the input stream itself,
hence both the keywords and anything else are case preserved when you ask
for their text; that is the whole point of doing it that way. Then you
specify the tokens in the lexer using upper case only and it has the side
effect of simplifying the lexer rules as well as not creating a method
call to match every letter of every keyword (which is a bad idea even with
JIT inlining).

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Douglas Godfrey
> Sent: Monday, June 06, 2011 12:41 PM
> To: Marco Hunsicker
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] New Guy Question...
>
> When you implement case insensitive keywords, you may still want case
> sensitive identifiers.
> If the input stream does case folding, you can't use case sensitive
> identifiers.
>
> On Sun, Jun 5, 2011 at 5:58 PM, Marco Hunsicker <devel at hunsicker.de>
> wrote:
>
> > > You have to handle case insensitivity the hard way:
> > >
> > > fragment A
> > >      :    'A' | 'a';
> > >
> > >[...]
> >
> > I don't think it's a necessity to do it this way. Actually, I think
> it
> > would be better using a specialized input stream that does any
> > necessary transformation. Your mileage may vary ;)
> >
> > Cheers,
> >
> > Marco
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe:
> > http://www.antlr.org/mailman/options/antlr-interest/your-email-
> address
> >
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list