Trying to visualize an abstract syntax tree at a point in the graph, and it's too easy. How to fix?

So, I am working on a language, and I wanted, mainly out of curiosity, to see if I could visualize the abstract syntax tree of the file. After some inspection, I found the graphviz point, converted my pretty AST instance to be able to output to this 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 that on startup

 dot -Tpng dotf.gv -o graph.png 

In the input file, I get a file with a width of 8000 pixels, which is just not practical. See here .

I do not know if it can be fixed, but if someone can be grateful.

+5
source share
1 answer

The first thing to do is set the direction of the chart from the lower level to the default left-right by inserting:

 rankdir=LR; 

... in the .dot file. This should orient the graph from left to right and thereby make it much more compact for a case that probably has many nodes with long node labels.

There are several other ideas for reducing the width of such graphs in Create a call graph for a file with clang .

+2
source

Source: https://habr.com/ru/post/1482403/


All Articles