P --
> (however the error message is strange...)
Yep. Getting parsers of any ilk to emit good error messages is darned
close to a black art, and pegs are no exception. The core problem is
that, for any unparsable string S there are mindbogglingly many ways it
could have parsed if only it had been different in some way. Selecting
which subset of these correspond to the intended parsing is a necessary
precursor to producing a good error message. It is also far beyond the
scope of a parser generator, and perhaps even brushes up against AI.
As a more tractable substitute people have tried:
* Just reporting the error as a generic "syntax error" at the
furthest point that was successfully parsed (would have helped
in your case)
* Adding special rules to the grammar that only match on an error,
and then (when the total parse fails) reporting the last of
these
* Like above, but having the error rules always report and then
skip ahead to some keyword that lets the parser recover and
continue
* Building a suite of expected errors (this could be as simple as
annotating your test cases) and mapping from the failure mode to
a more human friendly message.
http://people.via.ecp.fr/~stilgar/doc/compilo/parser/Generating%
20LR%20Syntax%20Error%20Messages.pdf
* Half a dozen other techniques, which (from a quick google) all
sound even more complicated to implement.
Failing all that, you can do what most people do and just grumble about
how bad the error messages are, secure in the knowledge that your
sentiment is widely shared.
-- M