[antlr-interest] Need help with lexer rules

John B. Brodie jbb at acm.org
Mon Aug 15 09:58:38 PDT 2005


Sven Efftinge wrote:
>I've the following lexer rules :
>
>// terminals (guillemots '<<' & '>>')
>LG            : '\u00ab';
>RG            : '\u00bb';
>
>// any char but not antlr special, LG and RG
>protected VOCAB :
>    ('\3'..'\u00aa'|'\u00ac'..'\u00ba'|'\u00bc'..'\u00ff')
>;
>
>// template text '>> Bla text here <<'
>TEXT :
>  RG (VOCAB)* LG
>;
>
>It scans
>
>'>> Bla text <<' => TEXT , EOF
>'>>'                   => RG, EOF
>
>but cannot scan
>'>>    '            
>I want the scanner to evaluate to RG, WS (which is skipped), EOF
>But it stucks in the TEXT rule : "line 1:5: expecting '«', found '<EOF>'"
>
>Can someone give me a hint?

My unicode knowledge is rather weak, sorry.

But doesn't your VOCAB lexer rule include WS and NOT skip WS? (WS -
e.g. blank - is '\u0040' right?)

Hope this helps...
   -jbb


More information about the antlr-interest mailing list