Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: Hans-Peter Diettrich Newsgroups: comp.compilers Subject: Re: LR(1) Parsing : Error Handling & Recovery Date: Sat, 19 Jul 2014 12:04:41 +0200 Organization: Compilers Central Lines: 43 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-07-037@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> <14-07-032@comp.compilers> <14-07-034@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Trace: miucha.iecc.com 1405784118 54383 2001:470:1f07:1126:0:676f:7373:6970 (19 Jul 2014 15:35:18 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Sat, 19 Jul 2014 15:35:18 +0000 (UTC) Keywords: parse Posted-Date: 19 Jul 2014 11:35:18 EDT 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:1327 Stefan Monnier schrieb: >> 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 > > This is misleading. Take your BNF and pass it to a PEG parser: a PEG > parser can accept pretty much the same input syntax as a BNF parser, and > can be considered as a kind of RD parser, so you'd think the result is > necessarily correct. Sorry, that's ambiguous :-] You miss to define what is "passing a grammar to an parser". Should the PEG parser - parse the grammar - create an parser from the grammar - interpret the grammar in parsing further input In general the result cannot be more correct than is your grammar. If your grammar is unambiguous, the results should be the same (equivalent at least) in either case. But if your grammar is ambiguous, what "result" do you consider possibly incorrect? > Well, not so, because the semantics of the language is not the same: That's the case with every grammar: who knows whether it really reflects the semantics of the language? A parser generator only can verify that a grammar is *valid*, but not that it matches a specific language. > The PEG/RD parser will "silently resolve ambiguities". IMO a correct PEG parser generator should warn about ambiguities in the grammar, just as every other parser generator does. In such cases the disambiguation is *not* performed by the parser generator, but by the grammar writer, who arranges the alternatives in the correct (intended) order. I only can hope that you know how to use your programming tools, and don't belong to those coders who say: "it compiles, so let's ship it" ;-) DoDi