[antlr-interest] tree transformation question (if-elif-else ->
if-else)
Klaas Hofstra
antlr at klaashofstra.com
Fri Jul 1 09:51:48 PDT 2005
On Friday 01 July 2005 17:52, Bryan Ewbank wrote:
> I use a recursive grammar instead, drilling into the elif_s production
> to build the tree. It produces the tree you want, and recognizes the
> same language (if I wrote it correctly):
>
> if_s : "if"^ expr statements ( elif_s )? ;
> elif_s : "elif"^ expr statements ( elif_s | else_s )? ;
> else_s : "else"^ statement ;
The recursive grammar did the trick, thanks!
Klaas
More information about the antlr-interest
mailing list