Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: gah4 Newsgroups: comp.compilers Subject: Re: Some questions about recursive descent? Date: Sun, 27 Feb 2022 17:13:34 -0800 (PST) Organization: Compilers Central Lines: 34 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-02-022@comp.compilers> References: <22-02-021@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="55008"; mail-complaints-to="abuse@iecc.com" Keywords: parse Posted-Date: 27 Feb 2022 21:52:24 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <22-02-021@comp.compilers> Xref: csiph.com comp.compilers:2900 On Sunday, February 27, 2022 at 1:37:09 PM UTC-8, Johann 'Myrkraverk' Oskarsson wrote: > I am currently reading two compiler books, [Holub] and [Appel], and > then [Salomon] for a bit of context below, > > [Holub] Compiler Design in C, 1990, by Allen Holub > [Appel] Modern Compiler Implementation in ML, 2004, by Andrew Appel > > [Salomon] Assemblers and Loaders, 1993, David Salomon > and I have some questions about the construction of recursive descent > parsers. If some of my questions are adequately answered in some other > publication, reference, preferably with chapter and verse, is welcome. A few thoughts, which might not answer all your questions. One is that compilers that use recursive descent often don't use it for everything. Some might use it only for the statement level, and something else, such as operator precedence, for expressions. One of the complications with recursive descent is error handling. Consider that a user might forget, or misspell, a closing statement of some block structure. All the rest of the program is then parsed as inside the block, or at least until something that isn't allowed inside. And that might partly get to your question about returning the parse tree. Without errors, that might be fine. But when errors occur, the compiler has to undo much that was done, but should not have been done. That is somewhat easier with a global tree, than one that is distributed throughout the recursive contexts of the called routines. Also, much of earlier compiler design was done when computer memories were small. Designing compilers for small memory usage is now a lost art.