Browse Source

Setup prototype chain for |PEG.GrammarError| correctly

redux
David Majda 9 years ago
parent
commit
143924357b
  1. 5
      src/peg.js
  2. 6
      src/utils.js

5
src/peg.js

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

6
src/utils.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.
*

Loading…
Cancel
Save