diff --git a/lib/compiler/passes/generate-js.js b/lib/compiler/passes/generate-js.js index f566ff9..33efe44 100644 --- a/lib/compiler/passes/generate-js.js +++ b/lib/compiler/passes/generate-js.js @@ -746,9 +746,9 @@ function generateJS(ast, options) { parts.push([ "function peg$subclass(child, parent) {", - " function ctor() { this.constructor = child; }", - " ctor.prototype = parent.prototype;", - " child.prototype = new ctor();", + " function C() { this.constructor = child; }", + " C.prototype = parent.prototype;", + " child.prototype = new C();", "}", "", "function peg$SyntaxError(message, expected, found, location) {", @@ -781,11 +781,11 @@ function generateJS(ast, options) { " return \"[\" + (expectation.inverted ? \"^\" : \"\") + escapedParts + \"]\";", " },", "", - " any: function(expectation) {", + " any: function() {", " return \"any character\";", " },", "", - " end: function(expectation) {", + " end: function() {", " return \"end of input\";", " },", "", @@ -1039,7 +1039,9 @@ function generateJS(ast, options) { " }", "", " function expected(description, location) {", - " location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos);", + " location = location !== undefined", + " ? location", + " : peg$computeLocation(peg$savedPos, peg$currPos);", "", " throw peg$buildStructuredError(", " [peg$otherExpectation(description)],", @@ -1049,7 +1051,9 @@ function generateJS(ast, options) { " }", "", " function error(message, location) {", - " location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos);", + " location = location !== undefined", + " ? location", + " : peg$computeLocation(peg$savedPos, peg$currPos);", "", " throw peg$buildSimpleError(message, location);", " }", @@ -1104,6 +1108,7 @@ function generateJS(ast, options) { " }", "", " peg$posDetailsCache[pos] = details;", + "", " return details;", " }", " }", diff --git a/lib/parser.js b/lib/parser.js index cb8c5a5..bd1edea 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -5,9 +5,9 @@ "use strict"; function peg$subclass(child, parent) { - function ctor() { this.constructor = child; } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); + function C() { this.constructor = child; } + C.prototype = parent.prototype; + child.prototype = new C(); } function peg$SyntaxError(message, expected, found, location) { @@ -40,11 +40,11 @@ peg$SyntaxError.buildMessage = function(expected, found) { return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; }, - any: function(expectation) { + any: function() { return "any character"; }, - end: function(expectation) { + end: function() { return "end of input"; }, @@ -507,7 +507,9 @@ function peg$parse(input, options) { } function expected(description, location) { - location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos); + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError( [peg$otherExpectation(description)], @@ -517,7 +519,9 @@ function peg$parse(input, options) { } function error(message, location) { - location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos); + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location); } @@ -572,6 +576,7 @@ function peg$parse(input, options) { } peg$posDetailsCache[pos] = details; + return details; } }