[antlr-interest] How do you use template output with backtracking on in a validating semantic predicate?
Terence Parr
parrt at cs.usfca.edu
Mon Jul 2 11:01:43 PDT 2007
You can also use a predicate in front of the template
-> {...}? template
-> {...}? template2
-> template3
Ter
On Jul 2, 2007, at 10:54 AM, Richard Clark wrote:
> OK, I see what you're doing: selecting a different output template
> based on type info in your symbol table. The trick is to change the
> piece that creates your template. Try this:
>
> ^('==' left=expression right=expression) ->
> { String template = (isString($left.st} && isString($right.st)) ?
> "stringEqual" : "equal";
> templateLib.getInstanceOf(template,
> new STAttrMap().put("left", left.st).put("right",
> right.st);
> }
>
> The secret is the "-> {...}" bit. It says "I'll construct the string
> template myself, thank you."
>
> ...Richard
More information about the antlr-interest
mailing list