简体   繁体   中英

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.]

Arpan

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, eg, 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.

你看过LLVM铿锵吗?

For one of the refactoring efforts I've done, we used Elsa:

http://scottmcpeak.com/elkhound/sources/elsa/

with mixed results. Some parts of our code were too complicated or nonstandard for Elsa to deal with, and had to be preprocessed out for the refactoring.

You can use this with Oink:

http://danielwilkerson.com/oink/

if source analysis is what you're in the mood for.

Hope this helps!

Digital Mars C ++编译器不是开源的,但源代码可以购买(参见http://www.digitalmars.com/shop.html ),您可以自定义它。

CLang is probably the way to go these days for a comprehensive solution, but if you're looking for something standalone that you can understand then check out this project on github:

https://github.com/robertoraggi/cplusplus

Out of the box it comes with a little command line utility to dump the AST, symbols, and IR code.

This is the C++ front end used in QTCreator . It does a decent job parsing most modern C++ code and even though the cplusplus front end hasn't been updated for a while, QTCreator is very actively used and developed. This code has quite a bit of mileage on it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM