Setup prototype chain for |PEG.GrammarError| correctly

redux
David Majda 12 years ago
parent 428fe294cf
commit 143924357b

@ -8,6 +8,8 @@
*/ */
var PEG = (function(undefined) { var PEG = (function(undefined) {
// @include "utils.js"
var PEG = { var PEG = {
/* PEG.js version (uses semantic versioning). */ /* PEG.js version (uses semantic versioning). */
VERSION: "@VERSION", VERSION: "@VERSION",
@ -35,9 +37,8 @@ PEG.GrammarError = function(message) {
this.message = message; this.message = message;
}; };
PEG.GrammarError.prototype = Error.prototype; subclass(PEG.GrammarError, Error);
// @include "utils.js"
// @include "parser.js" // @include "parser.js"
// @include "compiler.js" // @include "compiler.js"

@ -87,6 +87,12 @@ function defaults(object, defaults) {
} }
} }
function subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
/* /*
* Returns a string padded on the left to a desired length with a character. * Returns a string padded on the left to a desired length with a character.
* *

Loading…
Cancel
Save