Open rmhsilva opened 4 years ago
I'll work on this, but I'll use graphviz (pydot package) due to lack of alternatives.
Great! Sounds good, graphviz would be great for a first implementation.
For the final version I have planned to:
Not sure if I misunderstood things or maybe I found a bug during parsing / AST generation:
list
they are in fact used as if they were type Any
since they at least sometimes contain just a node. E.g.: N_If.then is sometimes just a Node.What do you think about this visualisation for the file teal-lang/examples/video/video.tl? In fact I'm not even sure if I am plotting the AST or the parse tree :D
Nice, looks great! Colouring and symbols will be super useful. A couple of thoughts
on_upload
and on_http
are special event-triggered functions, and their configuration is in hark.toml
.import
statements can be shown as a single item, and therefore don't really need to be in the AST - filter them out.The thought process guiding me: I want to be able to, at a glance, understand the key elements in my program. The inputs, events and functions (python and Hark) involved. Like, where data is coming from, which Python functions are using it, any constants, etc. If it helps me visualise data flow, even better. Sort of like we're building a pipeline data-flow visualisation (e.g. Airflow style - https://airflow.apache.org/docs/stable/ui.html).
Ah, and I missed your question about list
vs Any
. You're right, it looks like they're wrong type annotations. Created #20 for it. Thanks!
It'd be great to be able to visualise the result of parsing -- the AST. This could be triggered with a new CLI command, e.g.
teal ast file.tl
.One approach: generate some graphviz based on the Node structure. See parser.py and nodes.py. Depends on the user having graphviz installed, so maybe a pure-python approach would be better!