Logo Questions Linux Laravel Mysql Ubuntu Git Menu

Options for open source front end for C++

I am looking for options for an open source C++ compiler front-end (source parser/analyzer) that I could customize for my requirements. I do not need the back end implementation, just that it would help to find a fast and relatively bug free C++ front end that supports most standard features. Any suggestions?

[I did google, clang seems to be an option but i'd much prefer peer feedback before i begin with it.]


like image 996
Fanatic23 Avatar asked Jan 21 '23 22:01


2 Answers

Clang and GCC are the two main options. GCC is very complicated (or so I've heard), and Clang is very promising but is immature.

GCC-XML uses GCC's frontend to spit out an XML description of the source. GCC-XML's output is not a full abstract source tree (it doesn't contain function bodies), but it would be a lot easier to work with than GCC itself. (The latest release on the GCC-XML page is horribly out of date; if you don't want to mess around with tracking its CVS yourself, you might try downloading a tarball from, e.g., Debian's gccxml page.)

Depending on your exact requirements, other options might work:

  • CINT is a C / C++ interpreter. I'm told that it's not very strict in its adherence to C++ standards.
  • ROSE can take C and C++ source and lets you do a variety of transformations on it. The C and C++ front-end of ROSE is licensed from EDG, so it's not open source, but it is freely redistributable.
  • Projects such as Doxygen and SWIG include their own limited C++ parsers. Although these are only intended for extracting documentation and generating interfaces, respectively, they may meet your needs.

Edit: For further reading, see "Parsing C++", by Andrew Birkett.

like image 115
Josh Kelley Avatar answered Jan 31 '23 19:01

Josh Kelley

Have you looked at LLVM clang?

like image 29
Nikolai Fetissov Avatar answered Jan 31 '23 19:01

Nikolai Fetissov