[antlr-interest] Re: manual AST construction: what am I doing wrong?

antlrlist antlrlist at yahoo.com
Tue Jun 17 10:20:20 PDT 2003


I just want to confirm that heterogenous ASTs work very well in java 
mode (even if there are some tricks to know, like only modifying ## 
at the ending action of each rule :| ).

One of the coolest things I've done with them is override toString() 
adding specific information that could be browsed on an ASTFrame. 
Gorgeous.

Enrique.

--- In antlr-interest at yahoogroups.com, Ric Klaren <klaren at c...> wrote:
> Hi,
> 
> On Mon, Jun 16, 2003 at 05:05:50PM +0200, Jorge Scandaliaris wrote:
> > Yes, I have a single AST type, but I was thinking in moving to
> > heterogeneous AST (I have defined my nodes to contain all info I 
could
> > possibly come across in the grammar, but they are 90% of the time 
left
> > empty). I guess for the moment I'll lose in efficiency until I 
get this
> > going, and more now that you point this out.
> > It seems it's no so common to use this approach, eh?
> 
> Heterogenous AST's are some of the more fragile things inside 
ANTLR. I
> would like to use them maybe myself but I'd rather wait with that 
untill a
> few things inside ANTLR are rewritten. The interface between antlr 
and the
> module parsing the actions for the specific target language is not
> something that would go for a software engineering award.
> 
> Also you can do a lot of things wrong depending on the layout of 
your
> project. If you go with it be very aware of:
> 
> - How import/exportVocab work (and all the related caveats in build 
orders)
> - How to register all node types with the astFactory and make sure 
all things
>   use the same factory.
> - How to read ANTLR's generated code (this never hurts) You may 
have to check
>   the generated code for actions quite often to work around things 
>   the action parser cannot see, and think of appropriate work 
arounds.
> - Be aware of the restrictions on polymorphism and the use of 
reference
>   counted AST's. Depending on what you do/want you may lose all the 
advantages
>   of making something polymorphic.
> - in short YMMV
> 
> Cheers,
> 
> Ric
> 
> PS personally I could (would like to maybe even) use heterogenous 
AST's in my
>    project. But I don't. In Java mode it may work nice though. C# 
maybe too.
> --
> -----
+++++*****************************************************+++++++++---
----
>     ---- Ric Klaren ----- j.klaren at u... ----- +31 53 4893722  ----
> -----
+++++*****************************************************+++++++++---
----
>   Chaos is found in greatest abundance wherever order is being 
sought.
>   --- Terry Pratchet


 

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




More information about the antlr-interest mailing list