[antlr-interest] Empty complement set?

Bart Kiers bkiers at gmail.com
Wed Mar 31 03:01:36 PDT 2010


On Wed, Mar 31, 2010 at 11:47 AM, Anton Bychkov <bychkov.anton at gmail.com>wrote:

> ...
> There is also a strange thing in rule view, it looks like antlr does
> not see LParen and RParen in twiddle operator.
> I attached screenshot with it.
>

Ah, I see. There are no other tokens than '(' and ')' defined, so
~(LParen|RParen) is wrong. Try adding a "fall through" DOT in your lexer
grammar:

skipper
       @init {
               int braceCount = 1;
       }
       : (
       LParen
       {
               braceCount ++;
       }
       | RParen
       {
               braceCount --;
               if(braceCount == 0)
               {
                       LTOKEN = EOF_TOKEN;
               }
       }
       | Other
       ) *
       ;

LParen : '(' ;
RParen : ')' ;
Other  :  .  ;


More information about the antlr-interest mailing list