3

I am looking into GCCXML, which can parse a given header file and generates XML format of C code meta data. But GCCxml is an open source. Is there any commercial version of c code parser which works similar to GCC XML?

Thanks, Karthick

K2M
  • 379
  • 1
  • 5
  • 12

2 Answers2

2

The obvious replacement for gccxml will be clang, which is licensed under BSD license (so you can freely use it in commercial projects, do whatever you want with the code, etc.). clang used to have an xml AST dumper built-in, but it was removed at some stage. If you only need to extract specific information (such as function prototypes for IDL generation or stuff like this) it is not difficult to write a basic custom clang plugin to do this. Otherwise, you can search around for existing clang plugins which will do the job, such as this one:

https://github.com/sk-havok/clang-extract

Clang plugin tutorial: http://clang.llvm.org/docs/ClangPlugins.html

oakad
  • 6,945
  • 1
  • 22
  • 31
  • Thanks Oakad. I will explore the above links by today or tommorrow and let you know what I come with. – K2M Dec 12 '13 at 17:25
  • Looks clang its really promising. It took me a day though to figure out what is Clang and able to download the source code and execute some sample Python scripts. But its a one time effort. Its really a great tool and this tutorial really helped me [http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang/] – K2M Dec 13 '13 at 02:22
1

See our DMS Software Reengineering Toolkit with its C Front End for an equivalent/superset of GCCXML.

The C front end can handle a variety of C dialects (ANSI, GCC, MS). It contains a full preprocessor. It can export ASTs for the complete language (esp. including function bodies, which GCCXML does not do, IIRC) and its symbol table, both in XML format.

Here at SO there is an example dump of the AST from DMS's C++ front end. This uses the same machinery as the C front end uses.

Community
  • 1
  • 1
Ira Baxter
  • 93,541
  • 22
  • 172
  • 341
  • Thanks Ira.. I will explore this as well. – K2M Dec 12 '13 at 17:43
  • I have not heard a chance to look this today. Can you please tell me what tool I need to download from this site [http://www.semanticdesigns.com/Products/Downloads.html] to explore further. – K2M Dec 13 '13 at 02:25
  • DMS is an enterprise product; it isn't offered for download. Contact Semantic Designs to discuss your needs. – Ira Baxter Dec 13 '13 at 09:41