Clang and GCC are two main options. GCC is very complex (or so I heard), and Clang is very promising, but immature.
GCC-XML uses the GCC front-end to highlight XML source descriptions. The output of GCC-XML is not a complete abstract source tree (it does not contain a function body), but it will be much easier to work with than with GCC itself. (The latest release on the GCC-XML page is terribly outdated; if you don't want to bother tracking its CVS yourself, you can try downloading tarball, for example, from the Debian gccxml page .)
Depending on your exact requirements, other options may work:
- CINT is a C / C ++ interpreter. I was told that it is not very strict according to C ++ standards.
- ROSE can use the source of C and C ++ and allows you to perform various conversions in it. The C and C ++ ROSE interface is licensed from EDG, so it is not open source, but it is freely distributed.
- Projects such as Doxygen and SWIG include their own limited C ++ parsers. Although they are intended only to extract documentation and create interfaces, they may suit your needs.
Edit: For further reading, see "C ++ Parsing," by Andrew Birkett.
source share