[antlr-interest] cretae the inverse of a rule

Bart Kiers bkiers at gmail.com
Fri Oct 15 07:08:13 PDT 2010


On Fri, Oct 15, 2010 at 3:39 PM, Remi Marechal <remi.marechal at gmail.com>wrote:

> if i create a rule like
>
> LETTER: 'a'..'z' ;


With the '~' (tilde):

NON_LETTER
  :  ~LETTER
  ;

Note that the negation only works on single characters (or lexer rules that
match a single character). For example, you can't negate the rule:

FOO
  :  'foo'
  ;

Regards,

Bart.


More information about the antlr-interest mailing list