Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: wclodius@earthlink.net (William Clodius) Newsgroups: comp.compilers Subject: Re: LR(1) Parsing : Error Handling & Recovery Date: Fri, 18 Jul 2014 13:41:52 -0600 Organization: Compilers Central Lines: 28 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-07-032@comp.compilers> References: <14-07-023@comp.compilers> <14-07-024@comp.compilers> <14-07-026@comp.compilers> <14-07-027@comp.compilers> <14-07-029@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: miucha.iecc.com 1405713982 91689 2001:470:1f07:1126:0:676f:7373:6970 (18 Jul 2014 20:06:22 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Fri, 18 Jul 2014 20:06:22 +0000 (UTC) Keywords: parse, LL(1), comment Posted-Date: 18 Jul 2014 16:06:22 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com X-Received-Bytes: 2602 X-Received-Body-CRC: 2610073058 Xref: csiph.com comp.compilers:1322 Ivan Godard wrote: > > > [Error rules in yacc parsers are really for error recovery, not error > reporting. They let the parser resynchronize at a boundary such as a > semicolon between statements. LALR can only tell you that the parse > failed, and it can give you a set of tokens that would be valid where > the parse failed, but that set is often too large due to the way the > states are created. It's certainly easier to produce diagnostics in a > RD parser. What's hard is to verify that the language it accepts is > the language you want, and that it correctly catches any invalid > input. -John] This sort of comment has appeared frequently in the past and to some extent I find it puzzing. A recursive descent translation of an LL(k) (with k small) grammar is straightforward, and should readilly match the grammar, and give you the parse you desire. Is the problem that error recognition generally does not readily map to the desired grammar, or that the usual "on the fly" semantic anayisis in such implementations loses context, or something else I haven't recognized? [The practical problem is that RD parsers are typically written by hand, and after a couple of tweaks to the grammar and what are supposed to be matching tweaks to the code, they can get out of sync. Also, error checking code is boring and one's eyes tend to glaze. An RD parser mechanically generated from the grammar should reflect the grammar as accurately as any other mechanically generated parser. -John]