A recent Dr. Dobbs Journal described extensions made to gcc so that it
dumps the parsed c or c++ syntax as xml. They did this because existing
non-compiler parsers were all aproximations of the c++ syntax, and
didnt' work with complex templated c++ code. They used it to build
wrappers in some other language (swig-like), but you could use  this to
get an xml representation of the code, and then your dotfile generator
would only have to parse xml, for which there are many tools.

I think if you search for xml and gcc, you will find the home page of
the the gcc port (I think it will be merged, eventually).

Sam

Quoteing deliriousNOSPAM / atchoo.be, on Sat, Apr 26, 2003 at 03:01:58AM +0900:
> 
> _Context:_
> 
> My company uses a Directed Acyclic Graphs implementation of the
> Observer/Notifier pattern. I would love to see automatic generation of 
> diagrams representing those relationships.
> 
> _Challenge:_
> 
> It seems to me the easiest way to attain my goal is to generate a dot
> file and have www.graphviz.org do the rest. I imagine the dot-file would
> have to be generated by parsing C++ (yuck!).
> 
> How do I go about doing that ?
> 
> Do I simply parse the code looking for a multi-line patterns ? (See
> example below.)  Or do I use existent parsers to generate a full-blown
> semantic tree ?  (And then what ?)
> 
> 
> 
> Looking forward to your experiences/ideas,
> Simon
> 
> 
> 
> 
> _Sample code:_
> 
> The code I want to transform in dot edges looks like:
> ....
> singleDirection (
>   componentA->port("out"),
>   componentB->port("input")
> );
> 
> doubleDirection ( componentB->port("setting1"), componentD->port("setting1"));
> ....
> 
> 
> -- 
> There are 10 types of people in the world... 
> those who understand binary and those who don't.
>