[antlr-interest] Puzzled by leading dot

Alexey Demakov demakov at ispras.ru
Tue Mar 15 22:56:45 PST 2005


The problem is not in escaping '.'.
Do you have rules to skip whitespaces in Lexer?
You have to instruct ANTLR what to do with them.
Look in docs & example grammars for rules like this:

protected
NL : (   {LA(2) == '\n'}? '\r' '\n'
       | '\r'
       | '\n'
     )
     { newline(); }
   ;

WS : ( options { greedy = true; } :
          ' '
       | '\t'
       | '\f'
       | NL
     )+
     { _ttype = Token.SKIP; }
   ;

Regards,
Alexey

-----
Alexey Demakov
TreeDL: Tree Description Language: http://treedl.sourceforge.net
RedVerst Group: http://www.unitesk.com


----- Original Message ----- 
From: "Juergen Weber" <weberjn at yahoo.com>
To: <antlr-interest at antlr.org>
Sent: Tuesday, March 15, 2005 8:19 PM
Subject: [antlr-interest] Puzzled by leading dot


> Thanks Alexey,
> 
> I changed to 
> 
> ...extends Lexer;
> 
> DOTSE:
> 
>    ".SE"
> ;
> 
> But still
> 
> Exception in thread "main" line 1:4: unexpected char:
> ' '
> 
> Do I have to quote the dot? How?
> 
> Thanks,
> Juergen




More information about the antlr-interest mailing list