[antlr-interest] Re: JavaTreeParser? What does it do?

lgcraymer lgc at mail1.jpl.nasa.gov
Tue Apr 29 17:28:55 PDT 2003


Micheal--

Visitors are useful for generic processing, such as printing out tree 
structure or "change all AST nodes of type FOO to BAR".  They are good 
for "shotgun" processing when you have no a priori knowledge of tree 
structure.

Tree walkers require knowledge of tree structure, but give much finer 
control.  For specific problems, the fine control is much to be 
preferred--even when you start with the thought that "all FOOs are 
alike" you soon find that what you really want is "all FOOs are alike, 
except when they follow BAR".

Now that I have automatic tree grammar generation (coming soon to 
ANTLR 3--I am forbidden from releasing the code into the public 
domain, so I can't release it for ANTLR 2) implemented, I don't have 
much use for Visitors except for tree printing.

--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