diff --git a/lib/compiler.js b/lib/compiler.js index 752d647..1dcdcc9 100644 --- a/lib/compiler.js +++ b/lib/compiler.js @@ -915,6 +915,10 @@ PEG.Compiler = { " },", " ", " _matchFailed: function(failure) {", + " if (this._pos < this._rightmostMatchFailuresPos) {", + " return;", + " }", + " ", " if (this._pos > this._rightmostMatchFailuresPos) {", " this._rightmostMatchFailuresPos = this._pos;", " this._rightmostMatchFailuresExpected = [];", diff --git a/lib/metagrammar.js b/lib/metagrammar.js index ea0b4d6..f1566c3 100644 --- a/lib/metagrammar.js +++ b/lib/metagrammar.js @@ -36,6 +36,10 @@ PEG.grammarParser = (function(){ }, _matchFailed: function(failure) { + if (this._pos < this._rightmostMatchFailuresPos) { + return; + } + if (this._pos > this._rightmostMatchFailuresPos) { this._rightmostMatchFailuresPos = this._pos; this._rightmostMatchFailuresExpected = [];