[antlr-interest] Re: AST vs parse trees

Terence Parr parrt at cs.usfca.edu
Tue Nov 11 10:05:25 PST 2003


On Monday, November 10, 2003, at 06:46 PM, micheal_jor wrote:

> --- In antlr-interest at yahoogroups.com, Terence Parr <parrt at c...> wrote:
>
>>> OK. I needed to be clearer. In practical terms, ANTLR neither
>>> generates a CST nor an AST by default. It generates something in
>>> between. Sure the internal rule nodes are missing but, lots of other
>>> noise like semicolons and closing braces are present. Now, they have
>>> their uses (~100% lossless tranformations being one example) but they
>>> still represent noise in an optimized AST.
>>
>> Actually I specifically remove ; and } etc... if you look at the 
>> java.g
>> file.  An AST should have the minimum necessary information in there. 
>> :)
>
> That the point I was making Ter. By default, ANTLR generates trees
> that need "pruning" to get an optimized AST with only the minimum
> neccesary information. Not necessarily a bad thing, as long as the
> pruning can be specified in a action-language-agnostic manner.

Oh. Sorry.  Yeah, you must manually prune.

> Any opinion on the visitor-generation idea/suggestion?

Well, visitor stuff is fine if you don't need a lot of context.  Being 
at node "PLUS" doesn't always tell you enough.  E.g., am I a PLUS node 
in an IF expression or WHILE?

Ter

>
> Cheers,
>
> Micheal
>
>
>
>
>
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/
>
>
>
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com pure link sharing




 

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




More information about the antlr-interest mailing list