Stream: ideas

Topic: AST to play with


view this post on Zulip Vladimir Zotov (Jul 02 2023 at 12:16):

Hi peeps, is there a tool that would give me ast?

view this post on Zulip Anton (Jul 02 2023 at 12:49):

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.

view this post on Zulip Vladimir Zotov (Jan 31 2024 at 09:51):

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?

view this post on Zulip Anton (Jan 31 2024 at 10:54):

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.

view this post on Zulip Vladimir Zotov (Jan 31 2024 at 14:06):

@Ayaz Hafiz Maybe you could shed more light here? :smile:

view this post on Zulip Ayaz Hafiz (Jan 31 2024 at 22:53):

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