[antlr-interest] Fwd: Empty complement set?
Bart Kiers
bkiers at gmail.com
Wed Mar 31 03:03:41 PDT 2010
---------- Forwarded message ----------
From: Bart Kiers <bkiers at gmail.com>
Date: Wed, Mar 31, 2010 at 12:01 PM
Subject: Re: [antlr-interest] Empty complement set?
To: antlr-interest at antlr.org
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 : . ;
Or like this:
LParen : '(';
RParen : ')';
Other : ~(LParen | RParen);
More information about the antlr-interest
mailing list