Re: Graphical representations of syntax trees?

anton@mips.complang.tuwien.ac.at (Anton Ertl)
Mon, 07 Feb 2022 18:33:57 GMT

          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: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.compilers
Date: Mon, 07 Feb 2022 18:33:57 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 22-02-004 22-02-006 22-02-008
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="88498"; mail-complaints-to="abuse@iecc.com"
Keywords: parse, tools
Posted-Date: 07 Feb 2022 14:13:03 EST

Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.com> writes:
>On 2/6/2022 10:32 PM, Anton Ertl wrote:
>> Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.com> writes:
>>> Are there any resources, or papers, about the subject of representing
>>> syntax trees graphically?
>>
>> There are LaTeX modes for displaying trees. There is also the
>> graphviz package for visualizing graphs.
>
>Sure, these are packages. But no actual algorithms, or discussions of
>how to do these things by myself.


Seems pretty trivial to me. If a rule


A: B C


is used for parsing a part of the input, you generate a node for this
rule (e.g., labeled "A"), with nodes for B and C as children. If you
want it to look nice, you arrange for all the terminals to be at the
same (geometrical, not logical) level. I think that's not very hard
with graphviz. Then you get trees like:


        E
      /|\
    F |F
  /|\||
  1*2+3


A web search for "bison dot files" resulted in
<https://www.gnu.org/software/bison/manual/html_node/Graphviz.html>,
but this describes a visual representation of the parser, not the
parse tree.


>[I suspect the practical problem is that for any but the tiniest programs
>the parse tree will be so large and bushy as to be unreadable. -John]


IIRC (only read about that part, and a long time ago) graphviz
contains a tool that supports folding/unfolding parts of the graph
interactively, exactly because of this problem.


- anton
--
M. Anton Ertl
anton@mips.complang.tuwien.ac.at
http://www.complang.tuwien.ac.at/anton/


Post a followup to this message

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