Path: csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Kaz Kylheku <157-073-9834@kylheku.com> Newsgroups: comp.compilers Subject: Re: Best language for implementing compilers? Date: Sun, 10 Mar 2019 05:48:27 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 32 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <19-03-008@comp.compilers> References: <19-02-002@comp.compilers> <19-02-004@comp.compilers> <19-02-006@comp.compilers> <19-03-002@comp.compilers> <19-03-006@comp.compilers> Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="48234"; mail-complaints-to="abuse@iecc.com" Keywords: parse Posted-Date: 10 Mar 2019 01:02:32 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:2174 On 2019-03-10, George Neuner wrote: > On Sat, 9 Mar 2019 01:47:38 -0500 (EST), mertesthomas@gmail.com wrote: > >>For parsing I don't think that pattern matching leads to correct >>results in all cases. I have seen too much buggy attempts to do >>parsing with pattern matching. > > You have seen the approach of bad patterns - you have not seen that > patterns are a bad approach. > > I also have seen some poor attempts made using pattern matching - when > the patterns are too general, or don't cover 100% the intended cases - > there will be unintended matches. Pattern matching is only as Sometimes unintended matches are better; you can deal with the over-match easily later in the pipeline. Lisp is a good example: any possible tree shape, containing any symbols, can be scanned into a tree. Then macros and operators check for invalid syntax. In C, any combination of type specifiers and qualifiers can occur in a declaration. For instance the simple grammar will match "long char unsigned short int double". Enforcing the permissible combinations is a constraint check. The valid combinations can occur in any order: unsigned long int, int long unsigned, ... It would be a fool's errand to write phrase structure rules to match the valid combinations and not match invalid ones.