[antlr-interest] How to add logic for StringTemplate selection?
Terence Parr
parrt at cs.usfca.edu
Mon Jul 23 09:38:27 PDT 2007
a : ... -> {...}? blort
-> blech
;
Ter
On Jul 23, 2007, at 9:31 AM, Ted Villalba wrote:
> Hi,
>
> I'm wondering if this is possible, or if I should be trying to
> approach it differently. Any help would be appreciated.
> I want to be able to select the proper string template, based on
> the results of some function calls, passing values from other rules.
> For instance, I have these tree grammar rules( reduced here for
> simplicity):
>
> field : ^('=' tag value) -> template1(tag={$tag.text},value=
> {$value.st})
> ;
>
> value : ^(operator terms value) -> template2(op={checkNotOperator
> ($operator.st)},terms={$terms.st}, values={$value.st})
> ;
>
> I want to be able to select the template for value, depending on a
> property of "tag" in the field rule.
> I need to somehow pass the value of $tag from the value rule, and
> depending on the output of that call, select the correct template.
> The pseudocode being something like:
>
> value : ^(operator terms value) if (getDataProp($tag.text) == X) -
> > templateX
> else if getDataProp
> ($tag.text) == Y -> templateY
>
>
> What is the best way to handle this?
>
> Thanks a lot for any help.
> Ted
>
More information about the antlr-interest
mailing list