Path: csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder1.iad1.usenetexpress.com!216.166.98.84.MISMATCH!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: George Neuner Newsgroups: comp.compilers Subject: Re: Alternatives to Syntax Trees Date: Mon, 16 Jan 2017 06:11:27 -0500 Organization: A noiseless patient Spider Lines: 31 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <17-01-004@comp.compilers> References: <17-01-002@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Injection-Info: miucha.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="32746"; mail-complaints-to="abuse@iecc.com" Keywords: parse, optimize Posted-Date: 16 Jan 2017 09:22:14 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:1810 On Sun, 15 Jan 2017 16:52:15 -0500 (EST), Seima Rao wrote: > Are there alternatives to syntax trees(i.e. the tree data structure) > when compiling via yacc or yacc like tools ? Parser tools don't limit the structure of the intermediate representation. >[There's quadruples, doubly linked lists of data structures. They >make it easier to rearrange code, but harder to do just about anything >else. There's also DAGs, which are trees that can have shared subtrees, >useful when you're doing common subexpressions or tail merging. -John] To add a bit to John's excellent response: You can use a combined representation: e.g., a graph to represent control - function defintions, loops, conditionals, etc. - and within the graph use 3-address form to represent basic blocks (straight line code). Some analyses, e.g., determining dominance for EBB def/kill chains, require both the basic blocks and the graph of their connectivity. Also, "quadruples" are one form of 3-address representation. There are other forms of 3-address and you can implement them using either lists or arrays. Quadruples are the most commonly used because - as John mentioned - they are the easiest to rearrange. George