[antlr-interest] newbie question

Terence Parr parrt at cs.usfca.edu
Fri Apr 9 10:02:18 PDT 2004


On Apr 9, 2004, at 2:18 AM, Rolf Schumacher wrote:

> Even though I solved my problem I'd like to be able to understand 
> 'why':
>
> Why this rule does not work?:
>
> LINECHAR: ~'\n';
>
> while this is working:
>
> LINECHAR: '\u0000'..'\u0009' | '\u000b'..'\uffff';
>
> I would expect identical behavior from both lexer rules.
> The answer must be simple, though I read several days thru the docs
> and could not find it. Can you help me?

Hi Rolf,

You need to specify a charVocabulary option so that the "not" operator 
makes sense. :)

Terence

> Rolf
>
> p.s. ---------------
> The full story: this works:
> --------------------
> class WParser extends Parser;
> text    :   ( LINE )+ ;
>
> class WLexer extends Lexer;
> protected
> LINECHAR:   '\u0000'..'\u0009' | '\u000b'..'\uffff'
>          // putting ~'\n' here does not work, why??
>      ;
> LINE    :   (LINECHAR)+ {System.out.println(getText());} ;
> WS      :   '\n' { _ttype = Token.SKIP; newline(); } ;
>
>





 
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