从C code AST [英] AST from C code
问题描述
我想执行的C源$ C $ C一些转换。 我需要在Linux上的工具,从源头code生成一个完整的AST ,这样我可以申请这个AST我的转换,然后将其转换回C源代码code。我试着 ELSA 但它没有得到编译。 (我使用Ubuntu 8.4)。任何人都可以提出一个更好的工具/应用程序?
I want to perform some transformations on C source code. I need a tool on linux that generates a complete AST from the source code so that I can apply my transformations on this AST and then convert it back to the C source code. I tried ELSA but it is not getting compiled. (I am using Ubuntu 8.4). Can anyone suggest a better tool/application?
推荐答案
我会建议铛。它与大多数海湾合作委员会的扩展相当完整的C实现,而code是非常可以理解的。他们的C ++实现是不完整的,但如果你只关心从C code产生的AST,应该是罚款。根据你想做什么,你可以使用铛作为一个库和工作与AST的直接,或已经铛倾倒出来安慰。
I would recommend clang. It has a fairly complete C implementation with most gcc extensions, and the code is very understandable. Their C++ implementation is incomplete, but if you only care about generating ASTs from C code that should be fine. Depending on what you want to do you can either use clang as a library and work with the ASTs directly, or have clang dump them out to console.
这篇关于从C code AST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!