Path: csiph.com!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Martin Ward Newsgroups: comp.compilers Subject: Re: What stage should entities be resolved? Date: Sat, 19 Mar 2022 18:17:14 +0000 Organization: Compilers Central Lines: 21 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <22-03-042@comp.compilers> References: <22-03-019@comp.compilers> <22-03-025@comp.compilers> <22-03-032@comp.compilers> <22-03-037@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="63378"; mail-complaints-to="abuse@iecc.com" Keywords: parse, design Posted-Date: 19 Mar 2022 17:50:09 EDT 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-03-037@comp.compilers> Content-Language: en-GB Xref: csiph.com comp.compilers:2944 On 2022-03-15, Roger L Costello wrote: > 1. How much knowledge of the language should the preprocessor stage have? In general, the preprocessor processes one language and passes the result to a compiler which processes a different (but often closely related) language. So the preprocessor can be thought of as a text to text language translator (the first C++ compiler was implemented as macros in the C preprocessor which accepted C++ source code and generated C source code). As a language tranlslator it should ideally know all about the input language that it is processing and only generate valid output. In practice, of course, many preprocessors have a very limited understanding of the source language they are processing and pass on syntax errors to the compiler (perhaps with hints about which line of the original source file this line of code came from). -- Martin Dr Martin Ward | Email: martin@gkc.org.uk | http://www.gkc.org.uk G.K.Chesterton site: http://www.gkc.org.uk/gkc | Erdos number: 4