Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.compilers > #2889

Re: Graphical representations of syntax trees?

From Christopher F Clark <christopher.f.clark@compiler-resources.com>
Newsgroups comp.compilers
Subject Re: Graphical representations of syntax trees?
Date 2022-02-07 22:04 +0200
Organization Compilers Central
Message-ID <22-02-010@comp.compilers> (permalink)

Show all headers | View raw


There is a "good" reason why you don't see lots of work on outputting
pretty pictures of syntax trees. That is because Graphviz has a
reasonable implementation of drawing graphs with a variety of
algorithms that draw it to different preferences. And, Graphviz is
open source, so the code is there for you to use. However, most
compiler people realize that our talents are better used elsewhere
than trying to do a "better" Graphviz. So, we all just use it rather
than re-inventing the wheel.

And, as our wise moderator said, beyond very very simple syntax trees,
nothing works. There is simply way too much information. In fact, in
that way, the railroad diagrams in the original book about Pascal are
impressive, because they figured out that you want to break them down
to roughly one rule each (and simple rules at that) and not try to do
the whole graph as a single graph.

Similarly, there was a site (beatgraphs, if I recall the name
correctly) that used Graphviz to draw the pictures of how the teams in
the NFL ranked week by week based upon who beat who (and how to
resolve cycles). Graphviz managed to draw all 32 teams and their
rankings in a single graph. Some weeks it wouldn't fit on the screen,
but most of the time it did. That shows a rough upper bound of how
much info you can reliably draw a picture for.

So, unless you have a real desire to write drawing algorithms
yourself, you are better off just writing a "dot" file and feeding it
to Graphviz. And, with the options it has, I would be surprised if you
couldn't get it to draw the syntax tree to your liking. And, if you do
want to write layout algorithms, why not add them to Graphviz?

--
******************************************************************************
Chris Clark                  email: christopher.f.clark@compiler-resources.com
Compiler Resources, Inc.  Web Site: http://world.std.com/~compres
23 Bailey Rd                 voice: (508) 435-5016
Berlin, MA  01503 USA      twitter: @intel_chris
------------------------------------------------------------------------------

Back to comp.compilers | Previous | Next | Find similar


Thread

Re: Graphical representations of syntax trees? Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-02-07 22:04 +0200

csiph-web