且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

来自 C 代码的 AST

更新时间:2023-12-03 15:08:22

我推荐 clang.它有一个相当完整的 C 实现,带有大多数 gcc 扩展,代码也很容易理解.他们的 C++ 实现是不完整的,但如果您只关心从 C 代码生成 AST,那应该没问题.根据您想要做什么,您可以使用 clang 作为库并直接使用 AST,或者让 clang 将它们转储到控制台.

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.