[antlr-interest] just added $FIRST(rule) and $FOLLOW(rule)
Terence Parr
parrt at jguru.com
Sat Sep 14 23:02:55 PDT 2002
Folks,
Extending Ric's work, I have made $FIRST and $FOLLOW computations
available to actions and exception actions. If you omit the arg it
assumes current rule. Note that this returns the name of a bitset you
can use to test or pass to consumeUntil().
a : A {$FIRST(a); $FIRST} B
exception
catch [MyExc e] {
foo = $FOLLOW(a);
consumeUntil($FIRST(c));
}
;
You can use for a variety of things:
if ( $FIRST(a).member(LBRACK) ) {...}
Ter
PS Ric, note that I've moved the computation into the two action.g
files (moving from code generators; cleaner).
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list