[antlr-interest] invoke subtemplates on multivalue attribute

Michael micha-1 at fantasymail.de
Thu Apr 30 03:12:44 PDT 2009


Am Thursday 30 April 2009 11:25:28 schrieb Florian Barth:
> Hi everyone!
> I'm writing a language transformator based on AntLR and I'm running
> into some problems:
> In order to transform conditional statement my parser constructs the
> following AST:


> The first problem I'm running into is that '?' and '*' seem to be not  
> allowed in tree grammars

I think you must write it with parens like:   (^(NODE foo))*   
try this:

cond    :       ^(IF
                        ^(CONDITION conds+=condExpression)
                        ^(THEN thens+=expression)
                        (^(ELSEIF
                                ^(conds+=CONDITION condExpression)
                                ^(thens+=THEN expression)
                        ))*
                        (^(ELSE else=expression))?
                )


 Michael


More information about the antlr-interest mailing list