[antlr-interest] How to add logic for StringTemplate selection?
Ted Villalba
ted.villalba at gmail.com
Mon Jul 23 09:31:07 PDT 2007
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070723/db8090bf/attachment.html
More information about the antlr-interest
mailing list