[antlr-interest] CommonTree & Tree grammar versus DIY
Gerald Rosenberg
gerald at certiv.net
Thu Aug 21 14:15:17 PDT 2008
At 01:21 PM 8/21/2008, Gavin Lambert wrote:
>At 14:42 21/08/2008, Gerald Rosenberg wrote:
> >For ad-hoc AST changes, the better approach, at least
> >conceptually, is to implement a low-level structural
> >modification API with methods to "find" a node based on
> >parameter values, and to similarly create, copy, insert and
> >delete nodes.
>
>You can write a tree grammar to do the find (or just do it manually,
>depending on how flexible your find requirements are), and use the
>TreeAdaptors for modifying the tree structure afterwards...
Absolutely. But doing so by hand is a fragile mess. With tree
walkers, it is still a mess. Since a tree grammar will all of the
rewrites listed in the grammar, you will need to have a separate
grammar for each node type and for each operation. Orchestration is clumsy.
More information about the antlr-interest
mailing list