I would suggest to have a look at the example grammers on the antlr site. The java grammar does what you want.
Basicly you can do something like this:
expr : andexp;
andexpr : orexpr (AND andexpr)*;
orexpr : notexpr (OR orexpr)*;
notexpr : atom | NOT expr;
The key is, that every expression can end to be an atom.
Arne
2010-08-24 11:59:01