From 20c13a814b8388199ea81b833834e771ec6f0b74 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 13 Sep 2024 21:54:08 +0200 Subject: [PATCH] lint peggy source files --- dist/main.js | 586 +++++++++++++++++------------------------ eslint.config.mjs | 9 +- package-lock.json | 60 +++++ package.json | 2 + src/cpanfile-peg.mjs | 509 +++++++++++++++-------------------- src/cpanfile-peg.pegjs | 282 +++++++++----------- src/ini-peg.mjs | 103 ++++---- src/ini-peg.pegjs | 47 ++-- 8 files changed, 715 insertions(+), 883 deletions(-) diff --git a/dist/main.js b/dist/main.js index d41c3f6..69e3e6d 100644 --- a/dist/main.js +++ b/dist/main.js @@ -19189,8 +19189,8 @@ function peg$parse(input, options) { options = options !== void 0 ? options : {}; var peg$FAILED = {}; var peg$source = options.grammarSource; - var peg$startRuleFunctions = { start: peg$parsestart }; - var peg$startRuleFunction = peg$parsestart; + var peg$startRuleFunctions = { Start: peg$parseStart }; + var peg$startRuleFunction = peg$parseStart; var peg$c0 = "#"; var peg$c1 = "\n"; var peg$c2 = ";"; @@ -19207,30 +19207,25 @@ function peg$parse(input, options) { var peg$c13 = ")"; var peg$c14 = "<"; var peg$c15 = ">"; - var peg$c16 = '"'; - var peg$c17 = "'"; + var peg$c16 = "'"; + var peg$c17 = '"'; var peg$c18 = "qq"; var peg$c19 = "q"; - var peg$c20 = "configure"; - var peg$c21 = "build"; - var peg$c22 = "test"; - var peg$c23 = "runtime"; - var peg$c24 = "develop"; - var peg$c25 = "use strict"; - var peg$c26 = "use warnings"; - var peg$c27 = "use "; - var peg$c28 = "1"; - var peg$c29 = "sub"; - var peg$c30 = "feature"; - var peg$c31 = "on"; - var peg$c32 = "requires"; - var peg$c33 = "recommends"; - var peg$c34 = "suggests"; - var peg$c35 = "conflicts"; - var peg$c36 = "configure_requires"; - var peg$c37 = "build_requires"; - var peg$c38 = "test_requires"; - var peg$c39 = "author_requires"; + var peg$c20 = "use strict"; + var peg$c21 = "use warnings"; + var peg$c22 = "use "; + var peg$c23 = "1"; + var peg$c24 = "sub"; + var peg$c25 = "feature"; + var peg$c26 = "on"; + var peg$c27 = "requires"; + var peg$c28 = "recommends"; + var peg$c29 = "suggests"; + var peg$c30 = "conflicts"; + var peg$c31 = "configure_requires"; + var peg$c32 = "build_requires"; + var peg$c33 = "test_requires"; + var peg$c34 = "author_requires"; var peg$r0 = /^[ \t\n\r]/; var peg$r1 = /^[^\n]/; var peg$r2 = /^[_a-z]/i; @@ -19241,10 +19236,11 @@ function peg$parse(input, options) { var peg$r7 = /^[^\\}]/; var peg$r8 = /^[^\\)]/; var peg$r9 = /^[^\\>]/; - var peg$r10 = /^[^\\"]/; - var peg$r11 = /^[^\\']/; - var peg$r12 = /^[^\\"$@]/; - var peg$r13 = /^[0-9a-z_']/i; + var peg$r10 = /^[^\\']/; + var peg$r11 = /^[^\\"]/; + var peg$r12 = /^[^\\'$@]/; + var peg$r13 = /^[^\\"$@]/; + var peg$r14 = /^[0-9a-z_']/i; var peg$e0 = peg$classExpectation([" ", " ", "\n", "\r"], false, false); var peg$e1 = peg$literalExpectation("#", false); var peg$e2 = peg$classExpectation(["\n"], true, false); @@ -19272,34 +19268,30 @@ function peg$parse(input, options) { var peg$e24 = peg$literalExpectation("<", false); var peg$e25 = peg$classExpectation(["\\", ">"], true, false); var peg$e26 = peg$literalExpectation(">", false); - var peg$e27 = peg$literalExpectation('"', false); - var peg$e28 = peg$classExpectation(["\\", '"'], true, false); - var peg$e29 = peg$literalExpectation("'", false); - var peg$e30 = peg$classExpectation(["\\", "'"], true, false); - var peg$e31 = peg$classExpectation(["\\", '"', "$", "@"], true, false); - var peg$e32 = peg$literalExpectation("qq", false); - var peg$e33 = peg$literalExpectation("q", false); - var peg$e34 = peg$literalExpectation("configure", false); - var peg$e35 = peg$literalExpectation("build", false); - var peg$e36 = peg$literalExpectation("test", false); - var peg$e37 = peg$literalExpectation("runtime", false); - var peg$e38 = peg$literalExpectation("develop", false); - var peg$e39 = peg$literalExpectation("use strict", false); - var peg$e40 = peg$literalExpectation("use warnings", false); - var peg$e41 = peg$literalExpectation("use ", false); - var peg$e42 = peg$literalExpectation("1", false); - var peg$e43 = peg$classExpectation([["0", "9"], ["a", "z"], "_", "'"], false, true); - var peg$e44 = peg$literalExpectation("sub", false); - var peg$e45 = peg$literalExpectation("feature", false); - var peg$e46 = peg$literalExpectation("on", false); - var peg$e47 = peg$literalExpectation("requires", false); - var peg$e48 = peg$literalExpectation("recommends", false); - var peg$e49 = peg$literalExpectation("suggests", false); - var peg$e50 = peg$literalExpectation("conflicts", false); - var peg$e51 = peg$literalExpectation("configure_requires", false); - var peg$e52 = peg$literalExpectation("build_requires", false); - var peg$e53 = peg$literalExpectation("test_requires", false); - var peg$e54 = peg$literalExpectation("author_requires", false); + var peg$e27 = peg$literalExpectation("'", false); + var peg$e28 = peg$classExpectation(["\\", "'"], true, false); + var peg$e29 = peg$literalExpectation('"', false); + var peg$e30 = peg$classExpectation(["\\", '"'], true, false); + var peg$e31 = peg$classExpectation(["\\", "'", "$", "@"], true, false); + var peg$e32 = peg$classExpectation(["\\", '"', "$", "@"], true, false); + var peg$e33 = peg$literalExpectation("qq", false); + var peg$e34 = peg$literalExpectation("q", false); + var peg$e35 = peg$literalExpectation("use strict", false); + var peg$e36 = peg$literalExpectation("use warnings", false); + var peg$e37 = peg$literalExpectation("use ", false); + var peg$e38 = peg$literalExpectation("1", false); + var peg$e39 = peg$classExpectation([["0", "9"], ["a", "z"], "_", "'"], false, true); + var peg$e40 = peg$literalExpectation("sub", false); + var peg$e41 = peg$literalExpectation("feature", false); + var peg$e42 = peg$literalExpectation("on", false); + var peg$e43 = peg$literalExpectation("requires", false); + var peg$e44 = peg$literalExpectation("recommends", false); + var peg$e45 = peg$literalExpectation("suggests", false); + var peg$e46 = peg$literalExpectation("conflicts", false); + var peg$e47 = peg$literalExpectation("configure_requires", false); + var peg$e48 = peg$literalExpectation("build_requires", false); + var peg$e49 = peg$literalExpectation("test_requires", false); + var peg$e50 = peg$literalExpectation("author_requires", false); var peg$f0 = function(reqs) { return reqs.map((req) => ({ phase: "runtime", @@ -19485,16 +19477,16 @@ function peg$parse(input, options) { location2 ); } - function peg$parsestart() { + function peg$parseStart() { var s0, s1; s0 = peg$currPos; - s1 = peg$parsedeclarations(); + s1 = peg$parseDeclarations(); peg$savedPos = s0; s1 = peg$f0(s1); s0 = s1; return s0; } - function peg$parsews() { + function peg$parseWS() { var s0, s1; s0 = []; s1 = input.charAt(peg$currPos); @@ -19524,7 +19516,7 @@ function peg$parse(input, options) { } return s0; } - function peg$parsecomment() { + function peg$parseComment() { var s0, s1, s2, s3, s4; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 35) { @@ -19631,7 +19623,7 @@ function peg$parse(input, options) { s1 = peg$FAILED; } if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); + s1 = peg$parseComment(); } while (s1 !== peg$FAILED) { s0.push(s1); @@ -19662,26 +19654,26 @@ function peg$parse(input, options) { s1 = peg$FAILED; } if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); + s1 = peg$parseComment(); } } return s0; } - function peg$parsevalue() { + function peg$parseValue() { var s0; - s0 = peg$parseundef(); + s0 = peg$parseUndef(); if (s0 === peg$FAILED) { - s0 = peg$parsestring(); + s0 = peg$parseString(); if (s0 === peg$FAILED) { - s0 = peg$parsevstring(); + s0 = peg$parseVString(); if (s0 === peg$FAILED) { - s0 = peg$parsenumber(); + s0 = peg$parseNumber(); } } } return s0; } - function peg$parsestatement_sep() { + function peg$parseStatementSep() { var s0, s1, s2, s3, s4; s0 = []; s1 = peg$currPos; @@ -19731,7 +19723,7 @@ function peg$parse(input, options) { } return s0; } - function peg$parselist_sep() { + function peg$parseListSep() { var s0, s1, s2, s3, s4; s0 = []; s1 = peg$currPos; @@ -19803,7 +19795,7 @@ function peg$parse(input, options) { } return s0; } - function peg$parsebareword() { + function peg$parseBareword() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = input.charAt(peg$currPos); @@ -19846,11 +19838,11 @@ function peg$parse(input, options) { } return s0; } - function peg$parsequoted_bareword() { + function peg$parseQuotedBareword() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$currPos; - s2 = peg$parsebareword(); + s2 = peg$parseBareword(); if (s2 !== peg$FAILED) { s1 = input.substring(s1, peg$currPos); } else { @@ -19860,7 +19852,7 @@ function peg$parse(input, options) { s2 = peg$currPos; peg$silentFails++; s3 = peg$currPos; - s4 = peg$parsews(); + s4 = peg$parseWS(); if (s4 === peg$FAILED) { s4 = null; } @@ -19899,7 +19891,7 @@ function peg$parse(input, options) { } return s0; } - function peg$parseinteger() { + function peg$parseInteger() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$currPos; @@ -19941,7 +19933,7 @@ function peg$parse(input, options) { s0 = s1; return s0; } - function peg$parsedecimal() { + function peg$parseDecimal() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$currPos; @@ -20032,15 +20024,15 @@ function peg$parse(input, options) { s0 = s1; return s0; } - function peg$parsenumber() { + function peg$parseNumber() { var s0; - s0 = peg$parsedecimal(); + s0 = peg$parseDecimal(); if (s0 === peg$FAILED) { - s0 = peg$parseinteger(); + s0 = peg$parseInteger(); } return s0; } - function peg$parseundef() { + function peg$parseUndef() { var s0, s1; s0 = peg$currPos; if (input.substr(peg$currPos, 5) === peg$c6) { @@ -20059,12 +20051,12 @@ function peg$parse(input, options) { s0 = s1; return s0; } - function peg$parsevstring() { + function peg$parseVString() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = peg$currPos; s2 = []; - s3 = peg$parseinteger(); + s3 = peg$parseInteger(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$currPos; @@ -20078,7 +20070,7 @@ function peg$parse(input, options) { } } if (s4 !== peg$FAILED) { - s4 = peg$parseinteger(); + s4 = peg$parseInteger(); if (s4 === peg$FAILED) { peg$currPos = s3; s3 = peg$FAILED; @@ -20109,7 +20101,7 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { s3 = peg$currPos; s4 = []; - s5 = peg$parseinteger(); + s5 = peg$parseInteger(); while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$currPos; @@ -20123,7 +20115,7 @@ function peg$parse(input, options) { } } if (s6 !== peg$FAILED) { - s6 = peg$parseinteger(); + s6 = peg$parseInteger(); if (s6 === peg$FAILED) { peg$currPos = s5; s5 = peg$FAILED; @@ -20158,7 +20150,7 @@ function peg$parse(input, options) { s0 = s1; return s0; } - function peg$parsepairs() { + function peg$parsePairs() { var s0, s1, s2, s3, s4; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 91) { @@ -20381,7 +20373,7 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { + if (input.charCodeAt(peg$currPos) === 39) { s1 = peg$c16; peg$currPos++; } else { @@ -20415,7 +20407,7 @@ function peg$parse(input, options) { } } s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 34) { + if (input.charCodeAt(peg$currPos) === 39) { s3 = peg$c16; peg$currPos++; } else { @@ -20436,7 +20428,7 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { + if (input.charCodeAt(peg$currPos) === 34) { s1 = peg$c17; peg$currPos++; } else { @@ -20470,7 +20462,7 @@ function peg$parse(input, options) { } } s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 39) { + if (input.charCodeAt(peg$currPos) === 34) { s3 = peg$c17; peg$currPos++; } else { @@ -20496,10 +20488,10 @@ function peg$parse(input, options) { } return s0; } - function peg$parsestring() { + function peg$parseString() { var s0, s1, s2, s3, s4; s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { + if (input.charCodeAt(peg$currPos) === 39) { s1 = peg$c16; peg$currPos++; } else { @@ -20533,7 +20525,7 @@ function peg$parse(input, options) { } } s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 34) { + if (input.charCodeAt(peg$currPos) === 39) { s3 = peg$c16; peg$currPos++; } else { @@ -20554,7 +20546,7 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { + if (input.charCodeAt(peg$currPos) === 34) { s1 = peg$c17; peg$currPos++; } else { @@ -20567,28 +20559,28 @@ function peg$parse(input, options) { s2 = peg$currPos; s3 = []; s4 = input.charAt(peg$currPos); - if (peg$r11.test(s4)) { + if (peg$r13.test(s4)) { peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e30); + peg$fail(peg$e32); } } while (s4 !== peg$FAILED) { s3.push(s4); s4 = input.charAt(peg$currPos); - if (peg$r11.test(s4)) { + if (peg$r13.test(s4)) { peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e30); + peg$fail(peg$e32); } } } s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 39) { + if (input.charCodeAt(peg$currPos) === 34) { s3 = peg$c17; peg$currPos++; } else { @@ -20615,11 +20607,11 @@ function peg$parse(input, options) { } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e32); + peg$fail(peg$e33); } } if (s1 !== peg$FAILED) { - s2 = peg$parsepairs(); + s2 = peg$parsePairs(); if (s2 !== peg$FAILED) { s0 = s2; } else { @@ -20638,11 +20630,11 @@ function peg$parse(input, options) { } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e33); + peg$fail(peg$e34); } } if (s1 !== peg$FAILED) { - s2 = peg$parsepairs(); + s2 = peg$parsePairs(); if (s2 !== peg$FAILED) { s0 = s2; } else { @@ -20658,87 +20650,30 @@ function peg$parse(input, options) { } return s0; } - function peg$parsephase() { + function peg$parseParameter() { var s0; - if (input.substr(peg$currPos, 9) === peg$c20) { - s0 = peg$c20; - peg$currPos += 9; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e34); - } - } + s0 = peg$parseValue(); if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c21) { - s0 = peg$c21; - peg$currPos += 5; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e35); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c22) { - s0 = peg$c22; - peg$currPos += 4; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e36); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 7) === peg$c23) { - s0 = peg$c23; - peg$currPos += 7; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e37); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 7) === peg$c24) { - s0 = peg$c24; - peg$currPos += 7; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e38); - } - } - } - } - } + s0 = peg$parseQuotedBareword(); } return s0; } - function peg$parseparameter() { - var s0; - s0 = peg$parsevalue(); - if (s0 === peg$FAILED) { - s0 = peg$parsequoted_bareword(); - } - return s0; - } - function peg$parseparameters() { + function peg$parseParameters() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - s1 = peg$parselist_sep(); + s1 = peg$parseListSep(); if (s1 === peg$FAILED) { s1 = null; } s2 = peg$currPos; s3 = []; - s4 = peg$parseparameter(); + s4 = peg$parseParameter(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$currPos; - s5 = peg$parselist_sep(); + s5 = peg$parseListSep(); if (s5 !== peg$FAILED) { - s5 = peg$parseparameter(); + s5 = peg$parseParameter(); if (s5 === peg$FAILED) { peg$currPos = s4; s4 = peg$FAILED; @@ -20756,7 +20691,7 @@ function peg$parse(input, options) { s2 = s3; } if (s2 !== peg$FAILED) { - s3 = peg$parselist_sep(); + s3 = peg$parseListSep(); if (s3 === peg$FAILED) { s3 = null; } @@ -20767,36 +20702,36 @@ function peg$parse(input, options) { } return s0; } - function peg$parsepragma() { + function peg$parsePragma() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; - if (input.substr(peg$currPos, 10) === peg$c25) { - s0 = peg$c25; + if (input.substr(peg$currPos, 10) === peg$c20) { + s0 = peg$c20; peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e39); + peg$fail(peg$e35); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 12) === peg$c26) { - s0 = peg$c26; + if (input.substr(peg$currPos, 12) === peg$c21) { + s0 = peg$c21; peg$currPos += 12; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e40); + peg$fail(peg$e36); } } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c27) { - s1 = peg$c27; + if (input.substr(peg$currPos, 4) === peg$c22) { + s1 = peg$c22; peg$currPos += 4; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e41); + peg$fail(peg$e37); } } if (s1 !== peg$FAILED) { @@ -20936,24 +20871,24 @@ function peg$parse(input, options) { } return s0; } - function peg$parsedeclarations() { + function peg$parseDeclarations() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$parse_(); - s2 = peg$parsestatement_sep(); + s2 = peg$parseStatementSep(); if (s2 === peg$FAILED) { s2 = null; } s3 = []; s4 = peg$currPos; s5 = []; - s6 = peg$parserequirement(); + s6 = peg$parseRequirement(); while (s6 !== peg$FAILED) { s5.push(s6); if (s5.length >= 1) { s6 = peg$FAILED; } else { - s6 = peg$parserequirement(); + s6 = peg$parseRequirement(); } } if (s5.length < 1) { @@ -20963,12 +20898,12 @@ function peg$parse(input, options) { s4 = s5; } if (s4 === peg$FAILED) { - s4 = peg$parsephase_block(); + s4 = peg$parsePhaseBlock(); if (s4 === peg$FAILED) { - s4 = peg$parsefeature_block(); + s4 = peg$parseFeatureBlock(); if (s4 === peg$FAILED) { s4 = peg$currPos; - s5 = peg$parsepragma(); + s5 = peg$parsePragma(); if (s5 !== peg$FAILED) { peg$savedPos = s4; s5 = peg$f5(); @@ -20977,12 +20912,12 @@ function peg$parse(input, options) { if (s4 === peg$FAILED) { s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 49) { - s5 = peg$c28; + s5 = peg$c23; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e42); + peg$fail(peg$e38); } } if (s5 !== peg$FAILED) { @@ -20997,17 +20932,17 @@ function peg$parse(input, options) { while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$currPos; - s5 = peg$parsestatement_sep(); + s5 = peg$parseStatementSep(); if (s5 !== peg$FAILED) { s5 = peg$currPos; s6 = []; - s7 = peg$parserequirement(); + s7 = peg$parseRequirement(); while (s7 !== peg$FAILED) { s6.push(s7); if (s6.length >= 1) { s7 = peg$FAILED; } else { - s7 = peg$parserequirement(); + s7 = peg$parseRequirement(); } } if (s6.length < 1) { @@ -21017,12 +20952,12 @@ function peg$parse(input, options) { s5 = s6; } if (s5 === peg$FAILED) { - s5 = peg$parsephase_block(); + s5 = peg$parsePhaseBlock(); if (s5 === peg$FAILED) { - s5 = peg$parsefeature_block(); + s5 = peg$parseFeatureBlock(); if (s5 === peg$FAILED) { s5 = peg$currPos; - s6 = peg$parsepragma(); + s6 = peg$parsePragma(); if (s6 !== peg$FAILED) { peg$savedPos = s5; s6 = peg$f5(); @@ -21031,12 +20966,12 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = peg$currPos; if (input.charCodeAt(peg$currPos) === 49) { - s6 = peg$c28; + s6 = peg$c23; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e42); + peg$fail(peg$e38); } } if (s6 !== peg$FAILED) { @@ -21058,7 +20993,7 @@ function peg$parse(input, options) { s4 = s5; } } - s4 = peg$parsestatement_sep(); + s4 = peg$parseStatementSep(); if (s4 === peg$FAILED) { s4 = null; } @@ -21067,22 +21002,22 @@ function peg$parse(input, options) { s0 = peg$f7(s3); return s0; } - function peg$parseend_bareword() { + function peg$parseEndBareword() { var s0, s1, s2, s3; s0 = peg$currPos; peg$silentFails++; s1 = input.charAt(peg$currPos); - if (peg$r13.test(s1)) { + if (peg$r14.test(s1)) { peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e43); + peg$fail(peg$e39); } } if (s1 === peg$FAILED) { s1 = peg$currPos; - s2 = peg$parsews(); + s2 = peg$parseWS(); if (s2 === peg$FAILED) { s2 = null; } @@ -21112,51 +21047,17 @@ function peg$parse(input, options) { } return s0; } - function peg$parserequirements() { - var s0, s1, s2, s3, s4, s5; - s0 = peg$currPos; - s1 = peg$parse_(); - s2 = peg$parsestatement_sep(); - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = []; - s4 = peg$parserequirement(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$currPos; - s5 = peg$parsestatement_sep(); - if (s5 !== peg$FAILED) { - s5 = peg$parserequirement(); - if (s5 === peg$FAILED) { - peg$currPos = s4; - s4 = peg$FAILED; - } else { - s4 = s5; - } - } else { - s4 = s5; - } - } - s4 = peg$parsestatement_sep(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parse_(); - s0 = s3; - return s0; - } - function peg$parsefeature_block_params() { + function peg$parseFeatureBlockParams() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; - s1 = peg$parseparameter(); + s1 = peg$parseParameter(); if (s1 !== peg$FAILED) { - s2 = peg$parselist_sep(); + s2 = peg$parseListSep(); if (s2 !== peg$FAILED) { s3 = peg$currPos; - s4 = peg$parseparameter(); + s4 = peg$parseParameter(); if (s4 !== peg$FAILED) { - s5 = peg$parselist_sep(); + s5 = peg$parseListSep(); if (s5 !== peg$FAILED) { s3 = s4; } else { @@ -21170,13 +21071,13 @@ function peg$parse(input, options) { if (s3 === peg$FAILED) { s3 = null; } - if (input.substr(peg$currPos, 3) === peg$c29) { - s4 = peg$c29; + if (input.substr(peg$currPos, 3) === peg$c24) { + s4 = peg$c24; peg$currPos += 3; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e44); + peg$fail(peg$e40); } } if (s4 !== peg$FAILED) { @@ -21191,7 +21092,7 @@ function peg$parse(input, options) { } } if (s6 !== peg$FAILED) { - s7 = peg$parsedeclarations(); + s7 = peg$parseDeclarations(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s8 = peg$c11; @@ -21231,20 +21132,20 @@ function peg$parse(input, options) { } return s0; } - function peg$parsefeature_block() { + function peg$parseFeatureBlock() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; - if (input.substr(peg$currPos, 7) === peg$c30) { - s1 = peg$c30; + if (input.substr(peg$currPos, 7) === peg$c25) { + s1 = peg$c25; peg$currPos += 7; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e45); + peg$fail(peg$e41); } } if (s1 !== peg$FAILED) { - s2 = peg$parseend_bareword(); + s2 = peg$parseEndBareword(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); s4 = peg$currPos; @@ -21259,7 +21160,7 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { s6 = peg$parse_(); - s7 = peg$parsefeature_block_params(); + s7 = peg$parseFeatureBlockParams(); if (s7 !== peg$FAILED) { s8 = peg$parse_(); if (input.charCodeAt(peg$currPos) === 41) { @@ -21287,7 +21188,7 @@ function peg$parse(input, options) { } if (s4 === peg$FAILED) { s4 = peg$currPos; - s5 = peg$parsefeature_block_params(); + s5 = peg$parseFeatureBlockParams(); if (s5 !== peg$FAILED) { s4 = s5; } else { @@ -21311,20 +21212,20 @@ function peg$parse(input, options) { } return s0; } - function peg$parsephase_block_params() { + function peg$parsePhaseBlockParams() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; - s1 = peg$parseparameter(); + s1 = peg$parseParameter(); if (s1 !== peg$FAILED) { - s2 = peg$parselist_sep(); + s2 = peg$parseListSep(); if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c29) { - s3 = peg$c29; + if (input.substr(peg$currPos, 3) === peg$c24) { + s3 = peg$c24; peg$currPos += 3; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e44); + peg$fail(peg$e40); } } if (s3 !== peg$FAILED) { @@ -21339,7 +21240,7 @@ function peg$parse(input, options) { } } if (s5 !== peg$FAILED) { - s6 = peg$parsedeclarations(); + s6 = peg$parseDeclarations(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s7 = peg$c11; @@ -21379,20 +21280,20 @@ function peg$parse(input, options) { } return s0; } - function peg$parsephase_block() { + function peg$parsePhaseBlock() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c31) { - s1 = peg$c31; + if (input.substr(peg$currPos, 2) === peg$c26) { + s1 = peg$c26; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e46); + peg$fail(peg$e42); } } if (s1 !== peg$FAILED) { - s2 = peg$parseend_bareword(); + s2 = peg$parseEndBareword(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); s4 = peg$currPos; @@ -21407,7 +21308,7 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { s6 = peg$parse_(); - s7 = peg$parsephase_block_params(); + s7 = peg$parsePhaseBlockParams(); if (s7 !== peg$FAILED) { s8 = peg$parse_(); if (input.charCodeAt(peg$currPos) === 41) { @@ -21435,7 +21336,7 @@ function peg$parse(input, options) { } if (s4 === peg$FAILED) { s4 = peg$currPos; - s5 = peg$parsephase_block_params(); + s5 = peg$parsePhaseBlockParams(); if (s5 !== peg$FAILED) { s4 = s5; } else { @@ -21459,11 +21360,11 @@ function peg$parse(input, options) { } return s0; } - function peg$parserequirement() { + function peg$parseRequirement() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; s1 = peg$currPos; - s2 = peg$parserelationship(); + s2 = peg$parseRelationship(); if (s2 !== peg$FAILED) { peg$savedPos = s1; s2 = peg$f10(s2); @@ -21471,7 +21372,7 @@ function peg$parse(input, options) { s1 = s2; if (s1 === peg$FAILED) { s1 = peg$currPos; - s2 = peg$parsephase_sub(); + s2 = peg$parsePhaseSub(); if (s2 !== peg$FAILED) { peg$savedPos = s1; s2 = peg$f11(s2); @@ -21479,7 +21380,7 @@ function peg$parse(input, options) { s1 = s2; } if (s1 !== peg$FAILED) { - s2 = peg$parseend_bareword(); + s2 = peg$parseEndBareword(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); s4 = peg$currPos; @@ -21494,7 +21395,7 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { s6 = peg$parse_(); - s7 = peg$parseparameters(); + s7 = peg$parseParameters(); if (s7 !== peg$FAILED) { s8 = peg$parse_(); if (input.charCodeAt(peg$currPos) === 41) { @@ -21522,7 +21423,7 @@ function peg$parse(input, options) { } if (s4 === peg$FAILED) { s4 = peg$currPos; - s5 = peg$parseparameters(); + s5 = peg$parseParameters(); if (s5 !== peg$FAILED) { s4 = s5; } else { @@ -21547,45 +21448,45 @@ function peg$parse(input, options) { } return s0; } - function peg$parserelationship() { + function peg$parseRelationship() { var s0; - if (input.substr(peg$currPos, 8) === peg$c32) { - s0 = peg$c32; + if (input.substr(peg$currPos, 8) === peg$c27) { + s0 = peg$c27; peg$currPos += 8; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e47); + peg$fail(peg$e43); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 10) === peg$c33) { - s0 = peg$c33; + if (input.substr(peg$currPos, 10) === peg$c28) { + s0 = peg$c28; peg$currPos += 10; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e48); + peg$fail(peg$e44); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 8) === peg$c34) { - s0 = peg$c34; + if (input.substr(peg$currPos, 8) === peg$c29) { + s0 = peg$c29; peg$currPos += 8; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e49); + peg$fail(peg$e45); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 9) === peg$c35) { - s0 = peg$c35; + if (input.substr(peg$currPos, 9) === peg$c30) { + s0 = peg$c30; peg$currPos += 9; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e50); + peg$fail(peg$e46); } } } @@ -21593,16 +21494,16 @@ function peg$parse(input, options) { } return s0; } - function peg$parsephase_sub() { + function peg$parsePhaseSub() { var s0, s1; s0 = peg$currPos; - if (input.substr(peg$currPos, 18) === peg$c36) { - s1 = peg$c36; + if (input.substr(peg$currPos, 18) === peg$c31) { + s1 = peg$c31; peg$currPos += 18; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e51); + peg$fail(peg$e47); } } if (s1 !== peg$FAILED) { @@ -21612,13 +21513,13 @@ function peg$parse(input, options) { s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 14) === peg$c37) { - s1 = peg$c37; + if (input.substr(peg$currPos, 14) === peg$c32) { + s1 = peg$c32; peg$currPos += 14; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e52); + peg$fail(peg$e48); } } if (s1 !== peg$FAILED) { @@ -21628,13 +21529,13 @@ function peg$parse(input, options) { s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 13) === peg$c38) { - s1 = peg$c38; + if (input.substr(peg$currPos, 13) === peg$c33) { + s1 = peg$c33; peg$currPos += 13; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e53); + peg$fail(peg$e49); } } if (s1 !== peg$FAILED) { @@ -21644,13 +21545,13 @@ function peg$parse(input, options) { s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 15) === peg$c39) { - s1 = peg$c39; + if (input.substr(peg$currPos, 15) === peg$c34) { + s1 = peg$c34; peg$currPos += 15; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { - peg$fail(peg$e54); + peg$fail(peg$e50); } } if (s1 !== peg$FAILED) { @@ -21869,8 +21770,8 @@ function peg$parse2(input, options) { options = options !== void 0 ? options : {}; var peg$FAILED = {}; var peg$source = options.grammarSource; - var peg$startRuleFunctions = { start: peg$parsestart }; - var peg$startRuleFunction = peg$parsestart; + var peg$startRuleFunctions = { Start: peg$parseStart }; + var peg$startRuleFunction = peg$parseStart; var peg$c0 = "\r"; var peg$c1 = "\n"; var peg$c2 = ";"; @@ -22048,18 +21949,14 @@ function peg$parse2(input, options) { location2 ); } - function peg$parsestart() { - var s0, s1, s2; + function peg$parseStart() { + var s0, s1; s0 = peg$currPos; - s1 = peg$parselines(); - s2 = peg$parseeol(); - if (s2 === peg$FAILED) { - s2 = null; - } + s1 = peg$parseLines(); s0 = s1; return s0; } - function peg$parsews() { + function peg$parseWS() { var s0, s1; s0 = []; s1 = input.charAt(peg$currPos); @@ -22089,7 +21986,7 @@ function peg$parse2(input, options) { } return s0; } - function peg$parseeol() { + function peg$parseEOL() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 13) { @@ -22122,7 +22019,7 @@ function peg$parse2(input, options) { } return s0; } - function peg$parsekey() { + function peg$parseKey() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$currPos; @@ -22177,7 +22074,7 @@ function peg$parse2(input, options) { s0 = s1; return s0; } - function peg$parsevalue() { + function peg$parseValue() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$currPos; @@ -22275,16 +22172,16 @@ function peg$parse2(input, options) { s0 = s1; return s0; } - function peg$parseassignment() { + function peg$parseAssignment() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; - s1 = peg$parsews(); + s1 = peg$parseWS(); if (s1 === peg$FAILED) { s1 = null; } - s2 = peg$parsekey(); + s2 = peg$parseKey(); if (s2 !== peg$FAILED) { - s3 = peg$parsews(); + s3 = peg$parseWS(); if (s3 === peg$FAILED) { s3 = null; } @@ -22298,16 +22195,16 @@ function peg$parse2(input, options) { } } if (s4 !== peg$FAILED) { - s5 = peg$parsews(); + s5 = peg$parseWS(); if (s5 === peg$FAILED) { s5 = null; } - s6 = peg$parsevalue(); - s7 = peg$parsews(); + s6 = peg$parseValue(); + s7 = peg$parseWS(); if (s7 === peg$FAILED) { s7 = null; } - s8 = peg$parsecomment(); + s8 = peg$parseComment(); if (s8 === peg$FAILED) { s8 = null; } @@ -22323,10 +22220,10 @@ function peg$parse2(input, options) { } return s0; } - function peg$parsecomment() { + function peg$parseComment() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - s1 = peg$parsews(); + s1 = peg$parseWS(); if (s1 === peg$FAILED) { s1 = null; } @@ -22372,19 +22269,19 @@ function peg$parse2(input, options) { } return s0; } - function peg$parselines() { + function peg$parseLines() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = []; s2 = peg$currPos; s3 = []; - s4 = peg$parsesection(); + s4 = peg$parseSection(); while (s4 !== peg$FAILED) { s3.push(s4); if (s3.length >= 1) { s4 = peg$FAILED; } else { - s4 = peg$parsesection(); + s4 = peg$parseSection(); } } if (s3.length < 1) { @@ -22396,13 +22293,13 @@ function peg$parse2(input, options) { if (s2 === peg$FAILED) { s2 = peg$currPos; s3 = []; - s4 = peg$parseassignment(); + s4 = peg$parseAssignment(); while (s4 !== peg$FAILED) { s3.push(s4); if (s3.length >= 1) { s4 = peg$FAILED; } else { - s4 = peg$parseassignment(); + s4 = peg$parseAssignment(); } } if (s3.length < 1) { @@ -22414,13 +22311,13 @@ function peg$parse2(input, options) { if (s2 === peg$FAILED) { s2 = peg$currPos; s3 = []; - s4 = peg$parsecomment(); + s4 = peg$parseComment(); while (s4 !== peg$FAILED) { s3.push(s4); if (s3.length >= 1) { s4 = peg$FAILED; } else { - s4 = peg$parsecomment(); + s4 = peg$parseComment(); } } if (s3.length < 1) { @@ -22431,7 +22328,7 @@ function peg$parse2(input, options) { } if (s2 === peg$FAILED) { s2 = peg$currPos; - s3 = peg$parsews(); + s3 = peg$parseWS(); if (s3 === peg$FAILED) { s3 = null; } @@ -22445,11 +22342,11 @@ function peg$parse2(input, options) { s1.push(s2); s2 = peg$currPos; s3 = []; - s4 = peg$parseeol(); + s4 = peg$parseEOL(); if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); - s4 = peg$parseeol(); + s4 = peg$parseEOL(); } } else { s3 = peg$FAILED; @@ -22457,13 +22354,13 @@ function peg$parse2(input, options) { if (s3 !== peg$FAILED) { s3 = peg$currPos; s4 = []; - s5 = peg$parsesection(); + s5 = peg$parseSection(); while (s5 !== peg$FAILED) { s4.push(s5); if (s4.length >= 1) { s5 = peg$FAILED; } else { - s5 = peg$parsesection(); + s5 = peg$parseSection(); } } if (s4.length < 1) { @@ -22475,13 +22372,13 @@ function peg$parse2(input, options) { if (s3 === peg$FAILED) { s3 = peg$currPos; s4 = []; - s5 = peg$parseassignment(); + s5 = peg$parseAssignment(); while (s5 !== peg$FAILED) { s4.push(s5); if (s4.length >= 1) { s5 = peg$FAILED; } else { - s5 = peg$parseassignment(); + s5 = peg$parseAssignment(); } } if (s4.length < 1) { @@ -22493,13 +22390,13 @@ function peg$parse2(input, options) { if (s3 === peg$FAILED) { s3 = peg$currPos; s4 = []; - s5 = peg$parsecomment(); + s5 = peg$parseComment(); while (s5 !== peg$FAILED) { s4.push(s5); if (s4.length >= 1) { s5 = peg$FAILED; } else { - s5 = peg$parsecomment(); + s5 = peg$parseComment(); } } if (s4.length < 1) { @@ -22510,7 +22407,7 @@ function peg$parse2(input, options) { } if (s3 === peg$FAILED) { s3 = peg$currPos; - s4 = peg$parsews(); + s4 = peg$parseWS(); if (s4 === peg$FAILED) { s4 = null; } @@ -22530,15 +22427,18 @@ function peg$parse2(input, options) { s2 = s3; } } + s2 = peg$parseEOL(); + if (s2 === peg$FAILED) { + s2 = null; + } peg$savedPos = s0; - s1 = peg$f5(s1); - s0 = s1; + s0 = peg$f5(s1); return s0; } - function peg$parsesection() { + function peg$parseSection() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; - s1 = peg$parsews(); + s1 = peg$parseWS(); if (s1 === peg$FAILED) { s1 = null; } @@ -22552,7 +22452,7 @@ function peg$parse2(input, options) { } } if (s2 !== peg$FAILED) { - s3 = peg$parsews(); + s3 = peg$parseWS(); if (s3 === peg$FAILED) { s3 = null; } @@ -22589,7 +22489,7 @@ function peg$parse2(input, options) { s4 = s5; } if (s4 !== peg$FAILED) { - s5 = peg$parsews(); + s5 = peg$parseWS(); if (s5 === peg$FAILED) { s5 = null; } @@ -22603,7 +22503,7 @@ function peg$parse2(input, options) { } } if (s6 !== peg$FAILED) { - s7 = peg$parsews(); + s7 = peg$parseWS(); if (s7 === peg$FAILED) { s7 = null; } diff --git a/eslint.config.mjs b/eslint.config.mjs index 1eae8a6..81a0536 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,7 +1,8 @@ import globals from 'globals'; import js from '@eslint/js'; import mochaPlugin from 'eslint-plugin-mocha'; -import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; +import prettierPlugin from 'eslint-plugin-prettier/recommended'; +import peggyPlugin from '@peggyjs/eslint-plugin/lib/flat/recommended.js'; export default [ { @@ -18,7 +19,11 @@ export default [ globals: globals.node, }, }, + peggyPlugin, js.configs.recommended, mochaPlugin.configs.flat.recommended, - eslintPluginPrettierRecommended, + { + ...prettierPlugin, + ignores: ['**/*.pegjs'], + }, ]; diff --git a/package-lock.json b/package-lock.json index 2b180d5..bb9e18f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,8 @@ "js-yaml": "^4.1.0" }, "devDependencies": { + "@peggyjs/eslint-parser": "^2.0.6", + "@peggyjs/eslint-plugin": "^2.1.2", "esbuild": "^0.23.1", "eslint": "^9.9.1", "eslint-config-prettier": "^9.1.0", @@ -260,6 +262,33 @@ "node": ">= 8" } }, + "node_modules/@peggyjs/eslint-parser": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/@peggyjs/eslint-parser/-/eslint-parser-2.0.6.tgz", + "integrity": "sha512-3nTz29Wo6kfe7OnVmCmlgOfEfRUT6PIJictENtLppSH3fJKOJnsR6L1tAw20JVo94Me4wWxnLaP0k8MyJpPP/Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@peggyjs/eslint-plugin": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@peggyjs/eslint-plugin/-/eslint-plugin-2.1.2.tgz", + "integrity": "sha512-1go0FFCIjyQl2M4PBtYLVE/W5sCHkwW/wnJLjK4WNM46O14zIy9SimJEYaEAM7DSGmW11i/Erk4VTH1nAX+KCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "enhanced-resolve": "5.15.1" + }, + "engines": { + "node": ">=20.8" + }, + "peerDependencies": { + "@peggyjs/eslint-parser": "^2.0.6", + "eslint": ">=8.57.0" + } + }, "node_modules/@peggyjs/from-mem": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@peggyjs/from-mem/-/from-mem-1.3.0.tgz", @@ -630,6 +659,20 @@ "dev": true, "license": "MIT" }, + "node_modules/enhanced-resolve": { + "version": "5.15.1", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.1.tgz", + "integrity": "sha512-3d3JRbwsCLJsYgvb6NuWEG44jjPSOMuS73L/6+7BZuoKm3W+qXnSoIYVHi8dG7Qcg4inAY4jbzkZ7MnskePeDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/esbuild": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.23.1.tgz", @@ -1168,6 +1211,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -1992,6 +2042,16 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", diff --git a/package.json b/package.json index 2b1fcb9..7b5bb8e 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,8 @@ "js-yaml": "^4.1.0" }, "devDependencies": { + "@peggyjs/eslint-parser": "^2.0.6", + "@peggyjs/eslint-plugin": "^2.1.2", "esbuild": "^0.23.1", "eslint": "^9.9.1", "eslint-config-prettier": "^9.1.0", diff --git a/src/cpanfile-peg.mjs b/src/cpanfile-peg.mjs index e45eb9a..bab9bc4 100644 --- a/src/cpanfile-peg.mjs +++ b/src/cpanfile-peg.mjs @@ -4,7 +4,7 @@ - import { fullVersion } from './cpan-versions.mjs'; + import { fullVersion } from "./cpan-versions.mjs"; function peg$subclass(child, parent) { function C() { this.constructor = child; } @@ -175,8 +175,8 @@ function peg$parse(input, options) { var peg$FAILED = {}; var peg$source = options.grammarSource; - var peg$startRuleFunctions = { start: peg$parsestart }; - var peg$startRuleFunction = peg$parsestart; + var peg$startRuleFunctions = { Start: peg$parseStart }; + var peg$startRuleFunction = peg$parseStart; var peg$c0 = "#"; var peg$c1 = "\n"; @@ -194,30 +194,25 @@ function peg$parse(input, options) { var peg$c13 = ")"; var peg$c14 = "<"; var peg$c15 = ">"; - var peg$c16 = "\""; - var peg$c17 = "'"; + var peg$c16 = "'"; + var peg$c17 = "\""; var peg$c18 = "qq"; var peg$c19 = "q"; - var peg$c20 = "configure"; - var peg$c21 = "build"; - var peg$c22 = "test"; - var peg$c23 = "runtime"; - var peg$c24 = "develop"; - var peg$c25 = "use strict"; - var peg$c26 = "use warnings"; - var peg$c27 = "use "; - var peg$c28 = "1"; - var peg$c29 = "sub"; - var peg$c30 = "feature"; - var peg$c31 = "on"; - var peg$c32 = "requires"; - var peg$c33 = "recommends"; - var peg$c34 = "suggests"; - var peg$c35 = "conflicts"; - var peg$c36 = "configure_requires"; - var peg$c37 = "build_requires"; - var peg$c38 = "test_requires"; - var peg$c39 = "author_requires"; + var peg$c20 = "use strict"; + var peg$c21 = "use warnings"; + var peg$c22 = "use "; + var peg$c23 = "1"; + var peg$c24 = "sub"; + var peg$c25 = "feature"; + var peg$c26 = "on"; + var peg$c27 = "requires"; + var peg$c28 = "recommends"; + var peg$c29 = "suggests"; + var peg$c30 = "conflicts"; + var peg$c31 = "configure_requires"; + var peg$c32 = "build_requires"; + var peg$c33 = "test_requires"; + var peg$c34 = "author_requires"; var peg$r0 = /^[ \t\n\r]/; var peg$r1 = /^[^\n]/; @@ -229,10 +224,11 @@ function peg$parse(input, options) { var peg$r7 = /^[^\\}]/; var peg$r8 = /^[^\\)]/; var peg$r9 = /^[^\\>]/; - var peg$r10 = /^[^\\"]/; - var peg$r11 = /^[^\\']/; - var peg$r12 = /^[^\\"$@]/; - var peg$r13 = /^[0-9a-z_']/i; + var peg$r10 = /^[^\\']/; + var peg$r11 = /^[^\\"]/; + var peg$r12 = /^[^\\'$@]/; + var peg$r13 = /^[^\\"$@]/; + var peg$r14 = /^[0-9a-z_']/i; var peg$e0 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false); var peg$e1 = peg$literalExpectation("#", false); @@ -261,58 +257,54 @@ function peg$parse(input, options) { var peg$e24 = peg$literalExpectation("<", false); var peg$e25 = peg$classExpectation(["\\", ">"], true, false); var peg$e26 = peg$literalExpectation(">", false); - var peg$e27 = peg$literalExpectation("\"", false); - var peg$e28 = peg$classExpectation(["\\", "\""], true, false); - var peg$e29 = peg$literalExpectation("'", false); - var peg$e30 = peg$classExpectation(["\\", "'"], true, false); - var peg$e31 = peg$classExpectation(["\\", "\"", "$", "@"], true, false); - var peg$e32 = peg$literalExpectation("qq", false); - var peg$e33 = peg$literalExpectation("q", false); - var peg$e34 = peg$literalExpectation("configure", false); - var peg$e35 = peg$literalExpectation("build", false); - var peg$e36 = peg$literalExpectation("test", false); - var peg$e37 = peg$literalExpectation("runtime", false); - var peg$e38 = peg$literalExpectation("develop", false); - var peg$e39 = peg$literalExpectation("use strict", false); - var peg$e40 = peg$literalExpectation("use warnings", false); - var peg$e41 = peg$literalExpectation("use ", false); - var peg$e42 = peg$literalExpectation("1", false); - var peg$e43 = peg$classExpectation([["0", "9"], ["a", "z"], "_", "'"], false, true); - var peg$e44 = peg$literalExpectation("sub", false); - var peg$e45 = peg$literalExpectation("feature", false); - var peg$e46 = peg$literalExpectation("on", false); - var peg$e47 = peg$literalExpectation("requires", false); - var peg$e48 = peg$literalExpectation("recommends", false); - var peg$e49 = peg$literalExpectation("suggests", false); - var peg$e50 = peg$literalExpectation("conflicts", false); - var peg$e51 = peg$literalExpectation("configure_requires", false); - var peg$e52 = peg$literalExpectation("build_requires", false); - var peg$e53 = peg$literalExpectation("test_requires", false); - var peg$e54 = peg$literalExpectation("author_requires", false); + var peg$e27 = peg$literalExpectation("'", false); + var peg$e28 = peg$classExpectation(["\\", "'"], true, false); + var peg$e29 = peg$literalExpectation("\"", false); + var peg$e30 = peg$classExpectation(["\\", "\""], true, false); + var peg$e31 = peg$classExpectation(["\\", "'", "$", "@"], true, false); + var peg$e32 = peg$classExpectation(["\\", "\"", "$", "@"], true, false); + var peg$e33 = peg$literalExpectation("qq", false); + var peg$e34 = peg$literalExpectation("q", false); + var peg$e35 = peg$literalExpectation("use strict", false); + var peg$e36 = peg$literalExpectation("use warnings", false); + var peg$e37 = peg$literalExpectation("use ", false); + var peg$e38 = peg$literalExpectation("1", false); + var peg$e39 = peg$classExpectation([["0", "9"], ["a", "z"], "_", "'"], false, true); + var peg$e40 = peg$literalExpectation("sub", false); + var peg$e41 = peg$literalExpectation("feature", false); + var peg$e42 = peg$literalExpectation("on", false); + var peg$e43 = peg$literalExpectation("requires", false); + var peg$e44 = peg$literalExpectation("recommends", false); + var peg$e45 = peg$literalExpectation("suggests", false); + var peg$e46 = peg$literalExpectation("conflicts", false); + var peg$e47 = peg$literalExpectation("configure_requires", false); + var peg$e48 = peg$literalExpectation("build_requires", false); + var peg$e49 = peg$literalExpectation("test_requires", false); + var peg$e50 = peg$literalExpectation("author_requires", false); var peg$f0 = function(reqs) { return reqs.map(req => ({ - phase: 'runtime', + phase: "runtime", ...req, version: fullVersion(req.version.toString()), })); }; var peg$f1 = function(digits) { return parseInt(digits, 10) }; - var peg$f2 = function(number) { return parseFloat(number.replace(/_/, '')) }; + var peg$f2 = function(number) { return parseFloat(number.replace(/_/, "")) }; var peg$f3 = function() { return null }; - var peg$f4 = function(version) { return 'v' + version.join('.') }; + var peg$f4 = function(version) { return "v" + version.join(".") }; var peg$f5 = function() { return [] }; var peg$f6 = function() { return [] }; var peg$f7 = function(reqs) { return reqs.flat() }; var peg$f8 = function(feature, description, reqs) { return reqs.map(req => ({ ...req, feature, description})) }; var peg$f9 = function(phase, reqs) { return reqs.map(req => ({ ...req, phase })) }; var peg$f10 = function(relationship) { return { relationship } }; - var peg$f11 = function(phase) { return { phase, relationship: 'requires' } }; + var peg$f11 = function(phase) { return { phase, relationship: "requires" } }; var peg$f12 = function(type, params) { return { prereq: params[0], version: params[1] || 0, ...type } }; - var peg$f13 = function() { return 'configure' }; - var peg$f14 = function() { return 'build' }; - var peg$f15 = function() { return 'test' }; - var peg$f16 = function() { return 'develop' }; + var peg$f13 = function() { return "configure" }; + var peg$f14 = function() { return "build" }; + var peg$f15 = function() { return "test" }; + var peg$f16 = function() { return "develop" }; var peg$currPos = options.peg$currPos | 0; var peg$savedPos = peg$currPos; var peg$posDetailsCache = [{ line: 1, column: 1 }]; @@ -475,11 +467,11 @@ function peg$parse(input, options) { ); } - function peg$parsestart() { + function peg$parseStart() { var s0, s1; s0 = peg$currPos; - s1 = peg$parsedeclarations(); + s1 = peg$parseDeclarations(); peg$savedPos = s0; s1 = peg$f0(s1); s0 = s1; @@ -487,7 +479,7 @@ function peg$parse(input, options) { return s0; } - function peg$parsews() { + function peg$parseWS() { var s0, s1; s0 = []; @@ -516,7 +508,7 @@ function peg$parse(input, options) { return s0; } - function peg$parsecomment() { + function peg$parseComment() { var s0, s1, s2, s3, s4; s0 = peg$currPos; @@ -613,7 +605,7 @@ function peg$parse(input, options) { s1 = peg$FAILED; } if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); + s1 = peg$parseComment(); } while (s1 !== peg$FAILED) { s0.push(s1); @@ -640,23 +632,23 @@ function peg$parse(input, options) { s1 = peg$FAILED; } if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); + s1 = peg$parseComment(); } } return s0; } - function peg$parsevalue() { + function peg$parseValue() { var s0; - s0 = peg$parseundef(); + s0 = peg$parseUndef(); if (s0 === peg$FAILED) { - s0 = peg$parsestring(); + s0 = peg$parseString(); if (s0 === peg$FAILED) { - s0 = peg$parsevstring(); + s0 = peg$parseVString(); if (s0 === peg$FAILED) { - s0 = peg$parsenumber(); + s0 = peg$parseNumber(); } } } @@ -664,7 +656,7 @@ function peg$parse(input, options) { return s0; } - function peg$parsestatement_sep() { + function peg$parseStatementSep() { var s0, s1, s2, s3, s4; s0 = []; @@ -713,7 +705,7 @@ function peg$parse(input, options) { return s0; } - function peg$parselist_sep() { + function peg$parseListSep() { var s0, s1, s2, s3, s4; s0 = []; @@ -780,7 +772,7 @@ function peg$parse(input, options) { return s0; } - function peg$parsebareword() { + function peg$parseBareword() { var s0, s1, s2, s3; s0 = peg$currPos; @@ -820,12 +812,12 @@ function peg$parse(input, options) { return s0; } - function peg$parsequoted_bareword() { + function peg$parseQuotedBareword() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$currPos; - s2 = peg$parsebareword(); + s2 = peg$parseBareword(); if (s2 !== peg$FAILED) { s1 = input.substring(s1, peg$currPos); } else { @@ -835,7 +827,7 @@ function peg$parse(input, options) { s2 = peg$currPos; peg$silentFails++; s3 = peg$currPos; - s4 = peg$parsews(); + s4 = peg$parseWS(); if (s4 === peg$FAILED) { s4 = null; } @@ -874,7 +866,7 @@ function peg$parse(input, options) { return s0; } - function peg$parseinteger() { + function peg$parseInteger() { var s0, s1, s2, s3; s0 = peg$currPos; @@ -915,7 +907,7 @@ function peg$parse(input, options) { return s0; } - function peg$parsedecimal() { + function peg$parseDecimal() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; @@ -997,18 +989,18 @@ function peg$parse(input, options) { return s0; } - function peg$parsenumber() { + function peg$parseNumber() { var s0; - s0 = peg$parsedecimal(); + s0 = peg$parseDecimal(); if (s0 === peg$FAILED) { - s0 = peg$parseinteger(); + s0 = peg$parseInteger(); } return s0; } - function peg$parseundef() { + function peg$parseUndef() { var s0, s1; s0 = peg$currPos; @@ -1028,13 +1020,13 @@ function peg$parse(input, options) { return s0; } - function peg$parsevstring() { + function peg$parseVString() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = peg$currPos; s2 = []; - s3 = peg$parseinteger(); + s3 = peg$parseInteger(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$currPos; @@ -1046,7 +1038,7 @@ function peg$parse(input, options) { if (peg$silentFails === 0) { peg$fail(peg$e12); } } if (s4 !== peg$FAILED) { - s4 = peg$parseinteger(); + s4 = peg$parseInteger(); if (s4 === peg$FAILED) { peg$currPos = s3; s3 = peg$FAILED; @@ -1075,7 +1067,7 @@ function peg$parse(input, options) { if (s2 !== peg$FAILED) { s3 = peg$currPos; s4 = []; - s5 = peg$parseinteger(); + s5 = peg$parseInteger(); while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$currPos; @@ -1087,7 +1079,7 @@ function peg$parse(input, options) { if (peg$silentFails === 0) { peg$fail(peg$e12); } } if (s6 !== peg$FAILED) { - s6 = peg$parseinteger(); + s6 = peg$parseInteger(); if (s6 === peg$FAILED) { peg$currPos = s5; s5 = peg$FAILED; @@ -1124,7 +1116,7 @@ function peg$parse(input, options) { return s0; } - function peg$parsepairs() { + function peg$parsePairs() { var s0, s1, s2, s3, s4; s0 = peg$currPos; @@ -1316,7 +1308,7 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { + if (input.charCodeAt(peg$currPos) === 39) { s1 = peg$c16; peg$currPos++; } else { @@ -1344,7 +1336,7 @@ function peg$parse(input, options) { } } s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 34) { + if (input.charCodeAt(peg$currPos) === 39) { s3 = peg$c16; peg$currPos++; } else { @@ -1363,7 +1355,7 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { + if (input.charCodeAt(peg$currPos) === 34) { s1 = peg$c17; peg$currPos++; } else { @@ -1391,7 +1383,7 @@ function peg$parse(input, options) { } } s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 39) { + if (input.charCodeAt(peg$currPos) === 34) { s3 = peg$c17; peg$currPos++; } else { @@ -1417,11 +1409,11 @@ function peg$parse(input, options) { return s0; } - function peg$parsestring() { + function peg$parseString() { var s0, s1, s2, s3, s4; s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { + if (input.charCodeAt(peg$currPos) === 39) { s1 = peg$c16; peg$currPos++; } else { @@ -1449,7 +1441,7 @@ function peg$parse(input, options) { } } s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 34) { + if (input.charCodeAt(peg$currPos) === 39) { s3 = peg$c16; peg$currPos++; } else { @@ -1468,7 +1460,7 @@ function peg$parse(input, options) { } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { + if (input.charCodeAt(peg$currPos) === 34) { s1 = peg$c17; peg$currPos++; } else { @@ -1479,24 +1471,24 @@ function peg$parse(input, options) { s2 = peg$currPos; s3 = []; s4 = input.charAt(peg$currPos); - if (peg$r11.test(s4)) { + if (peg$r13.test(s4)) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e30); } + if (peg$silentFails === 0) { peg$fail(peg$e32); } } while (s4 !== peg$FAILED) { s3.push(s4); s4 = input.charAt(peg$currPos); - if (peg$r11.test(s4)) { + if (peg$r13.test(s4)) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e30); } + if (peg$silentFails === 0) { peg$fail(peg$e32); } } } s2 = input.substring(s2, peg$currPos); - if (input.charCodeAt(peg$currPos) === 39) { + if (input.charCodeAt(peg$currPos) === 34) { s3 = peg$c17; peg$currPos++; } else { @@ -1520,10 +1512,10 @@ function peg$parse(input, options) { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e32); } + if (peg$silentFails === 0) { peg$fail(peg$e33); } } if (s1 !== peg$FAILED) { - s2 = peg$parsepairs(); + s2 = peg$parsePairs(); if (s2 !== peg$FAILED) { s0 = s2; } else { @@ -1541,10 +1533,10 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e33); } + if (peg$silentFails === 0) { peg$fail(peg$e34); } } if (s1 !== peg$FAILED) { - s2 = peg$parsepairs(); + s2 = peg$parsePairs(); if (s2 !== peg$FAILED) { s0 = s2; } else { @@ -1562,84 +1554,34 @@ function peg$parse(input, options) { return s0; } - function peg$parsephase() { - var s0; - - if (input.substr(peg$currPos, 9) === peg$c20) { - s0 = peg$c20; - peg$currPos += 9; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e34); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 5) === peg$c21) { - s0 = peg$c21; - peg$currPos += 5; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e35); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 4) === peg$c22) { - s0 = peg$c22; - peg$currPos += 4; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e36); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 7) === peg$c23) { - s0 = peg$c23; - peg$currPos += 7; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e37); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 7) === peg$c24) { - s0 = peg$c24; - peg$currPos += 7; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } - } - } - } - } - } - - return s0; - } - - function peg$parseparameter() { + function peg$parseParameter() { var s0; - s0 = peg$parsevalue(); + s0 = peg$parseValue(); if (s0 === peg$FAILED) { - s0 = peg$parsequoted_bareword(); + s0 = peg$parseQuotedBareword(); } return s0; } - function peg$parseparameters() { + function peg$parseParameters() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - s1 = peg$parselist_sep(); + s1 = peg$parseListSep(); if (s1 === peg$FAILED) { s1 = null; } s2 = peg$currPos; s3 = []; - s4 = peg$parseparameter(); + s4 = peg$parseParameter(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$currPos; - s5 = peg$parselist_sep(); + s5 = peg$parseListSep(); if (s5 !== peg$FAILED) { - s5 = peg$parseparameter(); + s5 = peg$parseParameter(); if (s5 === peg$FAILED) { peg$currPos = s4; s4 = peg$FAILED; @@ -1657,7 +1599,7 @@ function peg$parse(input, options) { s2 = s3; } if (s2 !== peg$FAILED) { - s3 = peg$parselist_sep(); + s3 = peg$parseListSep(); if (s3 === peg$FAILED) { s3 = null; } @@ -1670,32 +1612,32 @@ function peg$parse(input, options) { return s0; } - function peg$parsepragma() { + function peg$parsePragma() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; - if (input.substr(peg$currPos, 10) === peg$c25) { - s0 = peg$c25; + if (input.substr(peg$currPos, 10) === peg$c20) { + s0 = peg$c20; peg$currPos += 10; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e39); } + if (peg$silentFails === 0) { peg$fail(peg$e35); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 12) === peg$c26) { - s0 = peg$c26; + if (input.substr(peg$currPos, 12) === peg$c21) { + s0 = peg$c21; peg$currPos += 12; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e40); } + if (peg$silentFails === 0) { peg$fail(peg$e36); } } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 4) === peg$c27) { - s1 = peg$c27; + if (input.substr(peg$currPos, 4) === peg$c22) { + s1 = peg$c22; peg$currPos += 4; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e41); } + if (peg$silentFails === 0) { peg$fail(peg$e37); } } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 118) { @@ -1820,25 +1762,25 @@ function peg$parse(input, options) { return s0; } - function peg$parsedeclarations() { + function peg$parseDeclarations() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; s1 = peg$parse_(); - s2 = peg$parsestatement_sep(); + s2 = peg$parseStatementSep(); if (s2 === peg$FAILED) { s2 = null; } s3 = []; s4 = peg$currPos; s5 = []; - s6 = peg$parserequirement(); + s6 = peg$parseRequirement(); while (s6 !== peg$FAILED) { s5.push(s6); if (s5.length >= 1) { s6 = peg$FAILED; } else { - s6 = peg$parserequirement(); + s6 = peg$parseRequirement(); } } if (s5.length < 1) { @@ -1848,12 +1790,12 @@ function peg$parse(input, options) { s4 = s5; } if (s4 === peg$FAILED) { - s4 = peg$parsephase_block(); + s4 = peg$parsePhaseBlock(); if (s4 === peg$FAILED) { - s4 = peg$parsefeature_block(); + s4 = peg$parseFeatureBlock(); if (s4 === peg$FAILED) { s4 = peg$currPos; - s5 = peg$parsepragma(); + s5 = peg$parsePragma(); if (s5 !== peg$FAILED) { peg$savedPos = s4; s5 = peg$f5(); @@ -1862,11 +1804,11 @@ function peg$parse(input, options) { if (s4 === peg$FAILED) { s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 49) { - s5 = peg$c28; + s5 = peg$c23; peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e42); } + if (peg$silentFails === 0) { peg$fail(peg$e38); } } if (s5 !== peg$FAILED) { peg$savedPos = s4; @@ -1880,17 +1822,17 @@ function peg$parse(input, options) { while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$currPos; - s5 = peg$parsestatement_sep(); + s5 = peg$parseStatementSep(); if (s5 !== peg$FAILED) { s5 = peg$currPos; s6 = []; - s7 = peg$parserequirement(); + s7 = peg$parseRequirement(); while (s7 !== peg$FAILED) { s6.push(s7); if (s6.length >= 1) { s7 = peg$FAILED; } else { - s7 = peg$parserequirement(); + s7 = peg$parseRequirement(); } } if (s6.length < 1) { @@ -1900,12 +1842,12 @@ function peg$parse(input, options) { s5 = s6; } if (s5 === peg$FAILED) { - s5 = peg$parsephase_block(); + s5 = peg$parsePhaseBlock(); if (s5 === peg$FAILED) { - s5 = peg$parsefeature_block(); + s5 = peg$parseFeatureBlock(); if (s5 === peg$FAILED) { s5 = peg$currPos; - s6 = peg$parsepragma(); + s6 = peg$parsePragma(); if (s6 !== peg$FAILED) { peg$savedPos = s5; s6 = peg$f5(); @@ -1914,11 +1856,11 @@ function peg$parse(input, options) { if (s5 === peg$FAILED) { s5 = peg$currPos; if (input.charCodeAt(peg$currPos) === 49) { - s6 = peg$c28; + s6 = peg$c23; peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e42); } + if (peg$silentFails === 0) { peg$fail(peg$e38); } } if (s6 !== peg$FAILED) { peg$savedPos = s5; @@ -1939,7 +1881,7 @@ function peg$parse(input, options) { s4 = s5; } } - s4 = peg$parsestatement_sep(); + s4 = peg$parseStatementSep(); if (s4 === peg$FAILED) { s4 = null; } @@ -1950,21 +1892,21 @@ function peg$parse(input, options) { return s0; } - function peg$parseend_bareword() { + function peg$parseEndBareword() { var s0, s1, s2, s3; s0 = peg$currPos; peg$silentFails++; s1 = input.charAt(peg$currPos); - if (peg$r13.test(s1)) { + if (peg$r14.test(s1)) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e43); } + if (peg$silentFails === 0) { peg$fail(peg$e39); } } if (s1 === peg$FAILED) { s1 = peg$currPos; - s2 = peg$parsews(); + s2 = peg$parseWS(); if (s2 === peg$FAILED) { s2 = null; } @@ -1994,55 +1936,18 @@ function peg$parse(input, options) { return s0; } - function peg$parserequirements() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parse_(); - s2 = peg$parsestatement_sep(); - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = []; - s4 = peg$parserequirement(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$currPos; - s5 = peg$parsestatement_sep(); - if (s5 !== peg$FAILED) { - s5 = peg$parserequirement(); - if (s5 === peg$FAILED) { - peg$currPos = s4; - s4 = peg$FAILED; - } else { - s4 = s5; - } - } else { - s4 = s5; - } - } - s4 = peg$parsestatement_sep(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parse_(); - s0 = s3; - - return s0; - } - - function peg$parsefeature_block_params() { + function peg$parseFeatureBlockParams() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; - s1 = peg$parseparameter(); + s1 = peg$parseParameter(); if (s1 !== peg$FAILED) { - s2 = peg$parselist_sep(); + s2 = peg$parseListSep(); if (s2 !== peg$FAILED) { s3 = peg$currPos; - s4 = peg$parseparameter(); + s4 = peg$parseParameter(); if (s4 !== peg$FAILED) { - s5 = peg$parselist_sep(); + s5 = peg$parseListSep(); if (s5 !== peg$FAILED) { s3 = s4; } else { @@ -2056,12 +1961,12 @@ function peg$parse(input, options) { if (s3 === peg$FAILED) { s3 = null; } - if (input.substr(peg$currPos, 3) === peg$c29) { - s4 = peg$c29; + if (input.substr(peg$currPos, 3) === peg$c24) { + s4 = peg$c24; peg$currPos += 3; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e44); } + if (peg$silentFails === 0) { peg$fail(peg$e40); } } if (s4 !== peg$FAILED) { s5 = peg$parse_(); @@ -2073,7 +1978,7 @@ function peg$parse(input, options) { if (peg$silentFails === 0) { peg$fail(peg$e18); } } if (s6 !== peg$FAILED) { - s7 = peg$parsedeclarations(); + s7 = peg$parseDeclarations(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s8 = peg$c11; @@ -2113,19 +2018,19 @@ function peg$parse(input, options) { return s0; } - function peg$parsefeature_block() { + function peg$parseFeatureBlock() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; - if (input.substr(peg$currPos, 7) === peg$c30) { - s1 = peg$c30; + if (input.substr(peg$currPos, 7) === peg$c25) { + s1 = peg$c25; peg$currPos += 7; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e45); } + if (peg$silentFails === 0) { peg$fail(peg$e41); } } if (s1 !== peg$FAILED) { - s2 = peg$parseend_bareword(); + s2 = peg$parseEndBareword(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); s4 = peg$currPos; @@ -2138,7 +2043,7 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { s6 = peg$parse_(); - s7 = peg$parsefeature_block_params(); + s7 = peg$parseFeatureBlockParams(); if (s7 !== peg$FAILED) { s8 = peg$parse_(); if (input.charCodeAt(peg$currPos) === 41) { @@ -2164,7 +2069,7 @@ function peg$parse(input, options) { } if (s4 === peg$FAILED) { s4 = peg$currPos; - s5 = peg$parsefeature_block_params(); + s5 = peg$parseFeatureBlockParams(); if (s5 !== peg$FAILED) { s4 = s5; } else { @@ -2190,20 +2095,20 @@ function peg$parse(input, options) { return s0; } - function peg$parsephase_block_params() { + function peg$parsePhaseBlockParams() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; - s1 = peg$parseparameter(); + s1 = peg$parseParameter(); if (s1 !== peg$FAILED) { - s2 = peg$parselist_sep(); + s2 = peg$parseListSep(); if (s2 !== peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c29) { - s3 = peg$c29; + if (input.substr(peg$currPos, 3) === peg$c24) { + s3 = peg$c24; peg$currPos += 3; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e44); } + if (peg$silentFails === 0) { peg$fail(peg$e40); } } if (s3 !== peg$FAILED) { s4 = peg$parse_(); @@ -2215,7 +2120,7 @@ function peg$parse(input, options) { if (peg$silentFails === 0) { peg$fail(peg$e18); } } if (s5 !== peg$FAILED) { - s6 = peg$parsedeclarations(); + s6 = peg$parseDeclarations(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s7 = peg$c11; @@ -2255,19 +2160,19 @@ function peg$parse(input, options) { return s0; } - function peg$parsephase_block() { + function peg$parsePhaseBlock() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c31) { - s1 = peg$c31; + if (input.substr(peg$currPos, 2) === peg$c26) { + s1 = peg$c26; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e46); } + if (peg$silentFails === 0) { peg$fail(peg$e42); } } if (s1 !== peg$FAILED) { - s2 = peg$parseend_bareword(); + s2 = peg$parseEndBareword(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); s4 = peg$currPos; @@ -2280,7 +2185,7 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { s6 = peg$parse_(); - s7 = peg$parsephase_block_params(); + s7 = peg$parsePhaseBlockParams(); if (s7 !== peg$FAILED) { s8 = peg$parse_(); if (input.charCodeAt(peg$currPos) === 41) { @@ -2306,7 +2211,7 @@ function peg$parse(input, options) { } if (s4 === peg$FAILED) { s4 = peg$currPos; - s5 = peg$parsephase_block_params(); + s5 = peg$parsePhaseBlockParams(); if (s5 !== peg$FAILED) { s4 = s5; } else { @@ -2332,12 +2237,12 @@ function peg$parse(input, options) { return s0; } - function peg$parserequirement() { + function peg$parseRequirement() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; s1 = peg$currPos; - s2 = peg$parserelationship(); + s2 = peg$parseRelationship(); if (s2 !== peg$FAILED) { peg$savedPos = s1; s2 = peg$f10(s2); @@ -2345,7 +2250,7 @@ function peg$parse(input, options) { s1 = s2; if (s1 === peg$FAILED) { s1 = peg$currPos; - s2 = peg$parsephase_sub(); + s2 = peg$parsePhaseSub(); if (s2 !== peg$FAILED) { peg$savedPos = s1; s2 = peg$f11(s2); @@ -2353,7 +2258,7 @@ function peg$parse(input, options) { s1 = s2; } if (s1 !== peg$FAILED) { - s2 = peg$parseend_bareword(); + s2 = peg$parseEndBareword(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); s4 = peg$currPos; @@ -2366,7 +2271,7 @@ function peg$parse(input, options) { } if (s5 !== peg$FAILED) { s6 = peg$parse_(); - s7 = peg$parseparameters(); + s7 = peg$parseParameters(); if (s7 !== peg$FAILED) { s8 = peg$parse_(); if (input.charCodeAt(peg$currPos) === 41) { @@ -2392,7 +2297,7 @@ function peg$parse(input, options) { } if (s4 === peg$FAILED) { s4 = peg$currPos; - s5 = peg$parseparameters(); + s5 = peg$parseParameters(); if (s5 !== peg$FAILED) { s4 = s5; } else { @@ -2419,39 +2324,39 @@ function peg$parse(input, options) { return s0; } - function peg$parserelationship() { + function peg$parseRelationship() { var s0; - if (input.substr(peg$currPos, 8) === peg$c32) { - s0 = peg$c32; + if (input.substr(peg$currPos, 8) === peg$c27) { + s0 = peg$c27; peg$currPos += 8; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e47); } + if (peg$silentFails === 0) { peg$fail(peg$e43); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 10) === peg$c33) { - s0 = peg$c33; + if (input.substr(peg$currPos, 10) === peg$c28) { + s0 = peg$c28; peg$currPos += 10; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e48); } + if (peg$silentFails === 0) { peg$fail(peg$e44); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 8) === peg$c34) { - s0 = peg$c34; + if (input.substr(peg$currPos, 8) === peg$c29) { + s0 = peg$c29; peg$currPos += 8; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e49); } + if (peg$silentFails === 0) { peg$fail(peg$e45); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 9) === peg$c35) { - s0 = peg$c35; + if (input.substr(peg$currPos, 9) === peg$c30) { + s0 = peg$c30; peg$currPos += 9; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e50); } + if (peg$silentFails === 0) { peg$fail(peg$e46); } } } } @@ -2460,16 +2365,16 @@ function peg$parse(input, options) { return s0; } - function peg$parsephase_sub() { + function peg$parsePhaseSub() { var s0, s1; s0 = peg$currPos; - if (input.substr(peg$currPos, 18) === peg$c36) { - s1 = peg$c36; + if (input.substr(peg$currPos, 18) === peg$c31) { + s1 = peg$c31; peg$currPos += 18; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e51); } + if (peg$silentFails === 0) { peg$fail(peg$e47); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -2478,12 +2383,12 @@ function peg$parse(input, options) { s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 14) === peg$c37) { - s1 = peg$c37; + if (input.substr(peg$currPos, 14) === peg$c32) { + s1 = peg$c32; peg$currPos += 14; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e52); } + if (peg$silentFails === 0) { peg$fail(peg$e48); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -2492,12 +2397,12 @@ function peg$parse(input, options) { s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 13) === peg$c38) { - s1 = peg$c38; + if (input.substr(peg$currPos, 13) === peg$c33) { + s1 = peg$c33; peg$currPos += 13; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e53); } + if (peg$silentFails === 0) { peg$fail(peg$e49); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -2506,12 +2411,12 @@ function peg$parse(input, options) { s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 15) === peg$c39) { - s1 = peg$c39; + if (input.substr(peg$currPos, 15) === peg$c34) { + s1 = peg$c34; peg$currPos += 15; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } + if (peg$silentFails === 0) { peg$fail(peg$e50); } } if (s1 !== peg$FAILED) { peg$savedPos = s0; @@ -2554,7 +2459,7 @@ function peg$parse(input, options) { } const peg$allowedStartRules = [ - "start" + "Start" ]; export { diff --git a/src/cpanfile-peg.pegjs b/src/cpanfile-peg.pegjs index 2e0b9ed..5c5969e 100644 --- a/src/cpanfile-peg.pegjs +++ b/src/cpanfile-peg.pegjs @@ -1,161 +1,141 @@ {{ - import { fullVersion } from './cpan-versions.mjs'; + import { fullVersion } from "./cpan-versions.mjs"; }} -start - = reqs:declarations +Start = reqs:Declarations { return reqs.map(req => ({ - phase: 'runtime', + phase: "runtime", ...req, version: fullVersion(req.version.toString()), })); } -ws - = [ \t\n\r]+ - -comment - = '#' [^\n]* ("\n" / !. ) - -_ - = ( - [ \t\n\r]+ - / comment - )* - -value - = undef - / string - / vstring - / number - -statement_sep - = ( _ ';' _ )+ - -list_sep - = ( _ ( ',' / '=>' ) _ )+ - -bareword - = [_a-z]i [_a-z0-9]i* - -quoted_bareword - = @$bareword &(ws? '=>') - -integer - = digits:$[0-9]+ { return parseInt(digits, 10) } - -decimal - = number:$([0-9] [0-9_]* '.' [0-9_]*) { return parseFloat(number.replace(/_/, '')) } - -number - = decimal - / integer - -undef - = 'undef' { return null } - -vstring - = version:( - integer|3.., '.'| - / 'v' @integer|1.., '.'| - ) { return 'v' + version.join('.') } - -pairs - = '[' @$[^\\\]]* ']' - / '{' @$[^\\\}]* '}' - / '(' @$[^\\\)]* ')' - / '<' @$[^\\\>]* '>' - / '"' @$[^\\\"]* '"' - / '\'' @$[^\\\']* '\'' - -string - = '"' @$[^\\\"$@]* '"' - / '\'' @$[^\\\']* '\'' - / 'qq' @pairs - / 'q' @pairs - -phase - = 'configure' - / 'build' - / 'test' - / 'runtime' - / 'develop' - -parameter - = value - / quoted_bareword - -parameters - = list_sep? @parameter|1.., list_sep| list_sep? - -pragma - = 'use strict' - / 'use warnings' - / 'use ' 'v'? [0-9] ( '.' [0-9]+ )* - -declarations - = _ statement_sep? - reqs:( - requirement|1| - / phase_block - / feature_block - / pragma { return [] } - / '1' { return [] } - )|.., statement_sep| - statement_sep? _ - { return reqs.flat() } - -end_bareword - = !([0-9a-z_']i / ws? '=>') - -requirements - = _ statement_sep? - @requirement|.., statement_sep| - statement_sep? _ - -feature_block_params - = feature:parameter list_sep - description:(@parameter list_sep)? - 'sub' _ '{' reqs:declarations '}' - { return reqs.map(req => ({ ...req, feature, description})) } - -feature_block - = 'feature' end_bareword _ @( - '(' _ @feature_block_params _ ')' - / @feature_block_params - ) - -phase_block_params - = phase:parameter list_sep - 'sub' _ '{' reqs:declarations '}' - { return reqs.map(req => ({ ...req, phase })) } - -phase_block - = 'on' end_bareword _ @( - '(' _ @phase_block_params _ ')' - / @phase_block_params - ) - -requirement - = type:( - relationship:relationship { return { relationship } } - / phase:phase_sub { return { phase, relationship: 'requires' } } - ) end_bareword _ - params:( - '(' _ @parameters _ ')' - / @parameters - ) - { return { prereq: params[0], version: params[1] || 0, ...type } } - -relationship - = 'requires' - / 'recommends' - / 'suggests' - / 'conflicts' - -phase_sub - = 'configure_requires' { return 'configure' } - / 'build_requires' { return 'build' } - / 'test_requires' { return 'test' } - / 'author_requires' { return 'develop' } +WS = [ \t\n\r]+ + +Comment = "#" [^\n]* ( "\n" / !. ) + +_ = ( [ \t\n\r]+ / Comment )* + +Value + = Undef + / String + / VString + / Number + +StatementSep = ( _ ";" _ )+ + +ListSep = ( _ ( "," / "=>" ) _ )+ + +Bareword = [_a-z]i [_a-z0-9]i* + +QuotedBareword = @$Bareword &( WS? "=>" ) + +Integer = digits:$[0-9]+ + { return parseInt(digits, 10) } + +Decimal = number:$( [0-9] [0-9_]* "." [0-9_]* ) + { return parseFloat(number.replace(/_/, "")) } + +Number + = Decimal + / Integer + +Undef = "undef" { return null } + +VString = version:( + Integer|3.., "."| + / "v" @Integer|1.., "."| + ) + { return "v" + version.join(".") } + +Pairs + = "[" @$[^\\\]]* "]" + / "{" @$[^\\\}]* "}" + / "(" @$[^\\\)]* ")" + / "<" @$[^\\\>]* ">" + / "'" @$[^\\\']* "'" + / "\"" @$[^\\\"]* "\"" + +String + = "'" @$[^\\\'$@]* "'" + / "\"" @$[^\\\"$@]* "\"" + / "qq" @Pairs + / "q" @Pairs + +Parameter + = Value + / QuotedBareword + +Parameters = ListSep? @Parameter|1.., ListSep| ListSep? + +Pragma + = "use strict" + / "use warnings" + / "use " "v"? [0-9] ( "." [0-9]+ )* + +Declarations = _ + StatementSep? + reqs:( + Requirement|1| + / PhaseBlock + / FeatureBlock + / Pragma { return [] } + / "1" { return [] } + )|.., StatementSep| + StatementSep? _ + { return reqs.flat() } + +EndBareword = !( [0-9a-z_']i / WS? "=>" ) + +FeatureBlockParams = feature:Parameter ListSep + description:( @Parameter ListSep )? + "sub" _ "{" reqs:Declarations "}" + { return reqs.map(req => ({ ...req, feature, description})) } + +FeatureBlock = "feature" EndBareword _ + @( + "(" _ @FeatureBlockParams _ ")" + / @FeatureBlockParams + ) + +PhaseBlockParams = phase:Parameter ListSep + "sub" _ "{" reqs:Declarations "}" + { return reqs.map(req => ({ ...req, phase })) } + +PhaseBlock = "on" EndBareword _ + @( + "(" _ @PhaseBlockParams _ ")" + / @PhaseBlockParams + ) + +/* +Phase + = "configure" + / "build" + / "test" + / "runtime" + / "develop" +*/ + +Requirement = type:( + relationship:Relationship { return { relationship } } + / phase:PhaseSub { return { phase, relationship: "requires" } } + ) EndBareword _ + params:( + "(" _ @Parameters _ ")" + / @Parameters + ) + { return { prereq: params[0], version: params[1] || 0, ...type } } + +Relationship + = "requires" + / "recommends" + / "suggests" + / "conflicts" + +PhaseSub + = "configure_requires" { return "configure" } + / "build_requires" { return "build" } + / "test_requires" { return "test" } + / "author_requires" { return "develop" } diff --git a/src/ini-peg.mjs b/src/ini-peg.mjs index fde8ab2..da0a1f3 100644 --- a/src/ini-peg.mjs +++ b/src/ini-peg.mjs @@ -172,8 +172,8 @@ function peg$parse(input, options) { var peg$FAILED = {}; var peg$source = options.grammarSource; - var peg$startRuleFunctions = { start: peg$parsestart }; - var peg$startRuleFunction = peg$parsestart; + var peg$startRuleFunctions = { Start: peg$parseStart }; + var peg$startRuleFunction = peg$parseStart; var peg$c0 = "\r"; var peg$c1 = "\n"; @@ -209,12 +209,8 @@ function peg$parse(input, options) { var peg$f2 = function(key, value) { return { key, value } }; var peg$f3 = function(comment) { return { comment } }; var peg$f4 = function() { return [] }; - var peg$f5 = function(assignments) { - return assignments.flat(); - }; - var peg$f6 = function(name) { - return { section: name.trimEnd() }; - }; + var peg$f5 = function(assignments) { return assignments.flat(); }; + var peg$f6 = function(name) { return { section: name.trimEnd() }; }; var peg$currPos = options.peg$currPos | 0; var peg$savedPos = peg$currPos; var peg$posDetailsCache = [{ line: 1, column: 1 }]; @@ -377,21 +373,17 @@ function peg$parse(input, options) { ); } - function peg$parsestart() { - var s0, s1, s2; + function peg$parseStart() { + var s0, s1; s0 = peg$currPos; - s1 = peg$parselines(); - s2 = peg$parseeol(); - if (s2 === peg$FAILED) { - s2 = null; - } + s1 = peg$parseLines(); s0 = s1; return s0; } - function peg$parsews() { + function peg$parseWS() { var s0, s1; s0 = []; @@ -420,7 +412,7 @@ function peg$parse(input, options) { return s0; } - function peg$parseeol() { + function peg$parseEOL() { var s0, s1, s2; s0 = peg$currPos; @@ -452,7 +444,7 @@ function peg$parse(input, options) { return s0; } - function peg$parsekey() { + function peg$parseKey() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; @@ -504,7 +496,7 @@ function peg$parse(input, options) { return s0; } - function peg$parsevalue() { + function peg$parseValue() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; @@ -593,17 +585,17 @@ function peg$parse(input, options) { return s0; } - function peg$parseassignment() { + function peg$parseAssignment() { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; - s1 = peg$parsews(); + s1 = peg$parseWS(); if (s1 === peg$FAILED) { s1 = null; } - s2 = peg$parsekey(); + s2 = peg$parseKey(); if (s2 !== peg$FAILED) { - s3 = peg$parsews(); + s3 = peg$parseWS(); if (s3 === peg$FAILED) { s3 = null; } @@ -615,16 +607,16 @@ function peg$parse(input, options) { if (peg$silentFails === 0) { peg$fail(peg$e8); } } if (s4 !== peg$FAILED) { - s5 = peg$parsews(); + s5 = peg$parseWS(); if (s5 === peg$FAILED) { s5 = null; } - s6 = peg$parsevalue(); - s7 = peg$parsews(); + s6 = peg$parseValue(); + s7 = peg$parseWS(); if (s7 === peg$FAILED) { s7 = null; } - s8 = peg$parsecomment(); + s8 = peg$parseComment(); if (s8 === peg$FAILED) { s8 = null; } @@ -642,11 +634,11 @@ function peg$parse(input, options) { return s0; } - function peg$parsecomment() { + function peg$parseComment() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; - s1 = peg$parsews(); + s1 = peg$parseWS(); if (s1 === peg$FAILED) { s1 = null; } @@ -688,20 +680,20 @@ function peg$parse(input, options) { return s0; } - function peg$parselines() { + function peg$parseLines() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = []; s2 = peg$currPos; s3 = []; - s4 = peg$parsesection(); + s4 = peg$parseSection(); while (s4 !== peg$FAILED) { s3.push(s4); if (s3.length >= 1) { s4 = peg$FAILED; } else { - s4 = peg$parsesection(); + s4 = peg$parseSection(); } } if (s3.length < 1) { @@ -713,13 +705,13 @@ function peg$parse(input, options) { if (s2 === peg$FAILED) { s2 = peg$currPos; s3 = []; - s4 = peg$parseassignment(); + s4 = peg$parseAssignment(); while (s4 !== peg$FAILED) { s3.push(s4); if (s3.length >= 1) { s4 = peg$FAILED; } else { - s4 = peg$parseassignment(); + s4 = peg$parseAssignment(); } } if (s3.length < 1) { @@ -731,13 +723,13 @@ function peg$parse(input, options) { if (s2 === peg$FAILED) { s2 = peg$currPos; s3 = []; - s4 = peg$parsecomment(); + s4 = peg$parseComment(); while (s4 !== peg$FAILED) { s3.push(s4); if (s3.length >= 1) { s4 = peg$FAILED; } else { - s4 = peg$parsecomment(); + s4 = peg$parseComment(); } } if (s3.length < 1) { @@ -748,7 +740,7 @@ function peg$parse(input, options) { } if (s2 === peg$FAILED) { s2 = peg$currPos; - s3 = peg$parsews(); + s3 = peg$parseWS(); if (s3 === peg$FAILED) { s3 = null; } @@ -762,11 +754,11 @@ function peg$parse(input, options) { s1.push(s2); s2 = peg$currPos; s3 = []; - s4 = peg$parseeol(); + s4 = peg$parseEOL(); if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); - s4 = peg$parseeol(); + s4 = peg$parseEOL(); } } else { s3 = peg$FAILED; @@ -774,13 +766,13 @@ function peg$parse(input, options) { if (s3 !== peg$FAILED) { s3 = peg$currPos; s4 = []; - s5 = peg$parsesection(); + s5 = peg$parseSection(); while (s5 !== peg$FAILED) { s4.push(s5); if (s4.length >= 1) { s5 = peg$FAILED; } else { - s5 = peg$parsesection(); + s5 = peg$parseSection(); } } if (s4.length < 1) { @@ -792,13 +784,13 @@ function peg$parse(input, options) { if (s3 === peg$FAILED) { s3 = peg$currPos; s4 = []; - s5 = peg$parseassignment(); + s5 = peg$parseAssignment(); while (s5 !== peg$FAILED) { s4.push(s5); if (s4.length >= 1) { s5 = peg$FAILED; } else { - s5 = peg$parseassignment(); + s5 = peg$parseAssignment(); } } if (s4.length < 1) { @@ -810,13 +802,13 @@ function peg$parse(input, options) { if (s3 === peg$FAILED) { s3 = peg$currPos; s4 = []; - s5 = peg$parsecomment(); + s5 = peg$parseComment(); while (s5 !== peg$FAILED) { s4.push(s5); if (s4.length >= 1) { s5 = peg$FAILED; } else { - s5 = peg$parsecomment(); + s5 = peg$parseComment(); } } if (s4.length < 1) { @@ -827,7 +819,7 @@ function peg$parse(input, options) { } if (s3 === peg$FAILED) { s3 = peg$currPos; - s4 = peg$parsews(); + s4 = peg$parseWS(); if (s4 === peg$FAILED) { s4 = null; } @@ -847,18 +839,21 @@ function peg$parse(input, options) { s2 = s3; } } + s2 = peg$parseEOL(); + if (s2 === peg$FAILED) { + s2 = null; + } peg$savedPos = s0; - s1 = peg$f5(s1); - s0 = s1; + s0 = peg$f5(s1); return s0; } - function peg$parsesection() { + function peg$parseSection() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; - s1 = peg$parsews(); + s1 = peg$parseWS(); if (s1 === peg$FAILED) { s1 = null; } @@ -870,7 +865,7 @@ function peg$parse(input, options) { if (peg$silentFails === 0) { peg$fail(peg$e10); } } if (s2 !== peg$FAILED) { - s3 = peg$parsews(); + s3 = peg$parseWS(); if (s3 === peg$FAILED) { s3 = null; } @@ -903,7 +898,7 @@ function peg$parse(input, options) { s4 = s5; } if (s4 !== peg$FAILED) { - s5 = peg$parsews(); + s5 = peg$parseWS(); if (s5 === peg$FAILED) { s5 = null; } @@ -915,7 +910,7 @@ function peg$parse(input, options) { if (peg$silentFails === 0) { peg$fail(peg$e12); } } if (s6 !== peg$FAILED) { - s7 = peg$parsews(); + s7 = peg$parseWS(); if (s7 === peg$FAILED) { s7 = null; } @@ -966,7 +961,7 @@ function peg$parse(input, options) { } const peg$allowedStartRules = [ - "start" + "Start" ]; export { diff --git a/src/ini-peg.pegjs b/src/ini-peg.pegjs index 5ea015f..79d099b 100644 --- a/src/ini-peg.pegjs +++ b/src/ini-peg.pegjs @@ -1,41 +1,26 @@ -start - = @lines eol? +Start = @Lines +WS = [ \t]+ +EOL = "\r"? "\n" -ws - = [ \t]+ - -eol - = "\r"? "\n" - -key - = key:$([^\x00-\x1f\x7f= ] [^\x00-\x1f\x7f=]*) +Key = key:$( [^\x00-\x1f\x7f= ] [^\x00-\x1f\x7f=]* ) { return key.trimEnd() } -value - = value:$( [^ \t\r\n] ';' / [^\n;] )* +Value = value:$( [^ \t\r\n] ";" / [^\n;] )* { return value.trimEnd() } -assignment - = ws? key:key ws? '=' ws? value:value ws? comment? +Assignment = WS? key:Key WS? "=" WS? value:Value WS? Comment? { return { key, value } } -comment - = ws? ';' comment:$[^\r\n]* +Comment = WS? ";" comment:$[^\r\n]* { return { comment } } -lines - = assignments:( - section|1| - / assignment|1| - / comment|1| - / ws? { return [] } - )|.., eol+| - { - return assignments.flat(); - } +Lines = assignments:( + Section|1| + / Assignment|1| + / Comment|1| + / WS? { return [] } + )|.., EOL+| EOL? + { return assignments.flat(); } -section - = ws? '[' ws? name:$[^\]]+ ws? ']' ws? - { - return { section: name.trimEnd() }; - } +Section = WS? "[" WS? name:$[^\]]+ WS? "]" WS? + { return { section: name.trimEnd() }; }