是否有一个好的Python库可以解析C ++? [英] Is there a good Python library that can parse C++?

查看:110
本文介绍了是否有一个好的Python库可以解析C ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google没有显示任何似乎相关的内容。

Google didn't turn up anything that seemed relevant.

我有一堆现有的工作C ++代码,我想使用python抓取通过它和找出类之间的关系等。

I have a bunch of existing, working C++ code, and I'd like to use python to crawl through it and figure out relationships between classes, etc.

编辑:只是想指出:我不认为我需要或想要解析的每一个C ++;我只需要一些聪明的东西来接受类,函数和成员变量声明,并跳过功能定义。

Just wanted to point out: I don't think I need or want to parse every bit of C++; I just need something smart enough to pick up on class, function and member variable declarations, and to skip over function definitions.

推荐答案

C ++臭名昭着地难以解析。大多数尝试这样做的人最终会拆分编译器。实际上,这是(部分)为什么LLVM开始:苹果需要一种方式,他们可以解析C ++在XCode中使用匹配编译器解析它的方式。

C++ is notoriously hard to parse. Most people who try to do this properly end up taking apart a compiler. In fact this is (in part) why LLVM started: Apple needed a way they could parse C++ for use in XCode that matched the way the compiler parsed it.

这就是为什么有像 GCC_XML 这样的项目可以与python xml库结合使用。

That's why there are projects like GCC_XML which you could combine with a python xml library.

一些非编译器项目在解析C ++时做得很好:

Some non-compiler projects that seem to do a pretty good job at parsing C++ are:


  • Eclipse CDT

  • OpenGrok

  • Doxygen

这篇关于是否有一个好的Python库可以解析C ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆