On Sat, Oct 14, 2006 at 02:16:01PM +1000, Brendon Costa wrote: > Bob Rossi wrote: > > Hi Ian, > > > > Basically, I want to use GCC with C,C++. I want to walk a tree that GCC > > creates for the translation units. I would like to know if for these two > > languages if I should use a language dependent tree, the generic tree or > > the gimple tree. In general, I would like to use the tree that most > closely > > resembles the source language, and that is documented best. > > > > For starters, can you recommend which tree structure I should use in > > GCC? If so, would it be to much to ask to point me to the object in the > > source code that represents the tree after the tree has been populated? > > > > If I should be using gimple, I found this paper. > > ftp://gcc.gnu.org/pub/gcc/summit/2003/GENERIC%20and%20GIMPLE.pdf > > Is there any other good documentation on this? > > I cant help much as i have only been fumbling around in the GCC source > for a short time now and still have no idea about a lot of stuff. > However I did want to also look at the full tree for the C++ front end. > I did this from the parser.c: cp_parser_translation_unit() function just > after the call to: finish_translation_unit() and I was looking at the > tree defined globally elsewhere in the variable: global_namespace
Thanks Brendon, that was really helpful. I'm very new at this, and may have some seemingly rather odd questions. I see that global_namespace is of type 'union tree_node'. Is this the C++ language dependent AST? I found the documentation doc/c-tree.info. Is this the documentation representing the global_namespace tree? Is there any better documentation that you know of? Also, I noticed that converting it to html failed. Maybe this is a documentation error? Thanks again, Bob Rossi $ makeinfo --html ../../../gcc/gcc/doc/c-tree.texi ../../../gcc/gcc/doc/c-tree.texi:10: `Trees' has no Up field (perhaps incorrect sectioning?). makeinfo: Removing output file `/home/bob/rcs/svn/gcc/gcc/builddir/gcc/doc/c-tree/index.html' due to errors; use --force to preserve. $ makeinfo --version makeinfo (GNU texinfo) 4.8