Path: csiph.com!feeder.erje.net!2.us.feeder.erje.net!enother.net!enother.net!enother.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Kaz Kylheku <221-501-9011@kylheku.com> Newsgroups: comp.compilers Subject: Re: Alternatives to Syntax Trees Date: Sun, 15 Jan 2017 22:31:45 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 24 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <17-01-003@comp.compilers> References: <17-01-002@comp.compilers> Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="32457"; mail-complaints-to="abuse@iecc.com" Keywords: parse, optimize Posted-Date: 16 Jan 2017 09:21:28 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:1809 On 2017-01-15, Seima Rao wrote: > Hi, > > Are there alternatives to syntax trees(i.e. the tree data structure) > when compiling via yacc or yacc like tools ? If the language you are parsing has a context-free grammar suitable for Yacc, then the parse corresponds to a tree. More precisely, a real-world parse corresponds to a DAG: a tree in which some nodes are shared. For instance if you're parsing Lisp, an input like (a a a) is converted to DAG in which all three occurences of "a" point to the same symbol object. This is because the symbols are "interned" as scanning takes place. Compilers do not use the tree data structure in all passes. Syntax trees represent only the raw syntax. An intermediate representation may be quite different: a graph containing chunks of instruction sequences. -- TXR Programming Lanuage: http://nongnu.org/txr Music DIY Mailing List: http://www.kylheku.com/diy ADA MP-1 Mailing List: http://www.kylheku.com/mp1