Related articles |
---|
[4 earlier articles] |
Re: LR(1) Parsing : Error Handling & Recovery ivan@ootbcomp.com (Ivan Godard) (2014-07-17) |
Re: LR(1) Parsing : Error Handling & Recovery ivan@ootbcomp.com (Ivan Godard) (2014-07-17) |
Re: LR(1) Parsing : Error Handling & Recovery gneuner2@comcast.net (George Neuner) (2014-07-17) |
Re: LR(1) Parsing : Error Handling & Recovery wclodius@earthlink.net (2014-07-18) |
Re: LR(1) Parsing : Error Handling & Recovery wclodius@earthlink.net (2014-07-18) |
Re: LR(1) Parsing : Error Handling & Recovery monnier@iro.umontreal.ca (Stefan Monnier) (2014-07-18) |
Re: LR(1) Parsing : Error Handling & Recovery DrDiettrich1@aol.com (Hans-Peter Diettrich) (2014-07-19) |
Re: LR(1) Parsing : Error Handling & Recovery haberg-news@telia.com (Hans Aberg) (2014-07-19) |
Re: LR(1) Parsing : Error Handling & Recovery drikosev@otenet.gr (Evangelos Drikos) (2014-07-20) |
Re: LR(1) Parsing : Error Handling & Recovery haberg-news@telia.com (Hans Aberg) (2014-07-20) |
Re: LR(1) Parsing : Error Handling & Recovery gneuner2@comcast.net (George Neuner) (2014-07-20) |
Re: LR(1) Parsing : Error Handling & Recovery arnold@skeeve.com (2014-07-20) |
Re: LR(1) Parsing : Error Handling & Recovery monnier@iro.umontreal.ca (Stefan Monnier) (2014-07-20) |
[14 later articles] |
From: | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
Newsgroups: | comp.compilers |
Date: | Sat, 19 Jul 2014 12:04:41 +0200 |
Organization: | Compilers Central |
References: | 14-07-023 14-07-024 14-07-026 14-07-027 14-07-029 14-07-032 14-07-034 |
Keywords: | parse |
Posted-Date: | 19 Jul 2014 11:35:18 EDT |
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
Return to the
comp.compilers page.
Search the
comp.compilers archives again.