简体   繁体   English

C ++开源前端的选项

[英]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. 我正在寻找开源C ++编译器前端(源解析器/分析器)的选项,我可以根据我的要求进行自定义。 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. 我不需要后端实现,只是它有助于找到支持大多数标准功能的快速且相对无错误的C ++前端。 Any suggestions? 有什么建议么?

[I did google, clang seems to be an option but i'd much prefer peer feedback before i begin with it.] [我确实谷歌,clang似乎是一个选项,但在我开始之前我更喜欢同行反馈。]

Arpan Arpan

Clang and GCC are the two main options. Clang和GCC是两个主要选择。 GCC is very complicated (or so I've heard), and Clang is very promising but is immature. 海湾合作委员会非常复杂(或者我听说过),而且Clang非常有前途,但还不成熟。

GCC-XML uses GCC's frontend to spit out an XML description of the source. GCC-XML使用GCC的前端来吐出源的XML描述。 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. GCC-XML的输出不是一个完整的抽象源树(它不包含函数体),但它比GCC本身更容易使用。 (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 .) (GCC-XML页面上的最新版本已经过时了;如果您不想自己跟踪其CVS,可以尝试从Debian的gccxml页面下载tarball。)

Depending on your exact requirements, other options might work: 根据您的具体要求,其他选项可能有效:

  • CINT is a C / C++ interpreter. CINT是一个C / C ++解释器。 I'm told that it's not very strict in its adherence to C++ standards. 我被告知它遵守C ++标准并不是很严格。
  • ROSE can take C and C++ source and lets you do a variety of transformations on it. ROSE可以使用C和C ++源代码,并允许您对其进行各种转换。 The C and C++ front-end of ROSE is licensed from EDG, so it's not open source, but it is freely redistributable. ROSE的C和C ++前端是从EDG获得许可的,因此它不是开源的,但可以自由再发行。
  • Projects such as Doxygen and SWIG include their own limited C++ parsers. DoxygenSWIG这样的项目包括他们自己有限的C ++解析器。 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. 编辑:有关进一步阅读,请参阅Andrew Birkett撰写的“解析C ++”

你看过LLVM铿锵吗?

For one of the refactoring efforts I've done, we used Elsa: 对于我所做的重构工作之一,我们使用了Elsa:

http://scottmcpeak.com/elkhound/sources/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. 我们的代码的某些部分对于Elsa来说太复杂或不标准,并且必须对其进行预处理才能进行重构。

You can use this with Oink: 您可以在Oink中使用它:

http://danielwilkerson.com/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: CLang可能是最近寻求全面解决方案的方法,但如果您正在寻找可以理解的独立内容,那么请在github上查看这个项目:

https://github.com/robertoraggi/cplusplus 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. 开箱即用它带有一个小命令行实用程序来转储AST,符号和IR代码。

This is the C++ front end used in QTCreator . 这是QTCreator中使用的C ++前端。 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. 它在解析大多数现代C ++代码方面做得不错,即使cplusplus前端还没有更新一段时间,QTCreator也非常活跃地使用和开发。 This code has quite a bit of mileage on it. 这段代码有相当多的里程数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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