[antlr-interest] Path-based template selection
Richard Clark
rdclark at gmail.com
Sun Jul 29 16:29:10 PDT 2007
On 7/29/07, Ted Villalba <ted.villalba at gmail.com> wrote:
> a : b ... //if I try to set a scope field here
> | c
> b: c
> c: CHAR call template1 //it will not exist here
That makes sense, as you're trying to set the field after rule b
returns. How about this:
a
scope { boolean usesB; }
: b
| c
;
// fragment marker not required, but keeps you from accidentally
calling this directly
// in the code that uses the parser.
fragment
b: { $a::usesB = true; } c ;
fragment
c: CHAR call {$a::usesB ? ...
...Richard
More information about the antlr-interest
mailing list