@ -744,13 +744,11 @@ function generateJavascript(ast, options) {
' child.prototype = new ctor();' ,
' }' ,
'' ,
' function peg$SyntaxError(message, expected, found, offset, line, colum n) {',
' function peg$SyntaxError(message, expected, found, locatio n) {',
' this.message = message;' ,
' this.expected = expected;' ,
' this.found = found;' ,
' this.offset = offset;' ,
' this.line = line;' ,
' this.column = column;' ,
' this.location = location;' ,
'' ,
' this.name = "SyntaxError";' ,
' }' ,
@ -929,33 +927,25 @@ function generateJavascript(ast, options) {
' }' ,
'' ,
' function location() {' ,
' var savedPosDetails = peg$computePosDetails(peg$savedPos),' ,
' currPosDetails = peg$computePosDetails(peg$currPos);' ,
'' ,
' return {' ,
' start: {' ,
' offset: peg$savedPos,' ,
' line: savedPosDetails.line,' ,
' column: savedPosDetails.column' ,
' },' ,
' end: {' ,
' offset: peg$currPos,' ,
' line: currPosDetails.line,' ,
' column: currPosDetails.column' ,
' }' ,
' };' ,
' return peg$computeLocation(peg$savedPos, peg$currPos);' ,
' }' ,
'' ,
' function expected(description) {' ,
' throw peg$buildException(' ,
' null,' ,
' [{ type: "other", description: description }],' ,
' peg$savedPos' ,
' input.substring(peg$savedPos, peg$currPos),' ,
' peg$computeLocation(peg$savedPos, peg$currPos)' ,
' );' ,
' }' ,
'' ,
' function error(message) {' ,
' throw peg$buildException(message, null, peg$savedPos);' ,
' throw peg$buildException(' ,
' message,' ,
' null,' ,
' input.substring(peg$savedPos, peg$currPos),' ,
' peg$computeLocation(peg$savedPos, peg$currPos)' ,
' );' ,
' }' ,
'' ,
' function peg$computePosDetails(pos) {' ,
@ -995,6 +985,24 @@ function generateJavascript(ast, options) {
' };' ,
' }' ,
'' ,
' function peg$computeLocation(startPos, endPos) {' ,
' var startPosDetails = peg$computePosDetails(startPos),' ,
' endPosDetails = peg$computePosDetails(endPos);' ,
'' ,
' return {' ,
' start: {' ,
' offset: startPos,' ,
' line: startPosDetails.line,' ,
' column: startPosDetails.column' ,
' },' ,
' end: {' ,
' offset: endPos,' ,
' line: endPosDetails.line,' ,
' column: endPosDetails.column' ,
' }' ,
' };' ,
' }' ,
'' ,
' function peg$fail(expected) {' ,
' if (peg$currPos < peg$maxFailPos) { return; }' ,
'' ,
@ -1006,7 +1014,7 @@ function generateJavascript(ast, options) {
' peg$maxFailExpected.push(expected);' ,
' }' ,
'' ,
' function peg$buildException(message, expected, pos ) {',
' function peg$buildException(message, expected, found, location ) {',
' function cleanupExpected(expected) {' ,
' var i = 1;' ,
'' ,
@ -1080,9 +1088,6 @@ function generateJavascript(ast, options) {
' return "Expected " + expectedDesc + " but " + foundDesc + " found.";' ,
' }' ,
'' ,
' var posDetails = peg$computePosDetails(pos),' ,
' found = pos < input.length ? input.charAt(pos) : null;' ,
'' ,
' if (expected !== null) {' ,
' cleanupExpected(expected);' ,
' }' ,
@ -1091,9 +1096,7 @@ function generateJavascript(ast, options) {
' message !== null ? message : buildMessage(expected, found),' ,
' expected,' ,
' found,' ,
' pos,' ,
' posDetails.line,' ,
' posDetails.column' ,
' location' ,
' );' ,
' }' ,
''
@ -1144,7 +1147,14 @@ function generateJavascript(ast, options) {
' peg$fail({ type: "end", description: "end of input" });' ,
' }' ,
'' ,
' throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);' ,
' throw peg$buildException(' ,
' null,' ,
' peg$maxFailExpected,' ,
' peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,' ,
' peg$maxFailPos < input.length' ,
' ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)' ,
' : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)' ,
' );' ,
' }' ,
' }' ,
'' ,