
Ask HN: Compiler frameworks for AST Transformations? - ianbertolacci
Are there any compiler frameworks that tools to parse code (C&#x2F;C++ at a minimum), and analyse, transform, and manipulate the AST?<p>We&#x27;ve been using the Rose compiler framework (http:&#x2F;&#x2F;rosecompiler.org&#x2F;) in our group for some time.
However, it&#x27;s not my favorite and I&#x27;d like to use an alternative.<p>I&#x27;ve been wondering if there was something similar that was better maintained and supported.
LLVM seems like an obvious choice, but it&#x27;s too low level to be really effective.
We would end up writing a lot more analysis to discover things that are obvious at high-level representations (&quot;Is that a for loop?&quot;).<p>Looking for something:
1) very accessible; other people should be able to build and use my transformations with relative ease.
2) well documented; no mysterious functions and types that I have to use.
3) easy-to-use&#x2F;intuitive (for compiler writers).<p>Thanks!
======
_RPM
I think it is great that you are into this kind of stuff. I am as well, as I
find it one of the most interesting things to do. "The AST" is subjective,
however. We know it is a tree data structure, but most compilers implemented
it differently. Also, AST generation is typically derived from the parsing
stage, then the AST is taken to be compiled. I think you should look into GNU
Bison.

~~~
ianbertolacci
Bison is a great tool for parsing grammars.

However, I'm more looking for a tool that, on its own, can be used as a full
compiler, with the added ability to put myself in the middle of the front and
back end.

LLVM has a similar ability where you can develop a pass over the IR and
manipulate it.

------
msdos
[https://github.com/cil-project/cil](https://github.com/cil-project/cil)

