[antlr-interest] How do you use template output with backtracking on in a validating semantic predicate?

William Halliburton whalliburton at gmail.com
Fri Jun 29 17:23:48 PDT 2007


How do I use the the output of a stringtemplate in predicates while
backtracking? I believe antlr only completes the template for the final path
and not for the subsequent failures.

Also, maybe this is the wrong approach and any other method would be most
appreciated.

Below is a simplification of my current project to demonstrate the problem.

I have a java function that takes a stringtemplate and checks its string
against a list. If backtracking is turned on then it receives a null, while
I need to to actually receive the template of bar.

Thank you.

----

tree grammar testing;

options {
    output=template;
    backtrack=true;
}

foo : ^(T1 a=bar) {myJavaFunction($a.st)}? -> {%{"asdfasdf"}}
    | alternative -> {$alternative.st}
    ;

----

Thank you all for this smart system.

William Halliburton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070629/73b4c8ec/attachment.html 


More information about the antlr-interest mailing list