zaach/jison — pull request #147 by GerHobbelt (2013-02-16 01:48:02+00:00)
Title: Pullreq 5 - parser built-in grammar error recovery was completely b0rked (it would never act): fixed. Now searches for the nearest error rule and resolves to that one.

quick manual extract of these:

SHA-1: 24e36a5e99f8063df1be4401071cb558ae61c97f

* adjusted the code to remove the error recovery from the run-time when no error recovery rules are included in the user-provided grammar. (The correction was necessary as the run-time has been altered in the previous commits.)

SHA-1: d48466f5ef57d4dfc1ff6f0b78e12afd1f8983dd

* fixes error recovery logic in the parser run-time (tested & verified using the errorlab.js test file): previously 5 tests would fail, but after this fix, all pass.

The loop which looks for a matching error rule has been abstracted out into the function locateNearestErrorRecoveryRule() because the first cause for failed the tests was the parseError() handler firing before the erorr recovery could kick in: this (and user-defined) parseError handlers need a way to detect whether an error recovery rule is available (via the hash.recoverable boolean).

The tests also uncovered an infinitely loop in error recovery in the new code when the lexer hits EOF. This bug has been fixed.

**WARNING**: a heads up: this code has been tested but not extensively; knowing myself there's probably lurking a python in the grass here. Anyway, it's WAY better than what was because what was did nada.