[antlr-interest] newbie question

Rolf Schumacher mailinglist at august.de
Sat Apr 10 03:20:48 PDT 2004


Thx, missed that bit.

Rolf

p.s.--------------
this works now
- -------------------
class WikiParser extends Parser;

text : ( LINE )+
;

class WikiLexer extends Lexer;
options { charVocabulary = '\u0000' .. '\u00ff'; }
//if you put '\uffff' here instead "it would wind up generating huge
lexers"

protected
LINECHAR
:
~'\n'
;
LINE
:
(LINECHAR)+ {System.out.println(getText());}
;
WS : '\n'
{ _ttype = Token.SKIP; newline(); }
;

Terence Parr wrote:

>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
>
>
>
> 
>
>
>
>  
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 1730 bytes
Desc: S/MIME Cryptographic Signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20040410/0ed13bba/smime.bin


More information about the antlr-interest mailing list