[antlr-interest] Examining characters in lexer

Johannes Luber jaluber at gmx.de
Thu Mar 12 14:00:19 PDT 2009


Dennis Brothers schrieb:
> Is there a special symbol or method that returns the character about  
> to be scanned?  In order to handle a variety of (natural) languages,  
> I'd like to use Unicode categories to detect various character types  
> (particularly letters).
> 
> I want to do something like
> 
> fragment LETTER : { Char.IsLetter( $char ) } ?=> . ;
> 
> where $char is the next character to be scanned and Char.IsLetter() is  
> a .NET method that examines a character's Unicode category and returns  
> true if it's one of the letter categories.
> 
> While I'm at it, is it legal to use a gated predicate like the above  
> in a lexer?
> 
> Thanks -
>      - Dennis Brothers

Try LA(1) or input.LA(1).

Johannes


More information about the antlr-interest mailing list