[antlr-interest] Tree filter/rewrite wildcards

Joseph Cottam jcottam at umail.iu.edu
Fri Apr 9 06:38:32 PDT 2010


*Using rest* is closer, but still not what I need (and seems to behave
oddly as well).
The rest* inserts only the last item matched.

topdown: ^(f=FUNCTION rest=.*) -> ^(FUNCTION NEW_NODE $rest*);*
Tree: ^(FUNCTION OLD1 OLD2 OLD3 OLD4)
Yields: ^(FUNCTION NEW_NODE OLD4)

-JC

> Did you try:
>
> -> ^(FUNCTION NEW_NODE $rest*);
>                           ^
>
> Jim
>
>* -----Original Message-----*
>>* From: antlr-interest-bounces at antlr.org <http://www.antlr.org/mailman/listinfo/antlr-interest> [mailto:antlr-interest-*
>>* bounces at antlr.org <http://www.antlr.org/mailman/listinfo/antlr-interest>] On Behalf Of Joseph Cottam*
>>* Sent: Wednesday, April 07, 2010 11:19 AM
*>>* To: antlr-interest at antlr.org
<http://www.antlr.org/mailman/listinfo/antlr-interest>
*>>* Subject: [antlr-interest] Tree filter/rewrite wildcards
*>>*
*>>* Using V3.2...
*>>*
*>>* With grammar options:
*>>*   filter = true;
*>>*   output = AST;
*>>*
*>>* topdown: ^(f=FUNCTION rest=.*) -> ^(FUNCTION NEW_NODE $rest);
*>>*
*>>* Yields: ^(FUNCTION NEW_NODE)
*>>*
*>>* Regardless of the contents matched in $rest.  Put another way, it seems
*>>* to** match, but not output things caught up in a wildcard.
*>>*
*>>* Is that the defined behavior?
*>>*
*>>* How can I match number of anythings in tree
*>>*
*>>* I have also tried:
*>>*    rest+=.* (no change to behavior)
*>>*    Rule called 'rest' with just a .* in it (does not compile, tries to
*>>*      catch* *an exception that can't ever be thrown).
*>>*
*>>*
*>>* -Joseph Cottam
*


More information about the antlr-interest mailing list