[antlr-interest] How do you use template output with backtracking on in a validating semantic predicate?
Richard Clark
rdclark at gmail.com
Mon Jul 2 10:54:53 PDT 2007
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