Changed order of parameters in the SyntaxError constructor to make creating error with unknown location easier. Also fixes bug with reporting of invalid ranges such as [b-a] in the metagrammar.

redux
David Majda 14 years ago
parent 00a258d246
commit 796c98bf8e

@ -181,9 +181,9 @@ PEG.Parser.prototype = {
if (result === null || this._pos !== input.length) { if (result === null || this._pos !== input.length) {
var errorPosition = computeErrorPosition(); var errorPosition = computeErrorPosition();
throw new PEG.Parser.SyntaxError( throw new PEG.Parser.SyntaxError(
buildErrorMessage(),
errorPosition.line, errorPosition.line,
errorPosition.column, errorPosition.column
buildErrorMessage()
); );
} }
@ -230,11 +230,11 @@ PEG.Parser.NamedRuleMatchFailure.prototype = {
/* Thrown when a parser encounters a syntax error. */ /* Thrown when a parser encounters a syntax error. */
PEG.Parser.SyntaxError = function(line, column, message) { PEG.Parser.SyntaxError = function(message, line, column) {
this.name = "PEG.Parser.SyntaxError"; this.name = "PEG.Parser.SyntaxError";
this.message = message;
this.line = line; this.line = line;
this.column = column; this.column = column;
this.message = message;
}; };
PEG.Parser.SyntaxError.prototype = Error.prototype; PEG.Parser.SyntaxError.prototype = Error.prototype;

Loading…
Cancel
Save