[antlr-interest] Re: Understanding error: Label 'XX' has already been defined
lgcraymer
lgc at mail1.jpl.nasa.gov
Tue Sep 24 11:51:08 PDT 2002
Ter--
PCCTS allowed reuse of labels on AST nodes. That was a useful (but
undocumented) feature which helped to make grammars more readable--you
could attach a common action to one of a set of alternative AST nodes
rather than having to duplicate the action for each alternative (as
can be seen from Dimitrey's example). To accomplish the same thing in
ANTLR 2, you have to add an AST variable declaration in a rule-level
action and add assignment code to each alternative as in
{ AST a; }
( a1:FOO { a = a1; }
| a2:FOO { a = a2; }
) { a.setType(COMMON); }
before you can specify a common action for a set of alternatives.
It would be nice to bring back AST label reuse.
--Loring
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list