Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AST Explorer? #4636

Open
max-sixty opened this issue Jun 19, 2024 · 6 comments
Open

AST Explorer? #4636

max-sixty opened this issue Jun 19, 2024 · 6 comments

Comments

@max-sixty
Copy link
Member

What's up?

It would be really nice to be able to explore our AST in something a bit more interactive / "zoom-able" than reading flat YAML. When working on prqlc fmt I would have found this v helpful. I briefly discussed this on the most recent dev call with @aljazerzen.

I checked out https://astexplorer.net/ — it's pretty nice — you can zoom in & out to different parts of the AST by unfolding & folding the tree; it uses highlights to show where the AST comes from in the code.

It doesn't support multiple stages — it would be even better to have columns with each stage and have the highlighting working across them. It also seems somewhat unmaintained now (fkling/astexplorer#625), and I couldn't managed to get it to build on my local machine.

So:

  • Is anyone familiar with any alternatives?
  • Would anyone be up for either adding PRQL support to one of these?
    • We could possible try building our own if there are no alternatives; though it seems like a non-core part of the project, and would need to be in a web language, which we're less good at
@aljazerzen
Copy link
Member

These are all very specific to the AST that they are exploring. And this should not be too hard to build ourself.

I'm planning on doing that.

@max-sixty
Copy link
Member Author

These are all very specific to the AST that they are exploring.

Some parts! Though I had thought the concept of "put your cursor in an editor and highlight the corresponding items in the AST graphs" seemed quite general...

@snth
Copy link
Member

snth commented Jun 20, 2024

Do all of the IRs have span fields with which one can link to the source code?


Why does it have to be in a web language? Would a python tool be ok? You could potentially have it run in browser with pyodide or run serve a web page.

@max-sixty
Copy link
Member Author

Do all of the IRs have span fields with which one can link to the source code?

Yes! At least LR, PR & PL do (though the latter aren't by default serialized, easy to change)

Why does it have to be in a web language? Would a python tool be ok? You could potentially have it run in browser with pyodide or run serve a web page.

Sure, whatever works; I had thought that this sort of thing would be best in a browser and browsers were easiest in JS, but no view beyond that...

@aljazerzen
Copy link
Member

I've added "probes" that log data from the compilation to a "debug log" that can be serialized to either a json or html file. That file can be opened with a browser directly, so there is no need to have an HTTP server even.

@0xdevalias
Copy link

It also seems somewhat unmaintained now (fkling/astexplorer#625), and I couldn't managed to get it to build on my local machine.

Haven't looked deeply at this project, but saw the link on another issue. Not sure if it's a good fit, but this one by @sxzz is more actively maintained:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants