[antlr-interest] Re: JavaTreeParser? What does it do?
lgcraymer
lgc at mail1.jpl.nasa.gov
Tue Apr 29 16:10:23 PDT 2003
Micheal--
The Visitor pattern is good when you do not have context-dependent
operations on AST nodes. One example of this is in printing
trees--all that you need to know is depth (for indenting) and AST node
properties. Another is "change all AST nodes of type FOO to type BAR
in my tree". I find Visitors convenient for quick-and-dirty tools
that work on any tree that I can construct.
Tree walkers give you finer control, but require knowledge of tree
structure and force you into node-by-node processing (if you want do
do "action()" whenever you encounter a FOO node, then you will have to
insert " { action(); }" everywhere in your tree grammar that you
specify FOO).
--Loring
--- In antlr-interest at yahoogroups.com, "micheal_jor" <open.zone at v...>
wrote:
> > Tree parsers do the "getFirstChild()" and "getNextSibling()" for
> > you as well as matching a tree pattern--the whole idea is to
extend
> > the ANTLR parsing concept to trees. About the only case where you
> > might want to walk a tree without a tree parser is when
> the "Visitor"
> > pattern is appropriate.
>
> Hi Loring,
>
> Do you have any guidelines/advise on choosing between an
architecture
> using the Visitor pattern or TreeParsers?
>
> Having made full support of hetero-ASTs a priority in the C# codegen
-
> to support the use of Visitors with ANTLR-built trees - we now
often
> need to choose between both architectures.
>
> Cheers,
>
> Micheal
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list