[antlr-interest] Re: Reparsing a subtree. Or another solution?

Joan Pujol joanpujol at gmail.com
Tue Nov 16 15:12:44 PST 2004


A lot of thanks for your excellent reply.

On Tue, 16 Nov 2004 22:11:06 -0000, lgcraymer <lgc at mail1.jpl.nasa.gov> wrote:
> 
> 
> In general, there are three approaches to this type of problem.
> 1.)  Multiple passes over the full tree--that has the advantage of
> clarity, and the navigation overhead is usually minimal.
Well, I already know this alternative, but I found it very "hard" if I
only need the reparsing for one check, and only in very small parts of
the AST.
Currently I use two pass, one for type discovering (I have forward
references) and the second for type checking an others. And if I can't
I don't want to put a third pass.
 
> 2.)  Duplicate the subtrees of interest, and have different walkers
> (distinguished by actions, not by tree syntax) for the duplicates.
> This may have maintainability advantages.
I can't understand this alternative well.
Please, can you put an small example?

> 3.)  For the second pass, walk the tree in an action.  That is:
> 
> subTreeTest
>     :
>     #( a:A B C ) { secondPass(#a); }
>     ;
> 
> secondPass
>     :
>     #( A B C )
>     ;
The third aproach seems very nice to my needs.

A lot of thanks,


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list