views:

176

answers:

3

Are there any tools that can transform C++ code to xml, or some other format that would be easier to parse? It would be great if it would also have the option of turning xml back to C++ . I already know of doxygen's xml format ... maybe it's just me, but I don't find it particularly helpful.

+6  A: 

Something like gcc xml?

Éric Malenfant
can it turn the output back into C++ code?
Geo
No, it only gives you XML output. Also note that gcc-xml doesn't give you access to function bodies - if you need access to them its the wrong tool.
Georg Fritzsche
+2  A: 

As i recently learned, clangs C++ support is nearing completion and its API (the classes prefixed with CXX) looks quite good.
Maybe its current support is sufficient for your needs.

Georg Fritzsche
+1  A: 

Our DMS Software Reengineering Toolkit has a full C++ parser with symbol table, and can directly produce XML for the parse tree. DMS is designed to be customized; it would be close to trivial to get it to dump the symbol table as XML. It provides full access to declarations and function body information. Note that the XML can be pretty large for a 1000 line C++ program.

However, once you have the XML, you aren't going to be able to regenerate C++ source code from it.

DMS is designed to support custom analysis and code generation tasks. If you stay "inside" DMS you can generate C++ ASTs and symbol table data to your heart's content, analyze the code for issues, and/or transform the C+ ASTs and when done, prettyprint the ASTs back to legal, compilable C++ code.

Yes, its actively maintained.

Ira Baxter