Next: Memory management, Previous: Bound literals, Up: Top [Contents][Index]
In the event that the parser returns ‘0’ to indicate that the parse
has failed, then you can call char *pacc_error(struct pacc_parser
*) which returns a string indicating the furthest point in the input
which the parser reached, and what it expected to find there.
Consider the following one-rule grammar:
FortySomething <- "forty-" ("four" → { 44 } / "five" → { 45 })
With the input ‘fifty-three’, the parser can make no progress at all,
and pacc_error() returns ‘1:1: expected FortySomething’.
With the input ‘forty-three’, the first 6 characters are
successfully parsed, and pacc_error() returns ‘1:7: expected
"four", or "five"’.
Note that pacc_error() is the default name for the error
function. If you used the ‘--name=NAME’ / ‘-n NAME’ flag, the
error function will be called NAME_error instead.
There are currently some limitations on error handling.
FortySomething ← "forty-"* ("four" → { 44 } / "five" → { 45 })
then the input ‘forty-three’ produces the error ‘1:7: expected FortySomething:*:0, "four", or "five"’
Next: Memory management, Previous: Bound literals, Up: Top [Contents][Index]
Last updated: 2016-08-03 21:39:50 UTC
One thing pacc needs is more users. And, perhaps, one way to get more users is to reduce the friction in getting started with pacc. An obvious lubricant is packaging. Read More...
Looking at _pacc_coords(), I noticed that it seemed to have the same realloc() bug that I'd just fixed in _pacc_result(). However, the "list of arrays" trick really wasn't going to work here. Read More...