diff --git a/CHANGELOG.md b/CHANGELOG.md index f2a210dd..64435886 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ Released: TBD from the `options.grammarSource` property. That property can contain arbitrary data,for example, path to the currently parsed file. [@Mingun](https://github.com/peggyjs/peggy/pull/95) +- Several optimizations in the generator. Generated parsers now faster and smaller + [@Mingun](https://github.com/peggyjs/peggy/pull/118) ### Bug fixes diff --git a/lib/parser.js b/lib/parser.js index 7ffbe47e..e0226534 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -677,98 +677,63 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse__(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parseTopLevelInitializer(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 === peg$FAILED) { - s2 = null; - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseInitializer(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 === peg$FAILED) { - s3 = null; - } - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$currPos; - s6 = peg$parseRule(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s6 = [s6, s7]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$currPos; - s6 = peg$parseRule(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s6 = [s6, s7]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } - } else { - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c0(s2, s3, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s2 = peg$currPos; + s3 = peg$parseTopLevelInitializer(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + s3 = [s3, s4]; + s2 = s3; + } else { + peg$currPos = s2; + s2 = peg$FAILED; + } + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = peg$currPos; + s4 = peg$parseInitializer(); + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = null; + } + s4 = []; + s5 = peg$currPos; + s6 = peg$parseRule(); + if (s6 !== peg$FAILED) { + s7 = peg$parse__(); + s6 = [s6, s7]; + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 !== peg$FAILED) { + while (s5 !== peg$FAILED) { + s4.push(s5); + s5 = peg$currPos; + s6 = peg$parseRule(); + if (s6 !== peg$FAILED) { + s7 = peg$parse__(); + s6 = [s6, s7]; + s5 = s6; } else { - peg$currPos = s0; - s0 = peg$FAILED; + peg$currPos = s5; + s5 = peg$FAILED; } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } + } else { + s4 = peg$FAILED; + } + if (s4 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c0(s2, s3, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -852,54 +817,34 @@ function peg$parse(input, options) { s1 = peg$parseIdentifierName(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parseStringLiteral(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 === peg$FAILED) { - s3 = null; - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c7; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c8); } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (s5 !== peg$FAILED) { - s6 = peg$parseChoiceExpression(); - if (s6 !== peg$FAILED) { - s7 = peg$parseEOS(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c9(s1, s3, s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s3 = peg$currPos; + s4 = peg$parseStringLiteral(); + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + s4 = [s4, s5]; + s3 = s4; + } else { + peg$currPos = s3; + s3 = peg$FAILED; + } + if (s3 === peg$FAILED) { + s3 = null; + } + if (input.charCodeAt(peg$currPos) === 61) { + s4 = peg$c7; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c8); } + } + if (s4 !== peg$FAILED) { + s5 = peg$parse__(); + s6 = peg$parseChoiceExpression(); + if (s6 !== peg$FAILED) { + s7 = peg$parseEOS(); + if (s7 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c9(s1, s3, s6); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -929,29 +874,19 @@ function peg$parse(input, options) { s2 = []; s3 = peg$currPos; s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 47) { - s5 = peg$c10; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c11); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseActionExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 47) { + s5 = peg$c10; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c11); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s7 = peg$parseActionExpression(); + if (s7 !== peg$FAILED) { + s4 = [s4, s5, s6, s7]; + s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; @@ -964,29 +899,19 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$currPos; s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 47) { - s5 = peg$c10; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c11); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (s6 !== peg$FAILED) { - s7 = peg$parseActionExpression(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 47) { + s5 = peg$c10; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c11); } + } + if (s5 !== peg$FAILED) { + s6 = peg$parse__(); + s7 = peg$parseActionExpression(); + if (s7 !== peg$FAILED) { + s4 = [s4, s5, s6, s7]; + s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; @@ -996,13 +921,8 @@ function peg$parse(input, options) { s3 = peg$FAILED; } } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c12(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + peg$savedPos = s0; + s0 = peg$c12(s1, s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1019,15 +939,10 @@ function peg$parse(input, options) { if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$parse__(); - if (s3 !== peg$FAILED) { - s4 = peg$parseCodeBlock(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } + s4 = peg$parseCodeBlock(); + if (s4 !== peg$FAILED) { + s3 = [s3, s4]; + s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; @@ -1035,13 +950,8 @@ function peg$parse(input, options) { if (s2 === peg$FAILED) { s2 = null; } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c13(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + peg$savedPos = s0; + s0 = peg$c13(s1, s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1059,15 +969,10 @@ function peg$parse(input, options) { s2 = []; s3 = peg$currPos; s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseLabeledExpression(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } + s5 = peg$parseLabeledExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; @@ -1076,27 +981,17 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$currPos; s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$parseLabeledExpression(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } + s5 = peg$parseLabeledExpression(); + if (s5 !== peg$FAILED) { + s4 = [s4, s5]; + s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c14(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + peg$savedPos = s0; + s0 = peg$c14(s1, s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1121,15 +1016,10 @@ function peg$parse(input, options) { if (s2 === peg$FAILED) { s2 = null; } - if (s2 !== peg$FAILED) { - s3 = peg$parsePrefixedExpression(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c17(s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s3 = peg$parsePrefixedExpression(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c17(s2, s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1143,15 +1033,10 @@ function peg$parse(input, options) { s1 = peg$parseLabelColon(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parsePrefixedExpression(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c18(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s3 = peg$parsePrefixedExpression(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c18(s1, s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1175,20 +1060,15 @@ function peg$parse(input, options) { s1 = peg$parseIdentifier(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 58) { - s3 = peg$c19; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c20); } - } - if (s3 !== peg$FAILED) { - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 58) { + s3 = peg$c19; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c20); } + } + if (s3 !== peg$FAILED) { + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1208,15 +1088,10 @@ function peg$parse(input, options) { s1 = peg$parsePrefixedOperator(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseSuffixedExpression(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c21(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s3 = peg$parseSuffixedExpression(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c21(s1, s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1271,15 +1146,10 @@ function peg$parse(input, options) { s1 = peg$parsePrimaryExpression(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseSuffixedOperator(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c28(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s3 = peg$parseSuffixedOperator(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c28(s1, s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1350,29 +1220,19 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseChoiceExpression(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s5 = peg$c37; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c38); } - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c39(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s3 = peg$parseChoiceExpression(); + if (s3 !== peg$FAILED) { + s4 = peg$parse__(); + if (input.charCodeAt(peg$currPos) === 41) { + s5 = peg$c37; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c38); } + } + if (s5 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c39(s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1404,44 +1264,29 @@ function peg$parse(input, options) { peg$silentFails++; s3 = peg$currPos; s4 = peg$parse__(); - if (s4 !== peg$FAILED) { - s5 = peg$currPos; - s6 = peg$parseStringLiteral(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (s7 !== peg$FAILED) { - s6 = [s6, s7]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - if (s5 === peg$FAILED) { - s5 = null; - } - if (s5 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s6 = peg$c7; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c8); } - } - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } + s5 = peg$currPos; + s6 = peg$parseStringLiteral(); + if (s6 !== peg$FAILED) { + s7 = peg$parse__(); + s6 = [s6, s7]; + s5 = s6; + } else { + peg$currPos = s5; + s5 = peg$FAILED; + } + if (s5 === peg$FAILED) { + s5 = null; + } + if (input.charCodeAt(peg$currPos) === 61) { + s6 = peg$c7; + peg$currPos++; + } else { + s6 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c8); } + } + if (s6 !== peg$FAILED) { + s4 = [s4, s5, s6]; + s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; @@ -1475,15 +1320,10 @@ function peg$parse(input, options) { s1 = peg$parseSemanticPredicateOperator(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); - if (s2 !== peg$FAILED) { - s3 = peg$parseCodeBlock(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c41(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s3 = peg$parseCodeBlock(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c41(s1, s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1764,21 +1604,16 @@ function peg$parse(input, options) { s3 = peg$FAILED; } } - if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c72) { - s3 = peg$c72; - peg$currPos += 2; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c73); } - } - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.substr(peg$currPos, 2) === peg$c72) { + s3 = peg$c72; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1873,21 +1708,16 @@ function peg$parse(input, options) { s3 = peg$FAILED; } } - if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c72) { - s3 = peg$c72; - peg$currPos += 2; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c73); } - } - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.substr(peg$currPos, 2) === peg$c72) { + s3 = peg$c72; + peg$currPos += 2; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c73); } + } + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1964,13 +1794,8 @@ function peg$parse(input, options) { s3 = peg$FAILED; } } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s1 = [s1, s2]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2022,13 +1847,8 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parseIdentifierPart(); } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c77(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + peg$savedPos = s0; + s0 = peg$c77(s1, s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2314,13 +2134,8 @@ function peg$parse(input, options) { if (s2 === peg$FAILED) { s2 = null; } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c90(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + peg$savedPos = s0; + s0 = peg$c90(s1, s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2353,21 +2168,16 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parseDoubleStringCharacter(); } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c92; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c93); } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c94(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 34) { + s3 = peg$c92; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c93); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c94(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2392,21 +2202,16 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parseSingleStringCharacter(); } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 39) { - s3 = peg$c95; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c96); } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c94(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 39) { + s3 = peg$c95; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c96); } + } + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$c94(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -2598,53 +2403,38 @@ function peg$parse(input, options) { if (s2 === peg$FAILED) { s2 = null; } - if (s2 !== peg$FAILED) { - s3 = []; + s3 = []; + s4 = peg$parseClassCharacterRange(); + if (s4 === peg$FAILED) { + s4 = peg$parseClassCharacter(); + } + while (s4 !== peg$FAILED) { + s3.push(s4); s4 = peg$parseClassCharacterRange(); if (s4 === peg$FAILED) { s4 = peg$parseClassCharacter(); } - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parseClassCharacterRange(); - if (s4 === peg$FAILED) { - s4 = peg$parseClassCharacter(); - } - } - if (s3 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 93) { - s4 = peg$c103; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c104); } - } - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 105) { - s5 = peg$c88; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c89); } - } - if (s5 === peg$FAILED) { - s5 = null; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$c105(s2, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + } + if (input.charCodeAt(peg$currPos) === 93) { + s4 = peg$c103; + peg$currPos++; + } else { + s4 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c104); } + } + if (s4 !== peg$FAILED) { + if (input.charCodeAt(peg$currPos) === 105) { + s5 = peg$c88; + peg$currPos++; } else { - peg$currPos = s0; - s0 = peg$FAILED; + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c89); } + } + if (s5 === peg$FAILED) { + s5 = null; } + peg$savedPos = s0; + s0 = peg$c105(s2, s3, s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3210,20 +3000,15 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { s2 = peg$parseCode(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s3 = peg$c3; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c4); } - } - if (s3 !== peg$FAILED) { - s0 = s2; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 125) { + s3 = peg$c3; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c4); } + } + if (s3 !== peg$FAILED) { + s0 = s2; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -3325,21 +3110,16 @@ function peg$parse(input, options) { } if (s3 !== peg$FAILED) { s4 = peg$parseCode(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s5 = peg$c3; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c4); } - } - if (s5 !== peg$FAILED) { - s3 = [s3, s4, s5]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 125) { + s5 = peg$c3; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c4); } + } + if (s5 !== peg$FAILED) { + s3 = [s3, s4, s5]; + s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; @@ -3430,21 +3210,16 @@ function peg$parse(input, options) { } if (s3 !== peg$FAILED) { s4 = peg$parseCode(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s5 = peg$c3; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c4); } - } - if (s5 !== peg$FAILED) { - s3 = [s3, s4, s5]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 125) { + s5 = peg$c3; + peg$currPos++; + } else { + s5 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c4); } + } + if (s5 !== peg$FAILED) { + s3 = [s3, s4, s5]; + s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; @@ -3455,11 +3230,7 @@ function peg$parse(input, options) { } } } - if (s1 !== peg$FAILED) { - s0 = input.substring(s0, peg$currPos); - } else { - s0 = s1; - } + s0 = input.substring(s0, peg$currPos); return s0; } @@ -4999,21 +4770,16 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$parse__(); - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 59) { - s2 = peg$c240; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c241); } - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 59) { + s2 = peg$c240; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$c241); } + } + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5021,24 +4787,14 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parse_(); - if (s1 !== peg$FAILED) { - s2 = peg$parseSingleLineComment(); - if (s2 === peg$FAILED) { - s2 = null; - } - if (s2 !== peg$FAILED) { - s3 = peg$parseLineTerminatorSequence(); - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s2 = peg$parseSingleLineComment(); + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = peg$parseLineTerminatorSequence(); + if (s3 !== peg$FAILED) { + s1 = [s1, s2, s3]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -5046,15 +4802,10 @@ function peg$parse(input, options) { if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parse__(); - if (s1 !== peg$FAILED) { - s2 = peg$parseEOF(); - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s2 = peg$parseEOF(); + if (s2 !== peg$FAILED) { + s1 = [s1, s2]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED;