[antlr-interest] Advanced matching in Tree Parsers
Bryan Ewbank
ewbank at gmail.com
Fri Apr 15 12:28:39 PDT 2005
Another option is to use syntactic predicates and recursion...
// this is the entry point
root:
( (pattern) => takeaction
|
// first instance of root is "down"; second is "to the right"
#(. (root)? ) (root)?
);
pattern:
#(A B)
;
take_action:
#(A #(B .... ) )
{ ## = kaboommmmmm; }
;
> What I really want to do is match patterns against the tree. The difference
> to how ANTLR is handling this is that I just want to check if the pattern
> fits, and if it fits execute some action (e.g. rewrite the tree). If the
> pattern is not matched I want to continue recursively through the tree
> (recursion, e.g. whole new expressions, can occur only in well defined
> places, don't have to match everything).
More information about the antlr-interest
mailing list