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

Ric Klaren klaren at cs.utwente.nl
Mon Jun 16 08:39:52 PDT 2003


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 utwente.nl ----- +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