[antlr-interest] Re: Recognize letters

chr_mathis chriss007 at gmx.de
Wed Oct 13 00:08:31 PDT 2004




Dear Fernando Salg,

You should use the unicode character '\u00E1' (which correspondes to
'á') in a lexer rule like this:

CHARS :
    ('\u00E1' /* | others to follow */ )
  ;

The lexer is now able to recognize the chracter.

If I got the documentation right, the lexer derives the character
vocabulary automatically from the used characters in the lexer rules.
 With the option 'charVocabulary' you can override the derived
vocabulary. But even if you use

charVocabulary='\3'..'\377' | '\u00E1';

(standard ASCII enhanced with your special character) you have to
define a lexer rule like the one above. The 'charVocabulary' option
shows its effect, when you use the negation operator '~' to define a
character class, like in the example from the documentation:

STRING: '"' (~'"")* '"';

Hope this helps,
Christian.



--- In antlr-interest at yahoogroups.com, "Fernando Salgueiro"
<fernandosalg at h...> wrote:
> 
> 
> 
>  I have a problem. How can resolve the problem to recognize the letter 
>   "á" ? 
>  
>  I try put charVocabulary = '\003'..'\377'; ( java.g) 
>   And produce a problem to recognize letter of type "á" ? 
> 
>   Error: 
> parser exception: Funcionßrio.java:63:10: unexpected char: 0xE1
> Funcionßrio.java:63:10: unexpected char: 0xE1
>         at JavaLexer.nextToken(JavaLexer.java:373)
>         at antlr.TokenBuffer.fill(TokenBuffer.java:69)
>         at antlr.TokenBuffer.LA(TokenBuffer.java:80)
>         at antlr.LLkParser.LA(LLkParser.java:52)
>         at JavaRecognizer.field(JavaRecognizer.java:1235)
>         at JavaRecognizer.classBlock(JavaRecognizer.java:1132)
>         at JavaRecognizer.classDefinition(JavaRecognizer.java:512)
>         at JavaRecognizer.typeDefinition(JavaRecognizer.java:329)
>         at JavaRecognizer.compilationUnit(JavaRecognizer.java:219)
>         at Main.parseFile(Main.java:72)
>         at Main.doFile(Main.java:55)
>         at Main.main(Main.java:25)
> 
> 
>  How can i resolve ? 
>   (Send me the response to fernandosalg at h... )
>  Thanks , 
> 
>   Fernando Salg








 
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