解析C code。使用蟒蛇 [英] parsing C code using python

查看:86
本文介绍了解析C code。使用蟒蛇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个巨大的C文件(100K〜线),我需要能够解析。主要是我需要能够获得大约每结构的各个字段(如字段名称和类型结构中的各个领域)从其定义详细信息。是否有一个良好(开源的,这我可以在我的code使用)的方式已经做到这一点?或者我应该写我自己的这个解析器。如果我有我自己写的,任何人都可以提出一个良好的开端?我从来没有与蟒蛇工作过。

I have a huge C file (~100k lines) which I need to be able to parse. Mainly I need to be able to get details about individual fields of every structure (like field name and type for every field in the structure) from its definition. Is there a good(open source, which i can use in my code) way to do this already? Or should I write my own parser for this. If I have to write my own, can anyone suggest a good place to start? I have never worked with python before.

感谢

推荐答案

看看此链接一个广泛的可用于Python的分析工具列表。具体来说,解析C code,尝试 pycparser

Take a look at this link for an extensive list of parsing tools available for Python. Specifically, for parsing c code, try the pycparser

这篇关于解析C code。使用蟒蛇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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