[antlr-interest] Predicate Variable
Richard Clark
rdclark at gmail.com
Fri Jul 27 23:47:27 PDT 2007
Sounds like a good place for a scope:
// WARNING: Written at 15 minutes to midnight, from memory, see ANTLR book
// for exact syntax. Void where prohibited, your mileage may vary, if
a rash occurs
// see your doctor, etc. etc. etc.
scope context {
char predicateClass;
};
programA
scope context;
@init { $context::predicateClass='A'; }
: (stmtA SCOLON)*
;
stmtA
: s=while
| s=foo
;
programB
scope context;
@init { $context::predicateClass='B'; }
: (stmtB SCOLON)*
;
stmtB
: s=while
| s=bar
;
while
scope context;
: "while" expr "do"
(
{$context::predicateClass == 'A'}? predA
| predB
)
"od"
;
...Richard
More information about the antlr-interest
mailing list