[antlr-interest] Rewrite separators to root nodes.
Gavin Lambert
antlr at mirality.co.nz
Mon Aug 4 14:31:41 PDT 2008
At 04:01 5/08/2008, Craig Main wrote:
>I did originally have it like this.
>I ended up struggling to get the template output to work.
>My templates are not also recursing so it get's tricky.
>
>rules
> : ^('or' a=rules b=rules) ->
>ORTEMPLATE(a.returnvalue,b.returnvalue)
> | ^('and' a=rules b=rules) ->
>ANDTEMPLATE(a.returnvalue,b.returnvalue)
> | r=rule -> RULETEMPLATE(r.returnvalue)
> ;
This is just a wild stab in the dark (because I've never actually
used StringTemplate myself), but try this instead:
rules
: ^('or' a=rules b=rules)
-> ORTEMPLATE(a.st,b.st)
| ^('and' a=rules b=rules)
-> ANDTEMPLATE(a.st,b.st)
| r=rule -> RULETEMPLATE(r.returnvalue)
;
If that doesn't work, then maybe someone else will be able to help
you more :)
More information about the antlr-interest
mailing list