diff --git a/examples/pnpm-lock.yaml b/examples/pnpm-lock.yaml index 5a66a45d..5eb8f078 100644 --- a/examples/pnpm-lock.yaml +++ b/examples/pnpm-lock.yaml @@ -581,30 +581,12 @@ importers: ../packages/molecule: dependencies: - '@ckb-lumos/bi': - specifier: 0.24.0-next.1 - version: link:../bi '@ckb-lumos/codec': specifier: 0.24.0-next.1 version: link:../codec - '@types/moo': - specifier: ^0.5.9 - version: 0.5.9 - '@types/nearley': - specifier: ^2.11.2 - version: 2.11.5 glob: specifier: ^10.3.10 version: 10.4.1 - minimist: - specifier: ^1.2.8 - version: 1.2.8 - moo: - specifier: ^0.5.1 - version: 0.5.2 - nearley: - specifier: ^2.20.1 - version: 2.20.1 relative: specifier: ^3.0.2 version: 3.0.2 @@ -612,6 +594,9 @@ importers: '@ckb-lumos/base': specifier: 0.24.0-next.1 version: link:../base + '@ckb-lumos/bi': + specifier: 0.24.0-next.1 + version: link:../bi '@types/js-yaml': specifier: ^4.0.9 version: 4.0.9 @@ -5850,14 +5835,6 @@ packages: resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==} dev: true - /@types/moo@0.5.9: - resolution: {integrity: sha512-ZsFVecFi66jGQ6L41TonEaBhsIVeVftTz6iQKWTctzacHhzYHWvv9S0IyAJi4BhN7vb9qCQ3+kpStP2vbZqmDg==} - dev: false - - /@types/nearley@2.11.5: - resolution: {integrity: sha512-dM7TrN0bVxGGXTYGx4YhGear8ysLO5SOuouAWM9oltjQ3m9oYa13qi8Z1DJp5zxVMPukvQdsrnZmgzpeuTSEQA==} - dev: false - /@types/nock@11.1.0: resolution: {integrity: sha512-jI/ewavBQ7X5178262JQR0ewicPAcJhXS/iFaNJl0VHLfyosZ/kwSrsa6VNQNSO8i9d8SqdRgOtZSOKJ/+iNMw==} deprecated: This is a stub types definition. nock provides its own type definitions, so you do not need this installed. @@ -8659,10 +8636,6 @@ packages: dependencies: path-type: 4.0.0 - /discontinuous-range@1.0.0: - resolution: {integrity: sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==} - dev: false - /dlv@1.1.3: resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==} dev: false @@ -12848,10 +12821,6 @@ packages: minimist: 1.2.8 dev: false - /moo@0.5.2: - resolution: {integrity: sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==} - dev: false - /ms@2.0.0: resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} @@ -12933,16 +12902,6 @@ packages: /natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - /nearley@2.20.1: - resolution: {integrity: sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==} - hasBin: true - dependencies: - commander: 2.20.3 - moo: 0.5.2 - railroad-diagrams: 1.0.0 - randexp: 0.4.6 - dev: false - /negotiator@0.6.3: resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} engines: {node: '>= 0.6'} @@ -14562,18 +14521,6 @@ packages: performance-now: 2.1.0 dev: false - /railroad-diagrams@1.0.0: - resolution: {integrity: sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==} - dev: false - - /randexp@0.4.6: - resolution: {integrity: sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==} - engines: {node: '>=0.12'} - dependencies: - discontinuous-range: 1.0.0 - ret: 0.1.15 - dev: false - /randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} dependencies: @@ -15103,11 +15050,6 @@ packages: lowercase-keys: 1.0.1 dev: false - /ret@0.1.15: - resolution: {integrity: sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==} - engines: {node: '>=0.12'} - dev: false - /retry@0.12.0: resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} engines: {node: '>= 4'} diff --git a/packages/molecule/package.json b/packages/molecule/package.json index 6585e305..c707f228 100644 --- a/packages/molecule/package.json +++ b/packages/molecule/package.json @@ -43,7 +43,7 @@ "lint": "eslint -c ../../.eslintrc.js \"{src,tests,examples}/**/*.ts\"", "build": "pnpm run build:types && pnpm run build:js", "build:types": "tsc --declaration --emitDeclarationOnly", - "build:js": "babel --root-mode upward src --out-dir lib --extensions .ts -s && pnpm run build:old", + "build:js": "pnpm generate:grammar && babel --root-mode upward src --out-dir lib --extensions .ts -s && pnpm run build:old", "build:old": "shx mkdir -p lib/grammar && shx cp -r src/grammar/*.js lib/grammar", "clean": "rm -rf lib", "generate:grammar": "peggy -o ./src/grammar/grammar.js ./src/grammar/grammar.peggy", diff --git a/packages/molecule/src/grammar/.gitignore b/packages/molecule/src/grammar/.gitignore new file mode 100644 index 00000000..6ff1973e --- /dev/null +++ b/packages/molecule/src/grammar/.gitignore @@ -0,0 +1 @@ +grammar.js diff --git a/packages/molecule/src/grammar/grammar.js b/packages/molecule/src/grammar/grammar.js deleted file mode 100644 index 5c07f908..00000000 --- a/packages/molecule/src/grammar/grammar.js +++ /dev/null @@ -1,1980 +0,0 @@ -// @generated by Peggy 4.0.3. -// -// https://peggyjs.org/ - -"use strict"; - - -function peg$subclass(child, parent) { - function C() { this.constructor = child; } - C.prototype = parent.prototype; - child.prototype = new C(); -} - -function peg$SyntaxError(message, expected, found, location) { - var self = Error.call(this, message); - // istanbul ignore next Check is a necessary evil to support older environments - if (Object.setPrototypeOf) { - Object.setPrototypeOf(self, peg$SyntaxError.prototype); - } - self.expected = expected; - self.found = found; - self.location = location; - self.name = "SyntaxError"; - return self; -} - -peg$subclass(peg$SyntaxError, Error); - -function peg$padEnd(str, targetLength, padString) { - padString = padString || " "; - if (str.length > targetLength) { return str; } - targetLength -= str.length; - padString += padString.repeat(targetLength); - return str + padString.slice(0, targetLength); -} - -peg$SyntaxError.prototype.format = function(sources) { - var str = "Error: " + this.message; - if (this.location) { - var src = null; - var k; - for (k = 0; k < sources.length; k++) { - if (sources[k].source === this.location.source) { - src = sources[k].text.split(/\r\n|\n|\r/g); - break; - } - } - var s = this.location.start; - var offset_s = (this.location.source && (typeof this.location.source.offset === "function")) - ? this.location.source.offset(s) - : s; - var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; - if (src) { - var e = this.location.end; - var filler = peg$padEnd("", offset_s.line.toString().length, ' '); - var line = src[s.line - 1]; - var last = s.line === e.line ? e.column : line.length + 1; - var hatLen = (last - s.column) || 1; - str += "\n --> " + loc + "\n" - + filler + " |\n" - + offset_s.line + " | " + line + "\n" - + filler + " | " + peg$padEnd("", s.column - 1, ' ') - + peg$padEnd("", hatLen, "^"); - } else { - str += "\n at " + loc; - } - } - return str; -}; - -peg$SyntaxError.buildMessage = function(expected, found) { - var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, - - class: function(expectation) { - var escapedParts = expectation.parts.map(function(part) { - return Array.isArray(part) - ? classEscape(part[0]) + "-" + classEscape(part[1]) - : classEscape(part); - }); - - return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; - }, - - any: function() { - return "any character"; - }, - - end: function() { - return "end of input"; - }, - - other: function(expectation) { - return expectation.description; - } - }; - - function hex(ch) { - return ch.charCodeAt(0).toString(16).toUpperCase(); - } - - function literalEscape(s) { - return s - .replace(/\\/g, "\\\\") - .replace(/"/g, "\\\"") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); - } - - function classEscape(s) { - return s - .replace(/\\/g, "\\\\") - .replace(/\]/g, "\\]") - .replace(/\^/g, "\\^") - .replace(/-/g, "\\-") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); - } - - function describeExpectation(expectation) { - return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); - } - - function describeExpected(expected) { - var descriptions = expected.map(describeExpectation); - var i, j; - - descriptions.sort(); - - if (descriptions.length > 0) { - for (i = 1, j = 1; i < descriptions.length; i++) { - if (descriptions[i - 1] !== descriptions[i]) { - descriptions[j] = descriptions[i]; - j++; - } - } - descriptions.length = j; - } - - switch (descriptions.length) { - case 1: - return descriptions[0]; - - case 2: - return descriptions[0] + " or " + descriptions[1]; - - default: - return descriptions.slice(0, -1).join(", ") - + ", or " - + descriptions[descriptions.length - 1]; - } - } - - function describeFound(found) { - return found ? "\"" + literalEscape(found) + "\"" : "end of input"; - } - - return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; -}; - -function peg$parse(input, options) { - options = options !== undefined ? options : {}; - - var peg$FAILED = {}; - var peg$source = options.grammarSource; - - var peg$startRuleFunctions = { grammar: peg$parsegrammar }; - var peg$startRuleFunction = peg$parsegrammar; - - var peg$c0 = "table"; - var peg$c1 = "{"; - var peg$c2 = "}"; - var peg$c3 = "vector"; - var peg$c4 = "<"; - var peg$c5 = ">"; - var peg$c6 = "struct"; - var peg$c7 = ":"; - var peg$c8 = "array"; - var peg$c9 = "["; - var peg$c10 = ";"; - var peg$c11 = "]"; - var peg$c12 = "union"; - var peg$c13 = "option"; - var peg$c14 = "("; - var peg$c15 = ")"; - var peg$c16 = "syntax"; - var peg$c17 = "="; - var peg$c18 = ","; - var peg$c19 = "import"; - var peg$c20 = "/"; - var peg$c21 = "../"; - var peg$c22 = "/*"; - var peg$c23 = "*/"; - var peg$c24 = "//"; - var peg$c25 = "#"; - var peg$c26 = "\n"; - var peg$c27 = "\r\n"; - var peg$c28 = "0"; - - var peg$r0 = /^[0-9A-Z_a-z]/; - var peg$r1 = /^[A-Za-z]/; - var peg$r2 = /^[A-Z]/; - var peg$r3 = /^[a-z]/; - var peg$r4 = /^[^*\/]/; - var peg$r5 = /^[^\n]/; - var peg$r6 = /^[^\r\n]/; - var peg$r7 = /^[\t ]/; - var peg$r8 = /^[0-9]/; - var peg$r9 = /^[1-9]/; - - var peg$e0 = peg$literalExpectation("table", false); - var peg$e1 = peg$literalExpectation("{", false); - var peg$e2 = peg$literalExpectation("}", false); - var peg$e3 = peg$literalExpectation("vector", false); - var peg$e4 = peg$literalExpectation("<", false); - var peg$e5 = peg$literalExpectation(">", false); - var peg$e6 = peg$literalExpectation("struct", false); - var peg$e7 = peg$literalExpectation(":", false); - var peg$e8 = peg$literalExpectation("array", false); - var peg$e9 = peg$literalExpectation("[", false); - var peg$e10 = peg$literalExpectation(";", false); - var peg$e11 = peg$literalExpectation("]", false); - var peg$e12 = peg$literalExpectation("union", false); - var peg$e13 = peg$literalExpectation("option", false); - var peg$e14 = peg$literalExpectation("(", false); - var peg$e15 = peg$literalExpectation(")", false); - var peg$e16 = peg$literalExpectation("syntax", false); - var peg$e17 = peg$literalExpectation("=", false); - var peg$e18 = peg$literalExpectation(",", false); - var peg$e19 = peg$literalExpectation("import", false); - var peg$e20 = peg$literalExpectation("/", false); - var peg$e21 = peg$literalExpectation("../", false); - var peg$e22 = peg$classExpectation([["0", "9"], ["A", "Z"], "_", ["a", "z"]], false, false); - var peg$e23 = peg$classExpectation([["A", "Z"], ["a", "z"]], false, false); - var peg$e24 = peg$classExpectation([["A", "Z"]], false, false); - var peg$e25 = peg$classExpectation([["a", "z"]], false, false); - var peg$e26 = peg$literalExpectation("/*", false); - var peg$e27 = peg$classExpectation(["*", "/"], true, false); - var peg$e28 = peg$literalExpectation("*/", false); - var peg$e29 = peg$literalExpectation("//", false); - var peg$e30 = peg$literalExpectation("#", false); - var peg$e31 = peg$classExpectation(["\n"], true, false); - var peg$e32 = peg$classExpectation(["\r", "\n"], true, false); - var peg$e33 = peg$classExpectation(["\t", " "], false, false); - var peg$e34 = peg$literalExpectation("\n", false); - var peg$e35 = peg$literalExpectation("\r\n", false); - var peg$e36 = peg$classExpectation([["0", "9"]], false, false); - var peg$e37 = peg$classExpectation([["1", "9"]], false, false); - var peg$e38 = peg$literalExpectation("0", false); - - var peg$f0 = function(version, imports, declares) { - return { - syntaxVersion: version, - imports, - declares, - }; - }; - var peg$f1 = function(declare) { return declare; }; - var peg$f2 = function(name, fields) { - return { - type: "table", - name, - fields, - }; - }; - var peg$f3 = function(name, item) { - return { - type: "vector", - name, - item, - }; - }; - var peg$f4 = function(name, fields) { - return { - type: "struct", - name, - fields, - }; - }; - var peg$f5 = function(name, type) { - return { name, type }; - }; - var peg$f6 = function(name, item, item_count) { - return { - type: "array", - name, - item, - item_count, - }; - }; - var peg$f7 = function(name, declares) { - return { - type: "union", - name, - items: declares, - }; - }; - var peg$f8 = function(name) { return name; }; - var peg$f9 = function(name, id) { - return [name, id]; - }; - var peg$f10 = function(head, tail) { return head + tail.join(""); }; - var peg$f11 = function(name, item) { - return { - type: "option", - name, - item, - }; - }; - var peg$f12 = function(version) { - return version.join(""); - }; - var peg$f13 = function(path) { return path; }; - var peg$f14 = function(head, middle, tail) { - return head.join("") + middle.flatMap((x) => x).join("") + tail; - }; - var peg$f15 = function(head, tail) { return head + tail.join(""); }; - var peg$currPos = options.peg$currPos | 0; - var peg$savedPos = peg$currPos; - var peg$posDetailsCache = [{ line: 1, column: 1 }]; - var peg$maxFailPos = peg$currPos; - var peg$maxFailExpected = options.peg$maxFailExpected || []; - var peg$silentFails = options.peg$silentFails | 0; - - var peg$result; - - if (options.startRule) { - if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); - } - - peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; - } - - function text() { - return input.substring(peg$savedPos, peg$currPos); - } - - function offset() { - return peg$savedPos; - } - - function range() { - return { - source: peg$source, - start: peg$savedPos, - end: peg$currPos - }; - } - - function location() { - return peg$computeLocation(peg$savedPos, peg$currPos); - } - - function expected(description, location) { - location = location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); - - throw peg$buildStructuredError( - [peg$otherExpectation(description)], - input.substring(peg$savedPos, peg$currPos), - location - ); - } - - function error(message, location) { - location = location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); - - throw peg$buildSimpleError(message, location); - } - - function peg$literalExpectation(text, ignoreCase) { - return { type: "literal", text: text, ignoreCase: ignoreCase }; - } - - function peg$classExpectation(parts, inverted, ignoreCase) { - return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; - } - - function peg$anyExpectation() { - return { type: "any" }; - } - - function peg$endExpectation() { - return { type: "end" }; - } - - function peg$otherExpectation(description) { - return { type: "other", description: description }; - } - - function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos]; - var p; - - if (details) { - return details; - } else { - if (pos >= peg$posDetailsCache.length) { - p = peg$posDetailsCache.length - 1; - } else { - p = pos; - while (!peg$posDetailsCache[--p]) {} - } - - details = peg$posDetailsCache[p]; - details = { - line: details.line, - column: details.column - }; - - while (p < pos) { - if (input.charCodeAt(p) === 10) { - details.line++; - details.column = 1; - } else { - details.column++; - } - - p++; - } - - peg$posDetailsCache[pos] = details; - - return details; - } - } - - function peg$computeLocation(startPos, endPos, offset) { - var startPosDetails = peg$computePosDetails(startPos); - var endPosDetails = peg$computePosDetails(endPos); - - var res = { - source: peg$source, - start: { - offset: startPos, - line: startPosDetails.line, - column: startPosDetails.column - }, - end: { - offset: endPos, - line: endPosDetails.line, - column: endPosDetails.column - } - }; - if (offset && peg$source && (typeof peg$source.offset === "function")) { - res.start = peg$source.offset(res.start); - res.end = peg$source.offset(res.end); - } - return res; - } - - function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { return; } - - if (peg$currPos > peg$maxFailPos) { - peg$maxFailPos = peg$currPos; - peg$maxFailExpected = []; - } - - peg$maxFailExpected.push(expected); - } - - function peg$buildSimpleError(message, location) { - return new peg$SyntaxError(message, null, null, location); - } - - function peg$buildStructuredError(expected, found, location) { - return new peg$SyntaxError( - peg$SyntaxError.buildMessage(expected, found), - expected, - found, - location - ); - } - - function peg$parsegrammar() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = []; - s2 = peg$parsebrk(); - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parsebrk(); - } - s2 = peg$parsesyntax_version_stmt(); - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = []; - s4 = peg$parsebrk(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsebrk(); - } - s4 = []; - s5 = peg$parseimport_stmt(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parseimport_stmt(); - } - s5 = []; - s6 = peg$parsebrk(); - while (s6 !== peg$FAILED) { - s5.push(s6); - s6 = peg$parsebrk(); - } - s6 = []; - s7 = peg$parsedecl_stmt(); - if (s7 !== peg$FAILED) { - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsedecl_stmt(); - } - } else { - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f0(s2, s4, s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedecl_stmt() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = []; - s2 = peg$parsebrk(); - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parsebrk(); - } - s2 = peg$parseoption_decl(); - if (s2 === peg$FAILED) { - s2 = peg$parseunion_decl(); - if (s2 === peg$FAILED) { - s2 = peg$parsearray_decl(); - if (s2 === peg$FAILED) { - s2 = peg$parsestruct_decl(); - if (s2 === peg$FAILED) { - s2 = peg$parsevector_decl(); - if (s2 === peg$FAILED) { - s2 = peg$parsetable_decl(); - } - } - } - } - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parsebrk(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsebrk(); - } - peg$savedPos = s0; - s0 = peg$f1(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetable_decl() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c0) { - s1 = peg$c0; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e0); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parseidentifier(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 123) { - s5 = peg$c1; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } - } - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - s7 = []; - s8 = peg$parsefield_decl(); - while (s8 !== peg$FAILED) { - s7.push(s8); - s8 = peg$parsefield_decl(); - } - if (input.charCodeAt(peg$currPos) === 125) { - s8 = peg$c2; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } - } - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f2(s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsevector_decl() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c3) { - s1 = peg$c3; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e3); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parseidentifier(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 60) { - s5 = peg$c4; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e4); } - } - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - s7 = peg$parseidentifier(); - if (s7 !== peg$FAILED) { - s8 = []; - s9 = peg$parsebrk(); - while (s9 !== peg$FAILED) { - s8.push(s9); - s9 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 62) { - s9 = peg$c5; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e5); } - } - if (s9 !== peg$FAILED) { - s10 = []; - s11 = peg$parsebrk(); - while (s11 !== peg$FAILED) { - s10.push(s11); - s11 = peg$parsebrk(); - } - s11 = peg$parsestmt_end(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f3(s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsestruct_decl() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c6) { - s1 = peg$c6; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e6); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parseidentifier(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 123) { - s5 = peg$c1; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } - } - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - s7 = []; - s8 = peg$parsefield_decl(); - while (s8 !== peg$FAILED) { - s7.push(s8); - s8 = peg$parsefield_decl(); - } - if (input.charCodeAt(peg$currPos) === 125) { - s8 = peg$c2; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } - } - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f4(s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsefield_decl() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseidentifier(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 58) { - s3 = peg$c7; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e7); } - } - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - s5 = peg$parseidentifier(); - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - s7 = peg$parsefield_end(); - if (s7 !== peg$FAILED) { - s8 = []; - s9 = peg$parsebrk(); - while (s9 !== peg$FAILED) { - s8.push(s9); - s9 = peg$parsebrk(); - } - peg$savedPos = s0; - s0 = peg$f5(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsearray_decl() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c8) { - s1 = peg$c8; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e8); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parseidentifier(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 91) { - s5 = peg$c9; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e9); } - } - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - s7 = peg$parseidentifier(); - if (s7 !== peg$FAILED) { - s8 = []; - s9 = peg$parsebrk(); - while (s9 !== peg$FAILED) { - s8.push(s9); - s9 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 59) { - s9 = peg$c10; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } - } - if (s9 !== peg$FAILED) { - s10 = []; - s11 = peg$parsebrk(); - while (s11 !== peg$FAILED) { - s10.push(s11); - s11 = peg$parsebrk(); - } - s11 = peg$parsenumber_gt_zero(); - if (s11 !== peg$FAILED) { - s12 = []; - s13 = peg$parsebrk(); - while (s13 !== peg$FAILED) { - s12.push(s13); - s13 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 93) { - s13 = peg$c11; - peg$currPos++; - } else { - s13 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e11); } - } - if (s13 !== peg$FAILED) { - s14 = []; - s15 = peg$parsebrk(); - while (s15 !== peg$FAILED) { - s14.push(s15); - s15 = peg$parsebrk(); - } - s15 = peg$parsestmt_end(); - if (s15 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f6(s3, s7, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseunion_decl() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c12) { - s1 = peg$c12; - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parseidentifier(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 123) { - s5 = peg$c1; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } - } - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - s7 = []; - s8 = peg$parseitem_decl(); - if (s8 === peg$FAILED) { - s8 = peg$parsecustom_union_item_decl(); - } - if (s8 !== peg$FAILED) { - while (s8 !== peg$FAILED) { - s7.push(s8); - s8 = peg$parseitem_decl(); - if (s8 === peg$FAILED) { - s8 = peg$parsecustom_union_item_decl(); - } - } - } else { - s7 = peg$FAILED; - } - if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 125) { - s8 = peg$c2; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } - } - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f7(s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseitem_decl() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseidentifier(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - s3 = peg$parseitem_end(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - peg$savedPos = s0; - s0 = peg$f8(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecustom_union_item_decl() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseidentifier(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 58) { - s3 = peg$c7; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e7); } - } - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - s5 = peg$parsenumber_gte_zero(); - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - s7 = peg$parsefield_end(); - if (s7 !== peg$FAILED) { - s8 = []; - s9 = peg$parsebrk(); - while (s9 !== peg$FAILED) { - s8.push(s9); - s9 = peg$parsebrk(); - } - peg$savedPos = s0; - s0 = peg$f9(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenumber_gte_zero() { - var s0; - - s0 = peg$parsezero(); - if (s0 === peg$FAILED) { - s0 = peg$parsenumber_gt_zero(); - } - - return s0; - } - - function peg$parsenumber_gt_zero() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsenonzero(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsedigit(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsedigit(); - } - peg$savedPos = s0; - s0 = peg$f10(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseoption_decl() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c13) { - s1 = peg$c13; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e13); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parseidentifier(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 40) { - s5 = peg$c14; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e14); } - } - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - s7 = peg$parseidentifier(); - if (s7 !== peg$FAILED) { - s8 = []; - s9 = peg$parsebrk(); - while (s9 !== peg$FAILED) { - s8.push(s9); - s9 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 41) { - s9 = peg$c15; - peg$currPos++; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } - } - if (s9 !== peg$FAILED) { - s10 = peg$parsestmt_end(); - if (s10 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f11(s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesyntax_version_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c16) { - s1 = peg$c16; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e16); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - if (input.charCodeAt(peg$currPos) === 61) { - s3 = peg$c17; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - s5 = peg$parsesyntax_version(); - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - s7 = peg$parsestmt_end(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f12(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesyntax_version() { - var s0, s1; - - s0 = []; - s1 = peg$parsedigit(); - if (s1 !== peg$FAILED) { - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parsedigit(); - } - } else { - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseitem_end() { - var s0; - - if (input.charCodeAt(peg$currPos) === 44) { - s0 = peg$c18; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e18); } - } - - return s0; - } - - function peg$parsefield_end() { - var s0; - - if (input.charCodeAt(peg$currPos) === 44) { - s0 = peg$c18; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e18); } - } - - return s0; - } - - function peg$parseimport_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c19) { - s1 = peg$c19; - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e19); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsebrk(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsebrk(); - } - s3 = peg$parsepath(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$parsebrk(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsebrk(); - } - s5 = peg$parsestmt_end(); - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsebrk(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsebrk(); - } - peg$savedPos = s0; - s0 = peg$f13(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsepath() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = []; - s2 = peg$parsepath_super(); - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parsepath_super(); - } - s2 = []; - s3 = peg$currPos; - s4 = peg$parseidentifier(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 47) { - s5 = peg$c20; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e20); } - } - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parseidentifier(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 47) { - s5 = peg$c20; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e20); } - } - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - s3 = peg$parseidentifier(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f14(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsepath_super() { - var s0; - - if (input.substr(peg$currPos, 3) === peg$c21) { - s0 = peg$c21; - peg$currPos += 3; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e21); } - } - - return s0; - } - - function peg$parseidentifier() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseletter(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = input.charAt(peg$currPos); - if (peg$r0.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e22); } - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = input.charAt(peg$currPos); - if (peg$r0.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e22); } - } - } - peg$savedPos = s0; - s0 = peg$f15(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseletter() { - var s0; - - s0 = input.charAt(peg$currPos); - if (peg$r1.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e23); } - } - - return s0; - } - - function peg$parseuppercase() { - var s0; - - s0 = input.charAt(peg$currPos); - if (peg$r2.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e24); } - } - - return s0; - } - - function peg$parselowercase() { - var s0; - - s0 = input.charAt(peg$currPos); - if (peg$r3.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e25); } - } - - return s0; - } - - function peg$parsestmt_end() { - var s0; - - if (input.charCodeAt(peg$currPos) === 59) { - s0 = peg$c10; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } - } - - return s0; - } - - function peg$parsebrk() { - var s0; - - s0 = peg$parsewhitespace(); - if (s0 === peg$FAILED) { - s0 = peg$parsecomment(); - } - - return s0; - } - - function peg$parsecomment() { - var s0; - - s0 = peg$parseblock_comment(); - if (s0 === peg$FAILED) { - s0 = peg$parseline_comment(); - } - - return s0; - } - - function peg$parseblock_comment() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c22) { - s1 = peg$c22; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e26); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = input.charAt(peg$currPos); - if (peg$r4.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e27); } - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = input.charAt(peg$currPos); - if (peg$r4.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e27); } - } - } - if (input.substr(peg$currPos, 2) === peg$c23) { - s3 = peg$c23; - peg$currPos += 2; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseline_comment() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c24) { - s1 = peg$c24; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e29); } - } - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 35) { - s1 = peg$c25; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e30); } - } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = input.charAt(peg$currPos); - if (peg$r5.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e31); } - } - if (s3 === peg$FAILED) { - s3 = input.charAt(peg$currPos); - if (peg$r6.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e32); } - } - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = input.charAt(peg$currPos); - if (peg$r5.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e31); } - } - if (s3 === peg$FAILED) { - s3 = input.charAt(peg$currPos); - if (peg$r6.test(s3)) { - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e32); } - } - } - } - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsewhitespace() { - var s0; - - s0 = peg$parseifs(); - if (s0 === peg$FAILED) { - s0 = peg$parsenewline(); - } - - return s0; - } - - function peg$parseifs() { - var s0; - - s0 = input.charAt(peg$currPos); - if (peg$r7.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e33); } - } - - return s0; - } - - function peg$parsenewline() { - var s0; - - if (input.charCodeAt(peg$currPos) === 10) { - s0 = peg$c26; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e34); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c27) { - s0 = peg$c27; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e35); } - } - } - - return s0; - } - - function peg$parsedigit() { - var s0; - - s0 = input.charAt(peg$currPos); - if (peg$r8.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e36); } - } - - return s0; - } - - function peg$parsenonzero() { - var s0; - - s0 = input.charAt(peg$currPos); - if (peg$r9.test(s0)) { - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e37); } - } - - return s0; - } - - function peg$parsezero() { - var s0; - - if (input.charCodeAt(peg$currPos) === 48) { - s0 = peg$c28; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } - } - - return s0; - } - - peg$result = peg$startRuleFunction(); - - if (options.peg$library) { - return /** @type {any} */ ({ - peg$result, - peg$currPos, - peg$FAILED, - peg$maxFailExpected, - peg$maxFailPos - }); - } - if (peg$result !== peg$FAILED && peg$currPos === input.length) { - return peg$result; - } else { - if (peg$result !== peg$FAILED && peg$currPos < input.length) { - peg$fail(peg$endExpectation()); - } - - throw peg$buildStructuredError( - peg$maxFailExpected, - peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, - peg$maxFailPos < input.length - ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) - : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) - ); - } -} - -module.exports = { - StartRules: ["grammar"], - SyntaxError: peg$SyntaxError, - parse: peg$parse -};