Re: [antlr-interest] Partial tree transformation
- On Sunday, September 8, 2002, at 05:16 AM, renyedi wrote:
> GreetingsThat is a different philosophy than the tree grammar approach.
> Suppose we have an AST generated by ANTLR. Is there a way to perform a
> transformation for only certain tree patterns without defining rules
> that lead to that pattern?
However, in old Sorcerer I had support routines that worked like fscanf
called tscant or something that let you ask for all references to trees
of a certain form. There is something similar in ANTLR, but can't
remember the name right off the top of my head.
> For example, let's say that having a Java AST generated by the java.gAh. Yes, try this class
> grammar (the one from the ANTLR example grammars) one wants to filter
> out the final modifier. Based on java.tree.g, only the "modifier" rule
> should be defined. The nodes that do not match the "modifier" pattern
> should be copied by default to the resulting AST. However, if I do
> this way, the "modifier" rule is never matched but I get an unexpected
> node error.
> Is there a way to do this?
it has a next() method that keeps looking for subtrees I think. You
are really just asking for a depth first search. Easy to add if we
don't have precisely what you need. :)
Creator, ANTLR Parser Generator: http://www.antlr.org