PRQL / prql

PRQL is a modern language for transforming data — a simple, powerful, pipelined SQL replacement
https://prql-lang.org
Apache License 2.0
9.58k stars 208 forks source link

AST Explorer? #4636

Open max-sixty opened 1 week ago

max-sixty commented 1 week ago

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 (https://github.com/fkling/astexplorer/issues/625), and I couldn't managed to get it to build on my local machine.

So:

aljazerzen commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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.