Hi peeps, is there a tool that would give me ast?
Hi @Vladimir Zotov,
We don't have a standalone tool that can produce the ast for a given roc file. But printing the parsed_defs here could get you what you're looking for.
If you're looking for a bunch of examples of ast's you can find them here.
Hi @Anton I recently wanted to write a small tool to generate additional Roc code for dependency injection magic. I imagined I would run the compiler just to generate an AST. Then I would read it to find methods that were intended to have DI. Then I would do the actual compilation with the additional source code.
Do I understand it correctly: to do this right now I need to modify the compiler source (the parse method) and build the compiler from source to get it to print the AST? Is there a new simpler way since I asked this question last July?
Is there a new simpler way since I asked this question last July?
Perhaps that can also be done with the language server but I don't have much experience with it.
@Ayaz Hafiz Maybe you could shed more light here? :smile:
If you want to hack the compiler, you can generate an AST pretty easily. There are no public tools to grab the AST for a source program
Last updated: Jun 16 2026 at 16:19 UTC