So I'm working on a language and I wanted to, mostly out of curiosity, see if I could visualize the abstract syntax tree of a file. After some looking around I found graphviz dot, converted my AST prettyprinter to be able to output to this kind of format:
digraph G {
main -> parse -> execute;
main -> init;
main -> cleanup;
execute -> make_string;
execute -> printf
init -> make_string;
main -> printf;
execute -> compare;
}
But my problem is, when I run
dot -Tpng dotf.gv -o graph.png
On the input file, I end up with a file that is 8000 pixels in width, which is just not practical. See here.
I don't know if it's possible to fix, but if someone can I'd be grateful.
The first thing to do would be to set the direction of the graph from the default bottom-to-top ranking to left-to-right, by inserting:
rankdir=LR;
... in the .dot file. That should orient the graph left-to-right and thereby make it much more compact for a case like this that probably has many nodes with long node labels.
There are some other ideas for reducing the width of graphs like this in Create a call graph for a file with clang.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With