[antlr-interest] Re: Anyone tried this ANTLR-inspired CC?

Tiller, Michael (M.M.) mtiller at ford.com
Tue Nov 11 07:36:56 PST 2003


> From: Terence Parr [mailto:parrt at cs.usfca.edu]
> Sent: Monday, November 10, 2003 4:15 PM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] Re: Anyone tried this ANTLR-inspired CC?
> 
> 
> 
> On Sunday, November 9, 2003, at 05:37 PM, leung13512c wrote:
> 
> > The thing that caused me to switch away from ANTLR syntax
> > is because I prefer the tree building syntax of JJTree that always
> > create imaginary nodes instead of a mix of both.  And it mostly
> > avoid having to create nodes within actions.
> 
> Howdy.  This is the old AST versus parse tree argument...Parse trees 
> are easy to generate (i.e., no cost to developer) but have 
> way too much 
> noise for tree transformation and also are sensitive to grammar 
> construction whereas ASTs are the canonical repr for a particular 
> language.
> 
> Ter

I'm not sure this is an argument for parse trees or against ASTs.  Let me explain...

Personally, there are two extremes I would like to avoid.  One is using terminals as roots in ASTs.  I don't really care for this approach because I find it rather strange (just my personal preference).  The other case I wouldn't like is having every production rule in my grammar generate a node in my AST.  As far as I'm concerned, these are both sub-optimal.

In practice, ANTLR tends to fall into the former category and I guess JJTree probably falls into the latter.  Now ANLTR is obviously capable of avoiding this use of terminals for roots by creating imaginary nodes.  It seems to me that the issue here is how tedious it can be to do this (and the fact that it really becomes a problem with the current C++ framework).  I think it would be nice if ANTLR was capable of automatically handling this case of synthetic or imaginary nodes and I suspect that is what is at issue here.

--
Mike

 

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




More information about the antlr-interest mailing list