Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Christopher F Clark Newsgroups: comp.compilers Subject: Re: Graphical representations of syntax trees? Date: Mon, 7 Feb 2022 22:04:28 +0200 Organization: Compilers Central Lines: 38 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-02-010@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" 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 X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:2889 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 ------------------------------------------------------------------------------