This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Using of parse tree externally


Robert,

You are right about the AST, and that we are all talking about them 
but there is one thing to be said about the syntax trees:

The parser's syntax tree will also be interesting for cross referencing,
if you have a give AST node, in what parser rule was that node created from?
What where the tokens on the stack, or inherited that might be needed.
In the gcc -Dy  dumps, you have the entire source code of the program,
albeit run through the "Fleischwolf" or meatgrinder.
That might be of interest to the two-way reverse engineering tools ala
rose/together and co., 
you can then get then entire token/rule stream associated with a AST, and be
able to reconstruct the original source code from an give dump.

The next step would also be go into the preprocessor and encapsulate the
comments and macro calls.

I see there are then three streams of data that are related but independent
:
	1. The preprocessor token stream with comments and macros.
		of course you would have to embed some form of knowledge of
linking to say that some comment applys to the previous or next section of
code.		
	with links to  :
	2. syntax rules and tokens 

	with links to :
	3. Abstract Syntax Tree Nodes

	with links to :
	4. Assembler code snippets 

So given one of the pieces, you can traverse the network of data sideways
into a completely separate domain.
Say, what are the tokens that were involved in the creation of this one
piece of assembler.
Or you can say, given this ast node, what macros calls were involved in its
creation.

These are of course somewhat far off goals, but needless to say that the
full representation of a program 
would include all these pieces.

By the way, 
What are the symantics of the ASIS interface? What lessons can be learned
from there?

Mike

-----Original Message-----
From: dewar@gnat.com [mailto:dewar@gnat.com]
Sent: 19 October 2000 14:27
To: espie@quatramaran.ens.fr; gcc@gcc.gnu.org
Subject: Re: Using of parse tree externally


Note incidentally that I would guess that the subject of this thread
is wrong, since the parse tree is of little interest, I assume that
what we are really talking about is the AST (abstract syntax tree).

It is interesting to note that GNAT *does* have the capability of
writing out its AST, and this tree is used to feed the ASIS implementation,
which provides an API that allows tools to access semantic information
for a compiled program (suitable for static analysis tools etc). 

Theoretically, it might be possible to use this to drive a proprietary
back end. Theoretically, such a back end might not violate the GPL. In
practice building a complete compiler like this is hard anyway, and so
far it simply has not been an issue.

Robert Dewar
-- 
This communication contains information which is confidential and 
may also be privileged.  It is for the exclusive use of the 
intended recipient(s).  If you are not the intended recipient(s), 
please note that any distribution, copying or use of this 
communication or the information in it is strictly prohibited.  
If you have received this communication in error, please notify 
the sender immediately and then destroy any copies of it.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]