[antlr-interest] can tree grammers have an output of AST?

Terence Parr parrt at cs.usfca.edu
Mon Oct 16 10:13:30 PDT 2006


On Oct 15, 2006, at 11:30 PM, Hill, Robert wrote:
>> Ter's latest statement on translation philosophy is that trees
>> are built during parsing and then walked one or more times
>> without transformation (that started the latest thread on
>> translation approaches, after all).
>
> Hmm, I was (trying) to follow the thread , I must have missed that bit
> :(

Tree transformation is great if you are going from language L to L. I  
think that managing Union tree grammars when moving from L to L' is  
too much of a hassle.  But, that is just my opinion.

> All I wanted to do was make successive passes only deal with the rules
> that are
> Relevent at that pass, so for instance if I optimise away unused
> paramters, I wouldn't have to deal with them on the next pass, instead
> of simply setUnused(true)..

   An appropriate transformation.

>> ANTLR 3 was not designed
>> to do complex multi-pass transformations, nor was it designed
>> _not_ to support such transformations, for that matter.
>> However, features usually don't "just happen" in software, but
>> instead are the result of explicit design or redesign efforts.
>
> My misunderstanding, I just assumed that you could output either  
> another
> AST or a template from the treeparser. Just seemed natural to me, I
> guess I was jumping the gun a bit ;)

   Yes, it is my intention that you can output trees.  I had to cut  
that out of the first release so I could do a feature freeze and  
focus on bugs.  You will note that the wiki has:

http://www.antlr.org/wiki/display/ANTLR3/support+output%3DAST+in+tree 
+grammars

  from July 27.

Ter


More information about the antlr-interest mailing list