Browse Source

Restore silentFails guard for rule$expects

master
Futago-za Ryuu 5 years ago
parent
commit
d06a5b52ef
  1. 4
      lib/compiler/passes/generate-js.js
  2. 256
      lib/parser/index.js

4
lib/compiler/passes/generate-js.js

@ -148,7 +148,9 @@ function generateJS( ast, options ) {
parts.push( [
"",
"var rule$expects = peg$expect;",
"var rule$expects = function (expected) {",
" if (peg$silentFails === 0) peg$expect(expected);",
"}",
""
].join( "\n" ) );

256
lib/parser/index.js

@ -540,7 +540,9 @@ function peg$parse(input, options) {
function peg$parseGrammar() {
var s0, s1, s2, s3, s4, s5, s6;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parse__();
@ -599,7 +601,9 @@ function peg$parse(input, options) {
function peg$parseInitializer() {
var s0, s1, s2;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseCodeBlock();
@ -623,7 +627,9 @@ function peg$parse(input, options) {
function peg$parseRule() {
var s0, s1, s2, s3, s4, s5, s6, s7;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseIdentifierName();
@ -680,7 +686,9 @@ function peg$parse(input, options) {
function peg$parseChoiceExpression() {
var s0, s1, s2, s3, s4, s5, s6, s7;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseActionExpression();
@ -748,7 +756,9 @@ function peg$parse(input, options) {
function peg$parseActionExpression() {
var s0, s1, s2, s3, s4;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseSequenceExpression();
@ -779,7 +789,9 @@ function peg$parse(input, options) {
function peg$parseSequenceExpression() {
var s0, s1, s2, s3, s4, s5;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseLabeledExpression();
@ -821,7 +833,9 @@ function peg$parse(input, options) {
function peg$parseLabeledExpression() {
var s0, s1, s2, s3, s4, s5;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseIdentifier();
@ -862,7 +876,9 @@ function peg$parse(input, options) {
function peg$parsePrefixedExpression() {
var s0, s1, s2, s3;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parsePrefixedOperator();
@ -890,7 +906,9 @@ function peg$parse(input, options) {
function peg$parsePrefixedOperator() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e3);
if (input.charCodeAt(peg$currPos) === 36) {
@ -924,7 +942,9 @@ function peg$parse(input, options) {
function peg$parseSuffixedExpression() {
var s0, s1, s2, s3;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parsePrimaryExpression();
@ -952,7 +972,9 @@ function peg$parse(input, options) {
function peg$parseSuffixedOperator() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e6);
if (input.charCodeAt(peg$currPos) === 63) {
@ -986,7 +1008,9 @@ function peg$parse(input, options) {
function peg$parsePrimaryExpression() {
var s0, s1, s2, s3, s4, s5;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$parseLiteralMatcher();
if (s0 === peg$FAILED) {
@ -1045,7 +1069,9 @@ function peg$parse(input, options) {
function peg$parseRuleReferenceExpression() {
var s0, s1, s2, s3, s4, s5, s6, s7;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseIdentifierName();
@ -1106,7 +1132,9 @@ function peg$parse(input, options) {
function peg$parseSemanticPredicateExpression() {
var s0, s1, s2, s3;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseSemanticPredicateOperator();
@ -1131,7 +1159,9 @@ function peg$parse(input, options) {
function peg$parseSemanticPredicateOperator() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e4);
if (input.charCodeAt(peg$currPos) === 38) {
@ -1156,7 +1186,9 @@ function peg$parse(input, options) {
function peg$parseSourceCharacter() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e11);
if (input.length > peg$currPos) {
@ -1172,7 +1204,9 @@ function peg$parse(input, options) {
function peg$parseWhiteSpace() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e12);
peg$silentFails++;
@ -1233,7 +1267,9 @@ function peg$parse(input, options) {
function peg$parseLineTerminator() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e13);
if (peg$r0.test(input.charAt(peg$currPos))) {
@ -1249,7 +1285,9 @@ function peg$parse(input, options) {
function peg$parseLineTerminatorSequence() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e14);
peg$silentFails++;
@ -1299,7 +1337,9 @@ function peg$parse(input, options) {
function peg$parseComment() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e15);
peg$silentFails++;
@ -1315,7 +1355,9 @@ function peg$parse(input, options) {
function peg$parseMultiLineComment() {
var s0, s1, s2, s3, s4, s5;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
if (input.substr(peg$currPos, 2) === peg$c22) {
@ -1411,7 +1453,9 @@ function peg$parse(input, options) {
function peg$parseMultiLineCommentNoLineTerminator() {
var s0, s1, s2, s3, s4, s5;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
rule$expects(peg$e16);
@ -1517,7 +1561,9 @@ function peg$parse(input, options) {
function peg$parseSingleLineComment() {
var s0, s1, s2, s3, s4, s5;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
rule$expects(peg$e18);
@ -1593,7 +1639,9 @@ function peg$parse(input, options) {
function peg$parseIdentifier() {
var s0, s1;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseIdentifierName();
@ -1609,7 +1657,9 @@ function peg$parse(input, options) {
function peg$parseIdentifierName() {
var s0, s1, s2, s3;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e19);
peg$silentFails++;
@ -1636,7 +1686,9 @@ function peg$parse(input, options) {
function peg$parseIdentifierStart() {
var s0, s1, s2;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$parseUnicodeLetter();
if (s0 === peg$FAILED) {
@ -1684,7 +1736,9 @@ function peg$parse(input, options) {
function peg$parseIdentifierPart() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$parseIdentifierStart();
if (s0 === peg$FAILED) {
@ -1719,7 +1773,9 @@ function peg$parse(input, options) {
function peg$parseUnicodeLetter() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$parseLu();
if (s0 === peg$FAILED) {
@ -1744,7 +1800,9 @@ function peg$parse(input, options) {
function peg$parseUnicodeCombiningMark() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$parseMn();
if (s0 === peg$FAILED) {
@ -1757,7 +1815,9 @@ function peg$parse(input, options) {
function peg$parseLiteralMatcher() {
var s0, s1, s2;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e20);
peg$silentFails++;
@ -1787,7 +1847,9 @@ function peg$parse(input, options) {
function peg$parseStringLiteral() {
var s0, s1, s2, s3;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e21);
peg$silentFails++;
@ -1863,7 +1925,9 @@ function peg$parse(input, options) {
function peg$parseDoubleStringCharacter() {
var s0, s1, s2;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$currPos;
@ -1937,7 +2001,9 @@ function peg$parse(input, options) {
function peg$parseSingleStringCharacter() {
var s0, s1, s2;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$currPos;
@ -2011,7 +2077,9 @@ function peg$parse(input, options) {
function peg$parseCharacterClassMatcher() {
var s0, s1, s2, s3, s4, s5;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e22);
peg$silentFails++;
@ -2078,7 +2146,9 @@ function peg$parse(input, options) {
function peg$parseClassCharacterRange() {
var s0, s1, s2, s3;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parseClassCharacter();
@ -2113,7 +2183,9 @@ function peg$parse(input, options) {
function peg$parseClassCharacter() {
var s0, s1, s2;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$currPos;
@ -2187,7 +2259,9 @@ function peg$parse(input, options) {
function peg$parseLineContinuation() {
var s0, s1, s2;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 92) {
@ -2216,7 +2290,9 @@ function peg$parse(input, options) {
function peg$parseEscapeSequence() {
var s0, s1, s2, s3;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$parseCharacterEscapeSequence();
if (s0 === peg$FAILED) {
@ -2263,7 +2339,9 @@ function peg$parse(input, options) {
function peg$parseCharacterEscapeSequence() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$parseSingleEscapeCharacter();
if (s0 === peg$FAILED) {
@ -2276,7 +2354,9 @@ function peg$parse(input, options) {
function peg$parseSingleEscapeCharacter() {
var s0, s1;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (input.charCodeAt(peg$currPos) === 39) {
s0 = peg$c31;
@ -2391,7 +2471,9 @@ function peg$parse(input, options) {
function peg$parseNonEscapeCharacter() {
var s0, s1, s2;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$currPos;
@ -2427,7 +2509,9 @@ function peg$parse(input, options) {
function peg$parseEscapeCharacter() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$parseSingleEscapeCharacter();
if (s0 === peg$FAILED) {
@ -2456,7 +2540,9 @@ function peg$parse(input, options) {
function peg$parseHexEscapeSequence() {
var s0, s1, s2, s3, s4, s5;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 120) {
@ -2505,7 +2591,9 @@ function peg$parse(input, options) {
function peg$parseUnicodeEscapeSequence() {
var s0, s1, s2, s3, s4, s5, s6, s7;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 117) {
@ -2566,7 +2654,9 @@ function peg$parse(input, options) {
function peg$parseDecimalDigit() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r1.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2581,7 +2671,9 @@ function peg$parse(input, options) {
function peg$parseHexDigit() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r2.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2596,7 +2688,9 @@ function peg$parse(input, options) {
function peg$parseAnyMatcher() {
var s0, s1;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
rule$expects(peg$e23);
@ -2618,7 +2712,9 @@ function peg$parse(input, options) {
function peg$parseCodeBlock() {
var s0, s1, s2, s3;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
rule$expects(peg$e24);
peg$silentFails++;
@ -2670,7 +2766,9 @@ function peg$parse(input, options) {
function peg$parseCode() {
var s0, s1, s2, s3, s4, s5;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = [];
@ -2873,7 +2971,9 @@ function peg$parse(input, options) {
function peg$parseLl() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r4.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2888,7 +2988,9 @@ function peg$parse(input, options) {
function peg$parseLm() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r5.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2903,7 +3005,9 @@ function peg$parse(input, options) {
function peg$parseLo() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r6.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2918,7 +3022,9 @@ function peg$parse(input, options) {
function peg$parseLt() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r7.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2933,7 +3039,9 @@ function peg$parse(input, options) {
function peg$parseLu() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r8.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2948,7 +3056,9 @@ function peg$parse(input, options) {
function peg$parseMc() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r9.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2963,7 +3073,9 @@ function peg$parse(input, options) {
function peg$parseMn() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r10.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2978,7 +3090,9 @@ function peg$parse(input, options) {
function peg$parseNd() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r11.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -2993,7 +3107,9 @@ function peg$parse(input, options) {
function peg$parseNl() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r12.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -3008,7 +3124,9 @@ function peg$parse(input, options) {
function peg$parsePc() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r13.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -3023,7 +3141,9 @@ function peg$parse(input, options) {
function peg$parseZs() {
var s0;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
if (peg$r14.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);
@ -3038,7 +3158,9 @@ function peg$parse(input, options) {
function peg$parse__() {
var s0, s1;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = [];
s1 = peg$parseWhiteSpace();
@ -3065,7 +3187,9 @@ function peg$parse(input, options) {
function peg$parse_() {
var s0, s1;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = [];
s1 = peg$parseWhiteSpace();
@ -3086,7 +3210,9 @@ function peg$parse(input, options) {
function peg$parseEOS() {
var s0, s1, s2, s3;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
s1 = peg$parse__();
@ -3139,7 +3265,9 @@ function peg$parse(input, options) {
function peg$parseEOF() {
var s0, s1;
var rule$expects = peg$expect;
var rule$expects = function (expected) {
if (peg$silentFails === 0) peg$expect(expected);
}
s0 = peg$currPos;
peg$begin();

Loading…
Cancel
Save