Error messages now do not contain duplicities.

This commit is contained in:
David Majda 2010-04-11 15:30:02 +02:00
parent 714512f232
commit 37521cffa5
2 changed files with 11 additions and 1 deletions

View file

@ -93,7 +93,10 @@ PEG.Parser.prototype = {
this._rightmostMatchFailuresPos = this._pos;
this._rightmostMatchFailuresExpected = [];
}
if (this._rightmostMatchFailuresExpected.indexOf(failure) === -1) {
this._rightmostMatchFailuresExpected.push(failure);
}
},
/*

View file

@ -456,6 +456,13 @@ test("error messages", function() {
"something",
'Expected end of input but "s" found.'
);
var duplicateErrorParser = PEG.buildParser('start: "a" / "a"');
doesNotParseWithMessage(
duplicateErrorParser,
"",
'Expected "a" but end of input found.'
);
});
test("error positions", function() {