[antlr-interest] LPG WAS Retaining comments

Andy Tripp antlr at jazillian.com
Wed Mar 12 15:54:59 PDT 2008


Hmmm...a tool that automatically produces an "AST" just from an input 
grammar.
What a novel concept!  ;)

But the authors call it an "AST" when in fact it's really just a parse 
tree, not an AST.
Strange that the authors themselves would make such a mistake - to think 
that a parse
tree might make a reasonable default AST...what a silly mistake.

Don't they realize that building an AST is hard, and no one should be 
able to
get an AST "for free"? Don't they realize that's not an AST at all, but 
a parse tree, and that
the *real* AST that this input grammar has asked for is a useful, 
simple, flat, data structure?

Clearly they just don't know what they're talking about  and so should 
be ignored.

Andy ;)

Terence Parr wrote:
>
> On Mar 12, 2008, at 2:55 PM, David Holroyd wrote:
>
>> On Wed, Mar 12, 2008 at 02:22:55PM -0700, Gerald B. Rosenberg wrote:
>>> There are times where you just need to randomly muck around in the
>>> AST.  To use the AST interactively (to do user-driven refactorings in
>>> my case), or where the selection conditions are context dependent, as
>>> what sounds to be Stuart's case.  An AST wrapper is, I think, the
>>> right approach.  The down-side is that it would be directly dependent
>>> on the implementation/structure of the AST, requiring rewrite each
>>> time the AST changed.
>>>
>>> So, how to generate the implementation of a reasonably generic AST
>>> random access/manipulation API?
>>
>> I believe LPG (ANTLR competitor!) has some capability in this area,
>>
>>  http://kent.dl.sourceforge.net/sourceforge/lpg/LPG_Automatic_AST_Generation.htm 
>>
>>
>> Not that this on its own says much about problems like code refactoring,
>> but getting a heterogeneous AST for 'free' sounds nice.
>
> Unfortunately, that is a parse tree not an AST... ;)
>
> Ter
>



More information about the antlr-interest mailing list