[antlr-interest] invoke subtemplates on multivalue attribute
Jim Idle
jimi at temporal-wave.com
Thu Apr 30 08:12:21 PDT 2009
Florian Barth wrote:
> 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:
>
>
> I try to map the conditional statement to StringTemplate with the
> following rule:
> cond : ^(IF
> ^(CONDITION conds+=condExpression)
> ^(THEN thens+=expression)
> ^(ELSEIF
> ^(conds+=CONDITION condExpression)
> ^(thens+=THEN expression)
> )*
> ^(ELSE else=expression)?
> )
> ->
> conditional(conditions={$conds.st},thens={$thens.st},else={$else.st})
> ;
>
> The first problem I'm running into is that '?' and '*' seem to be not
> allowed in tree grammars.
>
You are confusing the () that mark the node with those that collect a
group. You need:
(
^(TT x x x)
)*
Jim
More information about the antlr-interest
mailing list