I'm playing with DOT output for debugging syntax trees from difftastic. Here's an F# snippet, the Debug representation, and the DOT rendered as an image.
I'm pleased with the information density on the graphic, but we'll see how often I end up using it.
Wilfred Hughes
@wilfredh i developed graphviz output for each phase of my parser compiler and i think it's only a little more useful than text output but still probably worth doing
@hipsterelectron thingskatedid on Twitter speaks very highly of graphviz debugging, so I figured I'd give it a try :)
Wilfred Hughes
@wilfredh @hipsterelectron it's been invaluable for #mergiraf to display matchings between trees. But not very happy with the #graphviz-rust crate I used, it lacks basic things (such as escaping to make sure it produces a valid DOT file) and has many dependencies. I am considering hand-rolling it instead. Are you using any crate?
@pintoch @hipsterelectron I'd been curious about DOT for a while, and seeing you doing it made me curious to try!
I'm hand-rolling it. It's a pretty simple syntax, it's purely for my debugging, and I didn't find any super compelling crates to help.
It's one screenful of code:
https://github.com/Wilfred/difftastic/blob/39e645832e1d78b4eda329a974e27652706e1745/src/parse/syntax.rs#L372-L407Wilfred Hughes
@pintoch @wilfredh i'm using a hand rolled crate as well (
https://docs.rs/graphvizier/latest/graphvizier/) as i find the precise utility of graphviz output tends to be very very specific and not easily something that can be abstracted (imagine a crate for painting!)
@pintoch @wilfredh we did this in the pants build tool as well (hand-generated graphviz output) to debug our extremely parallel type-driven task resolution engine (written in rust)
https://www.pantsbuild.org/docs/rules-api-concepts/@pintoch @wilfredh example output for a phase of the parser compiler
@hipsterelectron @pintoch Interesting! How well does it scale, i.e. at what point does it get so big that it's not useful?
Also, I'd love to hear how you decided what details to include in the graph. What does the arrow colour signify?
Wilfred Hughes
@wilfredh @pintoch i also happen to be extremely good at scanning long sequences of text for differences (kind of a useless talent) so it's somewhat less useful for my own purposes, but it does make a very useful representation for others when i want to explain what's going on in my head. in the above image red arrows are stack cycles which are allowed but require an additional phase of analysis