[antlr-interest] caseSensitiveLiterals

Ric Klaren klaren at cs.utwente.nl
Thu Jan 8 06:58:01 PST 2004


On Thu, Jan 08, 2004 at 02:19:14PM -0000, abellyahoo wrote:
> I am confused by the "caseSensitiveLiterals" option.  When I added it
> to my parser, antlr compains with:

This is a lexer only option.

> I can stick the options in the lexer, but will my resulting system 
> still treat literals as non case-sensitive when they are entered as 
> strings in the parser?

For example if you have a rule like this:

IDENTIFIER options { testLiterals = true; }:
 ( 'a' .. 'z' | 'A' .. 'Z' | '_' )
 ( 'a' .. 'z' | 'A' .. 'Z' | '0'..'9' | '_' | '#' )*
;

The token returned will have the same case as was entered by the user yet
when checking against the literals table (literals as specified in the
tokens section) the case is ignored. If you need the text downcased or in
upper case you can use $setText to set the required return string.

> If so, this is non-intuitive.  The 
> documentation says that the option is allowed in a grammar - is this 
> the same as a parser?

Looking at the docs it should mean parser. I'm not sure why it lists
grammar as one of the options for caseSensitiveLiterals, AFAIK it is only
used inside the lexer.

> P.S. - The documentation looks like it could use a little work 
> (fixing typos if nothing else).  Is there any interest in getting 
> some of this done?

If you want to invest some time in this it would probably be very welcome.
You might want to check with Terence I recall him mentioning that he wanted
to change the documentation format or something. Structurally the docs are
not really ideal.

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Chaos is found in greatest abundance wherever order is being sought.
  --- Terry Pratchet


 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

Your use of Yahoo! Groups is subject to:
 http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list