为 C++ 获取 AST? [英] Getting AST for C++?
问题描述
我希望获得 C++ 的 AST,然后我可以使用外部程序对其进行解析.有哪些程序适合为 C++ 生成 AST?我不在乎它是用什么语言实现的,也不关心输出格式(只要它易于解析即可).
I'm looking to get an AST for C++ that I can then parse with an external program. What programs are out there that are good for generating an AST for C++? I don't care what language it is implemented in or the output format (so long as it is readily parseable).
我的总体目标是将 C++ 单元测试台转换为相应的 C# 包装器测试台.
My overall goal is to transform a C++ unit test bed to its corresponding C# wrapper test bed.
推荐答案
你可以使用 clang 尤其是libclang 来解析 C++ 代码.这是一个非常高质量的手写库,用于词法分析、解析和编译 C++ 代码,但它也可以生成 AST.
You can use clang and especially libclang to parse C++ code. It's a very high quality, hand written library for lexing, parsing and compiling C++ code but it can also generate an AST.
Clang 也支持 C、Objective-C 和 Objective-C++.Clang 本身是用 C++ 编写的.
Clang also supports C, Objective-C and Objective-C++. Clang itself is written in C++.
这篇关于为 C++ 获取 AST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!