[antlr-interest] Case sensitive literals

Alexey Demakov demakov at ispras.ru
Wed Nov 3 08:41:02 PST 2004


antlr-2.7.4/metalang.html#_bb2:

In parser rules, strings represent tokens, and each unique string is assigned a token type. However, ANTLR does not create lexer
rules to match the strings. Instead, ANTLR enters the strings into a literals table in the associated lexer. ANTLR will generate
code to test the text of each token against the literals table, and change the token type when a match is encountered before handing
the token off to the parser.

lexer.html#Lexical_Analysis_with_ANTLR Case sensitivity

Case sensitivity for literals is handled separately. That is, set lexer option caseSensitiveLiterals to false when you want the
literals testing to be case-insensitive. Implementing this required changes to the literals table. Instead of adding a String, it
adds an ANTLRHashString that implements a case-insensitive or case-sensitive hashing as desired.

Regards,
Alexey

----- Original Message ----- 
From: "Maassen, H.A.M." <H.A.M.Maassen at student.tue.nl>
To: <antlr-interest at yahoogroups.com>
Sent: Wednesday, November 03, 2004 5:20 PM
Subject: [antlr-interest] Case sensitive literals


> Hello,
>
> When defining literals in the parser-grammar (stat: "if" expr "then" stats "endif";) the generated parser will be case sensitive,
and the caseSensitive option is only available for lexers.
>
> Do I need to define those literals in the lexer after all or is there a way to make the parser case insensitive that I've
overlooked?
>
> Thanks for your help,
>                  Harald Maassen
>
>
>
> Yahoo! Groups Links
>
>
>
>
>




 
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