Replies: 1 comment
-
Builder class maybe a possible solution but if you need to mutate the AST then you will need to have methods to modify the AST objects. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there,
Hope you are having a good day.
I am working on a project that needs to be able to generate mutable AST and of course, prettyprint it to get an output c/c++ code. Last night I came across CppParser and before anything else, thank you for sharing this amazing project. I love the fact that it does not depend on any huge library such as Clang.
I noticed
CppWriter
is a class to pretty-print AST to c/c++ code which is exactly what I needed.Now I have to write a builder class to build AST from scratch, meaning that the parser won't be the one putting AST together, but the user will create AST using some limited/simplified builder API.
Basically, my project tries to convert huge computational graphs (which are mixed with symbolic expressions) to AST and from there to c/c++ code.
The core idea is to modify AST on various occasions and finally emit the c/c++ code using
CppWriter
.I wrote this to ask for your advice on how to approach this. Given your in-depth insight into the data structures of the AST, do you think it is a good idea to approach the problem this way (i.e. writing an AST builder class)?
Is there any other well-established way to approach this that I am missing? (like some opensource projects or sth)
I would love to have your input on this.
Kind regards,
Saleh
Beta Was this translation helpful? Give feedback.
All reactions