Re: JJTree in JavaCC generates Parse Tree, not AST ??

"Arnaud Clère" <arnaud.clere@free.fr>
12 Nov 2002 14:13:43 -0500

          From comp.compilers

Related articles
JJTree in JavaCC generates Parse Tree, not AST ?? jrefactor@hotmail.com (John Davis) (2002-11-06)
Re: JJTree in JavaCC generates Parse Tree, not AST ?? arnaud.clere@free.fr (Arnaud Clère) (2002-11-12)
| List of all articles for this month |

From: "Arnaud Clère" <arnaud.clere@free.fr>
Newsgroups: comp.compilers
Date: 12 Nov 2002 14:13:43 -0500
Organization: Guest of ProXad - France
References: 02-11-021
Keywords: parse, AST
Posted-Date: 12 Nov 2002 14:13:43 EST

Hi,


I am not sure to understand the difference between Parse Tree and AST in
your terminology. I just wanted to say that JJTree will produce by default a
tree which matches exactly the productions in your grammar (looks like the
Parse Tree you mentioned), but that you can easily modify the generated tree
by decorating your grammar with JJTree directives like #void (do not
generate a Node for this production), #NodeType (unconditionaly generate a
NodeType node corresponding to the current production or clause scope),
#ConditionalNode(2) (generate a ConditionalNode whenever there are 2
children available), etc...


That will certainly enable you to produce what you're calling your AST. You
can find a lot of details and examples into JJTree documentation embedded
with the product.


Enjoy,


Arnaud Clère


"John Davis" <jrefactor@hotmail.com> wrote in message
| I want to confirm if JJTree in JavaCC generates Parse Tree (Concrete
| Syntax Tree), not AST (Abstract Syntax Tree)???
|
| But the 84 classes for each non-terminal node (ASTXXX.java) represents
| the AST node then??
|
| I am not sure how to change the grammar in order to produce an AST,
| not Parse Tree.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.