Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.compilers Subject: Re: Graphical representations of syntax trees? Date: Mon, 07 Feb 2022 18:33:57 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 45 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-02-009@comp.compilers> References: <22-02-004@comp.compilers> <22-02-006@comp.compilers> <22-02-008@comp.compilers> 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 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:2888 Johann 'Myrkraverk' Oskarsson writes: >On 2/6/2022 10:32 PM, Anton Ertl wrote: >> Johann 'Myrkraverk' Oskarsson 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 , 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/