Library for C++ abstract syntax trees composition and code generation
I am looking for a C/C++ library. It should be able to parse C++ source code and generate abstract syntax tree. I would also like to explore/edit the AST from my program, for example to add a function call. This means, the syntax tree should not be in some text format, but as a collection of C++ objects, based on the object model of the library itself.
It should also be able to generate C++ code from an AST.
It is clear that any compiler does this and probably has some API. I have heard that GCC exposes some functionality, but it is quite overwhelming under the hood.
I am aware of Elsa, but the project seems to be inactive for quite some time.
I was wondering if there are other options. Anything that is cross-platform is a plus.
clang and libtooling is what you are looking for. It is able to do everything you want, but the downside is that it's not very well documented (to my knowledge). Here is a blog post with useful examples: http://eli.thegreenplace.net/2014/05/01/modern-source-to-source-transformation-with-clang-and-libtooling
链接地址: http://www.djcxy.com/p/68214.html下一篇: 用于C ++抽象语法树组合和代码生成的库