@ -745,6 +745,7 @@ module.exports = function(ast, options) {
' peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },' ,
' peg$cachedPosDetails = { line: 1, column: 1, seenCR: false },' ,
' peg$maxFailPos = 0,' ,
' peg$maxFailPos = 0,' ,
' peg$maxFailExpected = [],' ,
' peg$maxFailExpected = [],' ,
' peg$maxFailMessage = null,' ,
' peg$silentFails = 0,' , // 0 = report failures, > 0 = silence failures
' peg$silentFails = 0,' , // 0 = report failures, > 0 = silence failures
' peg$userFail = false,' ,
' peg$userFail = false,' ,
''
''
@ -809,6 +810,13 @@ module.exports = function(ast, options) {
' peg$userFail = true;' ,
' peg$userFail = true;' ,
' }' ,
' }' ,
'' ,
'' ,
' function error(message) {' ,
' if (peg$silentFails === 0) {' ,
' peg$error(message, peg$reportedPos);' ,
' }' ,
' peg$userFail = true;' ,
' }' ,
'' ,
' function peg$computePosDetails(pos) {' ,
' function peg$computePosDetails(pos) {' ,
' function advance(details, startPos, endPos) {' ,
' function advance(details, startPos, endPos) {' ,
' var p, ch;' ,
' var p, ch;' ,
@ -848,11 +856,24 @@ module.exports = function(ast, options) {
' if (pos > peg$maxFailPos) {' ,
' if (pos > peg$maxFailPos) {' ,
' peg$maxFailPos = pos;' ,
' peg$maxFailPos = pos;' ,
' peg$maxFailExpected = [];' ,
' peg$maxFailExpected = [];' ,
' peg$maxFailMessage = null;' ,
' }' ,
' }' ,
'' ,
'' ,
' peg$maxFailExpected.push(expected);' ,
' peg$maxFailExpected.push(expected);' ,
' }' ,
' }' ,
'' ,
'' ,
' function peg$error(message, pos) {' ,
' if (pos < peg$maxFailPos) { return; }' ,
'' ,
' if (pos > peg$maxFailPos) {' ,
' peg$maxFailPos = pos;' ,
' peg$maxFailExpected = [];' ,
' peg$maxFailMessage = null;' ,
' }' ,
'' ,
' peg$maxFailMessage = message;' ,
' }' ,
'' ,
' function peg$buildException() {' ,
' function peg$buildException() {' ,
' function cleanupExpected(expected) {' ,
' function cleanupExpected(expected) {' ,
' var i = 1;' ,
' var i = 1;' ,
@ -934,13 +955,19 @@ module.exports = function(ast, options) {
'' ,
'' ,
' var pos = Math.max(peg$currPos, peg$maxFailPos),' ,
' var pos = Math.max(peg$currPos, peg$maxFailPos),' ,
' posDetails = peg$computePosDetails(pos),' ,
' posDetails = peg$computePosDetails(pos),' ,
' found = pos < input.length ? input.charAt(pos) : null;' ,
' expected = peg$maxFailMessage === null ? peg$maxFailExpected : null,' ,
'' ,
' found = pos < input.length ? input.charAt(pos) : null,' ,
' cleanupExpected(peg$maxFailExpected);' ,
' message = peg$maxFailMessage !== null' ,
' ? peg$maxFailMessage' ,
' : buildMessage(expected, found);' ,
'' ,
' if (expected !== null) {' ,
' cleanupExpected(expected);' ,
' }' ,
'' ,
'' ,
' return new SyntaxError(' ,
' return new SyntaxError(' ,
' buildMessage(peg$maxFailExpected, found),' ,
' message ,',
' peg$maxFailExpected,' ,
' expected,',
' found,' ,
' found,' ,
' pos,' ,
' pos,' ,
' posDetails.line,' ,
' posDetails.line,' ,