[antlr-interest] forcing parenthesis (no precedence)

Jim Idle jimi at temporal-wave.com
Wed Jul 15 08:17:55 PDT 2009


hakan eryargi wrote:
> hello,
>
> i want to create a grammar for simple expressions and AND, OR
> statements. AND's and OR's have no precedence, so i want the user to
> explicitly use parenthesis if AND's and OR's mixed. how can i define
> such a grammar ?
>   
Just steal the expression tree from something like Java.g, remove the 
things you don't need and make AND and OR tokens the same precedence in 
the same way that '+' and '=-' are.

In general stealing rules from the example grammars (see the download 
section) will get you a long way!

Jim


More information about the antlr-interest mailing list