On Sat, Oct 29, 2016 at 5:10 PM, Nicolas Laurent <
nicolas.laur...@uclouvain.be> wrote:

> Interesting, why do you think the furthest-position heuristic may report
> incorrect information?
>
> My perspective is that it returns one possible error among the set of all
> possible errors given an erroneous input. In all generality, finding out
> the actual error requires knowing the programmer's intent.
>
> Maybe you think about errors that say, for instance, "expecting operator
> X", when in fact there are a number of other operators than X that may have
> worked in that position?
>

Interesting question...

My best answer is that I've found that it is best if the parser reports an
error at the position in the input in which, after having forced to commit
by *cut* operators, there are no options in a choice that match the
remaining input. Without *cut* that choice will often be the start rule, or
other *high level* rules, or rules applied early in the parse.

Generally, for a PEG grammar to parse the intended language, the options
with the expected largest parse must come first, but there are other
options because the first one is not always the right one.


> I see cut operators it as a way to generator better error messages rather
> than unearthing different errors.
>

Yes.


> Inserting a cut operator can change the semantics of a grammar.
>

It can, if the *cut* commits the parser to an option that will eventually
fail for the input, when others could have suceeded.


> But with automatic insertion, the point is precisely to retain the
> existing semantics.
>

Exactly.


> In this case, the furthest error will always occur on the branch where the
> cut operator occurs.
>
> What do you think?
>

I think I need an example of furthest error being wrong. I can't think of
one off the top of my head, but the issues arise in ambiguous languages,
like AG Natural,

The problem is that we must assume that the grammar is correct, and that it
describes the intended language, so when an error is reported it is against
the input string. Talking about furthest-error or furthest-with-cut error
makes sense because just rejecting the input string is not enough in
practical applications. The expected error message is of the kind of: "the
string appeared to be part of the language up to _here_, and...".


-- 
Juancarlo *Añez*
_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to