Are there any tools for displaying a Rust Abstract Syntax Tree nicely?
I'm creating an attribute proc macro that works on functions.
I found one example of such a macro here: syn/examples/trace-var at master · dtolnay/syn · GitHub
It would be much easier to figure AST manipulations if there was a tool to display the AST nicely.
Thanks for any help or advice on working with ASTs.
Carl
Will converting the ast back into code suffice? prettyplease - Rust
H2CO3
3
If you are merely trying to debug the output of a macro, try cargo-epxand
.
Thanks for the suggestions! Rust made it easy to create what I needed:
Rust AST Explorer
You paste in any Rust code and it displays the AST. It uses the syn crate (for parsing and formatting) and WASM (for interactivity).
[Update: AST explorer is fancier. I saw it, but missed its Rust option, which is via a pull down.]
Please give it a try.
My hope is that this will make creating procedure macros easier.
2 Likes
system
Closed
6
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.