[antlr-interest] flat AST tree

Kay Röpke kroepke at classdump.org
Tue Aug 26 05:26:14 PDT 2008


Hi!

On Aug 26, 2008, at 12:43 PM, Gavin Lambert wrote:

> At 10:45 26/08/2008, Andy Tripp wrote:
>> If you look back in the mailing list, you'll see a fairly heated
>
>> debate a couple of months ago about whether it's reasonable to
>> have ANTLR return the parse tree for the AST when there are no
>> rewrite rules - your case.
>
> I don't recall it being all *that* heated :)

Either I missed it, or my memory is failing me. Probably both ;)

> I was actually on the other side at that time (arguing for it
> producing a parse-tree-like AST by default), but further thought
> has since caused me to change my mind.

There are not many cases where you really want to get a parse tree  
(Yes, I know there are some, but it's not the general case).

> I still think that there needs to be an easy way to obtain a parse
> tree from a given parser run (outside of ANTLRworks), just as
> simple diagnostic validation (after all, at the time the main
> thing I wanted it for was just to sanity-check the parse
> operation).  But I think that it needs to be kept separate from
> the AST, since the concepts don't really mesh too well in the end.

Well, there is support for generating parse trees, right? I can't  
remember what the class is called, and I think it uses the debug  
interface to get the rule invocations (most likely turns those into  
some kind of token, I guess, without looking the code) and then builds  
a tree.
I'm pretty sure there's even a wiki page on how to do it.
Wow, even google knows how to do it: http://www.google.com/search?q=antlr+v3+generate+parse+tree 
  (second hit for me) ;)
This is the wiki page that it links to http://antlr.org/wiki/pages/viewpage.action?pageId=1760

cheers,
-k
-- 
Kay Röpke
http://classdump.org/








More information about the antlr-interest mailing list