[antlr-interest] Advanced matching in Tree Parsers

Monty Zukowski monty at codetransform.com
Fri Apr 15 06:19:36 PDT 2005


Martin Probst wrote:

> 1) Do it yourself
>    e.g. by writing java code to traverse and match the tree. Possible, but
> creates a lot of ugly code. Could also create a little language to write the
> tree patterns in, but this really seems like reinventing the ANTLR tree
> parser wheel.

There are some methods in BaseAST like findAll(AST) and 
findAllPartial(AST) which will match trees and return you a list of 
trees matched.  You may want to change it so it only matches on type and 
ignores the text.  Once you have your list of trees that match, feed 
them to your translator.

Can you do your work with those methods?

Monty


More information about the antlr-interest mailing list