Re: Graphical representations of syntax trees?

Christopher F Clark <christopher.f.clark@compiler-resources.com>
Mon, 7 Feb 2022 22:04:28 +0200

          From comp.compilers

Related articles
Graphical representations of syntax trees? johann@myrkraverk.com (Johann 'Myrkraverk' Oskarsson) (2022-02-04)
Re: Graphical representations of syntax trees? gah4@u.washington.edu (gah4) (2022-02-06)
Re: Graphical representations of syntax trees? anton@mips.complang.tuwien.ac.at (2022-02-06)
Re: Graphical representations of syntax trees? DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2022-02-06)
Re: Graphical representations of syntax trees? johann@myrkraverk.com (Johann 'Myrkraverk' Oskarsson) (2022-02-07)
Re: Graphical representations of syntax trees? anton@mips.complang.tuwien.ac.at (2022-02-07)
Re: Graphical representations of syntax trees? christopher.f.clark@compiler-resources.com (Christopher F Clark) (2022-02-07)
Re: Graphical representations of syntax trees? alexfrunews@gmail.com (Alexei A. Frounze) (2022-02-07)
Re: Graphical representations of syntax trees? stephenjohnlimb@gmail.com (Steve Limb) (2022-02-08)
Re: Graphical representations of syntax trees? jonathan@gold.bkis-orchard.net (Jonathan Thornburg) (2022-02-08)
Re: Graphical representations of syntax trees? johann@myrkraverk.invalid (Johann 'Myrkraverk' Oskarsson) (2022-02-11)
| List of all articles for this month |

From: Christopher F Clark <christopher.f.clark@compiler-resources.com>
Newsgroups: comp.compilers
Date: Mon, 7 Feb 2022 22:04:28 +0200
Organization: Compilers Central
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="59389"; mail-complaints-to="abuse@iecc.com"
Keywords: parse, tools
Posted-Date: 07 Feb 2022 16:54:56 EST

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
------------------------------------------------------------------------------



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.