diff --git a/package.json b/package.json index fc6e82d60..8fd335b2d 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "format-js": "prettier --write README.md CONTRIBUTING.md CODE_OF_CONDUCT.md USAGE.md ./src/**/*.{ts,tsx} ./apps/**/*.{ts,tsx}", "jest": "jest", "lint": "eslint --ext .ts,.tsx src", - "peg": "pegjs -o src/lib/extract/transform.js ./src/lib/extract/transform.peg && peggy -o src/filter-image/extract/extractFiltersString.js src/filter-image/extract/extractFiltersString.pegjs && peggy -o src/lib/extract/transformToRn.js src/lib/extract/transformToRn.pegjs", + "peg": "peggy --format es ./src/lib/extract/transform.peg && peggy --format es src/filter-image/extract/extractFiltersString.pegjs && peggy --format es src/lib/extract/transformToRn.pegjs", "prepare": "npm run bob && husky install", "release": "npm login && release-it", "test": "npm run lint && npm run tsc", @@ -104,7 +104,6 @@ "jest-html-reporters": "^3.1.7", "lint-staged": "^13.0.3", "peggy": "4.0.3", - "pegjs": "^0.10.0", "pixelmatch": "5.3.0", "pngjs": "^7.0.0", "prettier": "3.0.1", diff --git a/shell.nix b/shell.nix new file mode 100644 index 000000000..920acb228 --- /dev/null +++ b/shell.nix @@ -0,0 +1,9 @@ +{pkgs ? import {}}: +pkgs.mkShell { + packages = with pkgs; [ + nodejs + eslint_d + prettierd + yarn + ]; +} diff --git a/src/filter-image/extract/extractFiltersString.js b/src/filter-image/extract/extractFiltersString.js index 9233fb4b6..f62f5679c 100644 --- a/src/filter-image/extract/extractFiltersString.js +++ b/src/filter-image/extract/extractFiltersString.js @@ -2,8 +2,6 @@ // // https://peggyjs.org/ -"use strict"; - function buildDropShadow(offsetX, offsetY, blurRadius, color) { @@ -2035,8 +2033,12 @@ function peg$parse(input, options) { } } -module.exports = { - StartRules: ["start"], - SyntaxError: peg$SyntaxError, - parse: peg$parse +const peg$allowedStartRules = [ + "start" +]; + +export { + peg$allowedStartRules as StartRules, + peg$SyntaxError as SyntaxError, + peg$parse as parse }; diff --git a/src/lib/extract/transform.js b/src/lib/extract/transform.js index 4d4aac664..c2a5fb510 100644 --- a/src/lib/extract/transform.js +++ b/src/lib/extract/transform.js @@ -1,62 +1,99 @@ -/* - * Generated by PEG.js 0.10.0. - * - * http://pegjs.org/ - */ +// @generated by Peggy 4.0.3. +// +// https://peggyjs.org/ -"use strict"; function peg$subclass(child, parent) { - function ctor() { this.constructor = child; } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); + function C() { this.constructor = child; } + C.prototype = parent.prototype; + child.prototype = new C(); } function peg$SyntaxError(message, expected, found, location) { - this.message = message; - this.expected = expected; - this.found = found; - this.location = location; - this.name = "SyntaxError"; - - if (typeof Error.captureStackTrace === "function") { - Error.captureStackTrace(this, peg$SyntaxError); + 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); -peg$SyntaxError.buildMessage = function(expected, found) { - var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, - - "class": function(expectation) { - var escapedParts = "", - i; - - for (i = 0; i < expectation.parts.length; i++) { - escapedParts += expectation.parts[i] instanceof Array - ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) - : classEscape(expectation.parts[i]); - } - - return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; - }, - - any: function(expectation) { - return "any character"; - }, +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); +} - end: function(expectation) { - return "end of input"; - }, +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; +}; - other: function(expectation) { - return expectation.description; - } - }; +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(); @@ -64,28 +101,28 @@ peg$SyntaxError.buildMessage = function(expected, found) { 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); }); + .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); }); + .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) { @@ -93,12 +130,8 @@ peg$SyntaxError.buildMessage = function(expected, found) { } function describeExpected(expected) { - var descriptions = new Array(expected.length), - i, j; - - for (i = 0; i < expected.length; i++) { - descriptions[i] = describeExpectation(expected[i]); - } + var descriptions = expected.map(describeExpectation); + var i, j; descriptions.sort(); @@ -134,112 +167,116 @@ peg$SyntaxError.buildMessage = function(expected, found) { }; function peg$parse(input, options) { - options = options !== void 0 ? options : {}; - - var peg$FAILED = {}, - - peg$startRuleFunctions = { transformList: peg$parsetransformList }, - peg$startRuleFunction = peg$parsetransformList, - - peg$c0 = function(ts) { return ts; }, - peg$c1 = function(t, ts) { - return multiply_matrices(t, ts); - }, - peg$c2 = "matrix", - peg$c3 = peg$literalExpectation("matrix", false), - peg$c4 = "(", - peg$c5 = peg$literalExpectation("(", false), - peg$c6 = ")", - peg$c7 = peg$literalExpectation(")", false), - peg$c8 = function(a, b, c, d, e, f) { - return [ - a, c, e, - b, d, f - ]; - }, - peg$c9 = "translate", - peg$c10 = peg$literalExpectation("translate", false), - peg$c11 = function(tx, ty) { - return [ - 1, 0, tx, - 0, 1, ty || 0 - ]; - }, - peg$c12 = "scale", - peg$c13 = peg$literalExpectation("scale", false), - peg$c14 = function(sx, sy) { - return [ - sx, 0, 0, - 0, sy === null ? sx : sy, 0 - ]; - }, - peg$c15 = "rotate", - peg$c16 = peg$literalExpectation("rotate", false), - peg$c17 = function(angle, c) { - var cos = Math.cos(deg2rad * angle); - var sin = Math.sin(deg2rad * angle); - if (c !== null) { - var x = c[0]; - var y = c[1]; - return [ - cos, -sin, cos * -x + -sin * -y + x, - sin, cos, sin * -x + cos * -y + y - ]; - } - return [ - cos, -sin, 0, - sin, cos, 0 - ]; - }, - peg$c18 = "skewX", - peg$c19 = peg$literalExpectation("skewX", false), - peg$c20 = function(angle) { - return [ - 1, Math.tan(deg2rad * angle), 0, - 0, 1, 0 - ]; - }, - peg$c21 = "skewY", - peg$c22 = peg$literalExpectation("skewY", false), - peg$c23 = function(angle) { - return [ - 1, 0, 0, - Math.tan(deg2rad * angle), 1, 0 - ]; - }, - peg$c24 = function(f) { return parseFloat(f.join("")); }, - peg$c25 = function(i) { return parseInt(i.join("")); }, - peg$c26 = function(n) { return n; }, - peg$c27 = function(n1, n2) { return [n1, n2]; }, - peg$c28 = ",", - peg$c29 = peg$literalExpectation(",", false), - peg$c30 = function(ds) { return ds.join(""); }, - peg$c31 = function(f) { return f.join(""); }, - peg$c32 = function(d) { return d.join(""); }, - peg$c33 = peg$otherExpectation("fractionalConstant"), - peg$c34 = ".", - peg$c35 = peg$literalExpectation(".", false), - peg$c36 = function(d1, d2) { return [d1 ? d1.join("") : null, ".", d2.join("")].join(""); }, - peg$c37 = /^[eE]/, - peg$c38 = peg$classExpectation(["e", "E"], false, false), - peg$c39 = function(e) { return [e[0], e[1], e[2].join("")].join(""); }, - peg$c40 = /^[+\-]/, - peg$c41 = peg$classExpectation(["+", "-"], false, false), - peg$c42 = /^[0-9]/, - peg$c43 = peg$classExpectation([["0", "9"]], false, false), - peg$c44 = /^[ \t\r\n]/, - peg$c45 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false), - - peg$currPos = 0, - peg$savedPos = 0, - peg$posDetailsCache = [{ line: 1, column: 1 }], - peg$maxFailPos = 0, - peg$maxFailExpected = [], - peg$silentFails = 0, - - peg$result; - - if ("startRule" in options) { + options = options !== undefined ? options : {}; + + var peg$FAILED = {}; + var peg$source = options.grammarSource; + + var peg$startRuleFunctions = { transformList: peg$parsetransformList }; + var peg$startRuleFunction = peg$parsetransformList; + + var peg$c0 = "matrix"; + var peg$c1 = "("; + var peg$c2 = ")"; + var peg$c3 = "translate"; + var peg$c4 = "scale"; + var peg$c5 = "rotate"; + var peg$c6 = "skewX"; + var peg$c7 = "skewY"; + var peg$c8 = ","; + var peg$c9 = "."; + + var peg$r0 = /^[eE]/; + var peg$r1 = /^[+\-]/; + var peg$r2 = /^[0-9]/; + var peg$r3 = /^[ \t\r\n]/; + + var peg$e0 = peg$literalExpectation("matrix", false); + var peg$e1 = peg$literalExpectation("(", false); + var peg$e2 = peg$literalExpectation(")", false); + var peg$e3 = peg$literalExpectation("translate", false); + var peg$e4 = peg$literalExpectation("scale", false); + var peg$e5 = peg$literalExpectation("rotate", false); + var peg$e6 = peg$literalExpectation("skewX", false); + var peg$e7 = peg$literalExpectation("skewY", false); + var peg$e8 = peg$literalExpectation(",", false); + var peg$e9 = peg$otherExpectation("fractionalConstant"); + var peg$e10 = peg$literalExpectation(".", false); + var peg$e11 = peg$classExpectation(["e", "E"], false, false); + var peg$e12 = peg$classExpectation(["+", "-"], false, false); + var peg$e13 = peg$classExpectation([["0", "9"]], false, false); + var peg$e14 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false); + + var peg$f0 = function(ts) { return ts; }; + var peg$f1 = function(t, ts) { + return multiply_matrices(t, ts); + }; + var peg$f2 = function(a, b, c, d, e, f) { + return [ + a, c, e, + b, d, f + ]; + }; + var peg$f3 = function(tx, ty) { + return [ + 1, 0, tx, + 0, 1, ty || 0 + ]; + }; + var peg$f4 = function(sx, sy) { + return [ + sx, 0, 0, + 0, sy === null ? sx : sy, 0 + ]; + }; + var peg$f5 = function(angle, c) { + var cos = Math.cos(deg2rad * angle); + var sin = Math.sin(deg2rad * angle); + if (c !== null) { + var x = c[0]; + var y = c[1]; + return [ + cos, -sin, cos * -x + -sin * -y + x, + sin, cos, sin * -x + cos * -y + y + ]; + } + return [ + cos, -sin, 0, + sin, cos, 0 + ]; + }; + var peg$f6 = function(angle) { + return [ + 1, Math.tan(deg2rad * angle), 0, + 0, 1, 0 + ]; + }; + var peg$f7 = function(angle) { + return [ + 1, 0, 0, + Math.tan(deg2rad * angle), 1, 0 + ]; + }; + var peg$f8 = function(f) { return parseFloat(f.join("")); }; + var peg$f9 = function(i) { return parseInt(i.join("")); }; + var peg$f10 = function(n) { return n; }; + var peg$f11 = function(n1, n2) { return [n1, n2]; }; + var peg$f12 = function(ds) { return ds.join(""); }; + var peg$f13 = function(f) { return f.join(""); }; + var peg$f14 = function(d) { return d.join(""); }; + var peg$f15 = function(d1, d2) { return [d1 ? d1.join("") : null, ".", d2.join("")].join(""); }; + var peg$f16 = function(d) { return d.join(""); }; + var peg$f17 = function(e) { return [e[0], e[1], e[2].join("")].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 + "\"."); } @@ -251,12 +288,26 @@ function peg$parse(input, options) { 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 !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError( [peg$otherExpectation(description)], @@ -266,7 +317,9 @@ function peg$parse(input, options) { } function error(message, location) { - location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location); } @@ -292,19 +345,22 @@ function peg$parse(input, options) { } function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos], p; + var details = peg$posDetailsCache[pos]; + var p; if (details) { return details; } else { - p = pos - 1; - while (!peg$posDetailsCache[p]) { - p--; + 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, + line: details.line, column: details.column }; @@ -320,26 +376,33 @@ function peg$parse(input, options) { } peg$posDetailsCache[pos] = details; + return details; } } - function peg$computeLocation(startPos, endPos) { - var startPosDetails = peg$computePosDetails(startPos), - endPosDetails = peg$computePosDetails(endPos); + function peg$computeLocation(startPos, endPos, offset) { + var startPosDetails = peg$computePosDetails(startPos); + var endPosDetails = peg$computePosDetails(endPos); - return { + var res = { + source: peg$source, start: { offset: startPos, - line: startPosDetails.line, + line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, - line: endPosDetails.line, + 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) { @@ -376,34 +439,18 @@ function peg$parse(input, options) { s1.push(s2); s2 = peg$parsewsp(); } - if (s1 !== peg$FAILED) { - s2 = peg$parsetransforms(); - if (s2 === peg$FAILED) { - s2 = null; - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parsewsp(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsewsp(); - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c0(s2); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; + s2 = peg$parsetransforms(); + if (s2 === peg$FAILED) { + s2 = null; + } + s3 = []; + s4 = peg$parsewsp(); + while (s4 !== peg$FAILED) { + s3.push(s4); + s4 = peg$parsewsp(); } + peg$savedPos = s0; + s0 = peg$f0(s2); return s0; } @@ -420,16 +467,10 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parsecommaWsp(); } - if (s2 !== peg$FAILED) { - s3 = peg$parsetransforms(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c1(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s3 = peg$parsetransforms(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f1(s1, s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -472,12 +513,12 @@ function peg$parse(input, options) { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17; s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c2) { - s1 = peg$c2; + if (input.substr(peg$currPos, 6) === peg$c0) { + s1 = peg$c0; peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c3); } + if (peg$silentFails === 0) { peg$fail(peg$e0); } } if (s1 !== peg$FAILED) { s2 = []; @@ -486,74 +527,58 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parsewsp(); } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s3 = peg$c4; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c5); } - } - if (s3 !== peg$FAILED) { - s4 = []; + if (input.charCodeAt(peg$currPos) === 40) { + s3 = peg$c1; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsewsp(); + while (s5 !== peg$FAILED) { + s4.push(s5); s5 = peg$parsewsp(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsewsp(); - } - if (s4 !== peg$FAILED) { - s5 = peg$parsenumber(); - if (s5 !== peg$FAILED) { - s6 = peg$parsecommaWsp(); - if (s6 !== peg$FAILED) { - s7 = peg$parsenumber(); - if (s7 !== peg$FAILED) { - s8 = peg$parsecommaWsp(); - if (s8 !== peg$FAILED) { - s9 = peg$parsenumber(); - if (s9 !== peg$FAILED) { - s10 = peg$parsecommaWsp(); - if (s10 !== peg$FAILED) { - s11 = peg$parsenumber(); - if (s11 !== peg$FAILED) { - s12 = peg$parsecommaWsp(); - if (s12 !== peg$FAILED) { - s13 = peg$parsenumber(); - if (s13 !== peg$FAILED) { - s14 = peg$parsecommaWsp(); - if (s14 !== peg$FAILED) { - s15 = peg$parsenumber(); - if (s15 !== peg$FAILED) { - s16 = []; - s17 = peg$parsewsp(); - while (s17 !== peg$FAILED) { - s16.push(s17); - s17 = peg$parsewsp(); - } - if (s16 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s17 = peg$c6; - peg$currPos++; - } else { - s17 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } - } - if (s17 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c8(s5, s7, s9, s11, s13, s15); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + } + s5 = peg$parsenumber(); + if (s5 !== peg$FAILED) { + s6 = peg$parsecommaWsp(); + if (s6 !== peg$FAILED) { + s7 = peg$parsenumber(); + if (s7 !== peg$FAILED) { + s8 = peg$parsecommaWsp(); + if (s8 !== peg$FAILED) { + s9 = peg$parsenumber(); + if (s9 !== peg$FAILED) { + s10 = peg$parsecommaWsp(); + if (s10 !== peg$FAILED) { + s11 = peg$parsenumber(); + if (s11 !== peg$FAILED) { + s12 = peg$parsecommaWsp(); + if (s12 !== peg$FAILED) { + s13 = peg$parsenumber(); + if (s13 !== peg$FAILED) { + s14 = peg$parsecommaWsp(); + if (s14 !== peg$FAILED) { + s15 = peg$parsenumber(); + if (s15 !== peg$FAILED) { + s16 = []; + s17 = peg$parsewsp(); + while (s17 !== peg$FAILED) { + s16.push(s17); + s17 = peg$parsewsp(); + } + if (input.charCodeAt(peg$currPos) === 41) { + s17 = peg$c2; + peg$currPos++; + } else { + s17 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } + if (s17 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f2(s5, s7, s9, s11, s13, s15); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -618,12 +643,12 @@ function peg$parse(input, options) { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; - if (input.substr(peg$currPos, 9) === peg$c9) { - s1 = peg$c9; + if (input.substr(peg$currPos, 9) === peg$c3) { + s1 = peg$c3; peg$currPos += 9; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c10); } + if (peg$silentFails === 0) { peg$fail(peg$e3); } } if (s1 !== peg$FAILED) { s2 = []; @@ -632,63 +657,42 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parsewsp(); } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s3 = peg$c4; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c5); } - } - if (s3 !== peg$FAILED) { - s4 = []; + if (input.charCodeAt(peg$currPos) === 40) { + s3 = peg$c1; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsewsp(); + while (s5 !== peg$FAILED) { + s4.push(s5); s5 = peg$parsewsp(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsewsp(); + } + s5 = peg$parsenumber(); + if (s5 !== peg$FAILED) { + s6 = peg$parsecommaWspNumber(); + if (s6 === peg$FAILED) { + s6 = null; } - if (s4 !== peg$FAILED) { - s5 = peg$parsenumber(); - if (s5 !== peg$FAILED) { - s6 = peg$parsecommaWspNumber(); - if (s6 === peg$FAILED) { - s6 = null; - } - if (s6 !== peg$FAILED) { - s7 = []; - s8 = peg$parsewsp(); - while (s8 !== peg$FAILED) { - s7.push(s8); - s8 = peg$parsewsp(); - } - if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s8 = peg$c6; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } - } - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c11(s5, s6); - s0 = s1; - } 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; - } + s7 = []; + s8 = peg$parsewsp(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsewsp(); + } + if (input.charCodeAt(peg$currPos) === 41) { + 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$f3(s5, s6); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -713,12 +717,12 @@ function peg$parse(input, options) { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c12) { - s1 = peg$c12; + if (input.substr(peg$currPos, 5) === peg$c4) { + s1 = peg$c4; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c13); } + if (peg$silentFails === 0) { peg$fail(peg$e4); } } if (s1 !== peg$FAILED) { s2 = []; @@ -727,63 +731,42 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parsewsp(); } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s3 = peg$c4; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c5); } - } - if (s3 !== peg$FAILED) { - s4 = []; + if (input.charCodeAt(peg$currPos) === 40) { + s3 = peg$c1; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsewsp(); + while (s5 !== peg$FAILED) { + s4.push(s5); s5 = peg$parsewsp(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsewsp(); + } + s5 = peg$parsenumber(); + if (s5 !== peg$FAILED) { + s6 = peg$parsecommaWspNumber(); + if (s6 === peg$FAILED) { + s6 = null; } - if (s4 !== peg$FAILED) { - s5 = peg$parsenumber(); - if (s5 !== peg$FAILED) { - s6 = peg$parsecommaWspNumber(); - if (s6 === peg$FAILED) { - s6 = null; - } - if (s6 !== peg$FAILED) { - s7 = []; - s8 = peg$parsewsp(); - while (s8 !== peg$FAILED) { - s7.push(s8); - s8 = peg$parsewsp(); - } - if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s8 = peg$c6; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } - } - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c14(s5, s6); - s0 = s1; - } 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; - } + s7 = []; + s8 = peg$parsewsp(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsewsp(); + } + if (input.charCodeAt(peg$currPos) === 41) { + 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(s5, s6); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -808,12 +791,12 @@ function peg$parse(input, options) { var s0, s1, s2, s3, s4, s5, s6, s7, s8; s0 = peg$currPos; - if (input.substr(peg$currPos, 6) === peg$c15) { - s1 = peg$c15; + if (input.substr(peg$currPos, 6) === peg$c5) { + s1 = peg$c5; peg$currPos += 6; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c16); } + if (peg$silentFails === 0) { peg$fail(peg$e5); } } if (s1 !== peg$FAILED) { s2 = []; @@ -822,63 +805,42 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parsewsp(); } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s3 = peg$c4; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c5); } - } - if (s3 !== peg$FAILED) { - s4 = []; + if (input.charCodeAt(peg$currPos) === 40) { + s3 = peg$c1; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsewsp(); + while (s5 !== peg$FAILED) { + s4.push(s5); s5 = peg$parsewsp(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsewsp(); + } + s5 = peg$parsenumber(); + if (s5 !== peg$FAILED) { + s6 = peg$parsecommaWspTwoNumbers(); + if (s6 === peg$FAILED) { + s6 = null; } - if (s4 !== peg$FAILED) { - s5 = peg$parsenumber(); - if (s5 !== peg$FAILED) { - s6 = peg$parsecommaWspTwoNumbers(); - if (s6 === peg$FAILED) { - s6 = null; - } - if (s6 !== peg$FAILED) { - s7 = []; - s8 = peg$parsewsp(); - while (s8 !== peg$FAILED) { - s7.push(s8); - s8 = peg$parsewsp(); - } - if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s8 = peg$c6; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } - } - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c17(s5, s6); - s0 = s1; - } 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; - } + s7 = []; + s8 = peg$parsewsp(); + while (s8 !== peg$FAILED) { + s7.push(s8); + s8 = peg$parsewsp(); + } + if (input.charCodeAt(peg$currPos) === 41) { + 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$f5(s5, s6); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -903,12 +865,12 @@ function peg$parse(input, options) { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c18) { - s1 = peg$c18; + if (input.substr(peg$currPos, 5) === peg$c6) { + s1 = peg$c6; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c19); } + if (peg$silentFails === 0) { peg$fail(peg$e6); } } if (s1 !== peg$FAILED) { s2 = []; @@ -917,54 +879,38 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parsewsp(); } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s3 = peg$c4; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c5); } - } - if (s3 !== peg$FAILED) { - s4 = []; + if (input.charCodeAt(peg$currPos) === 40) { + s3 = peg$c1; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsewsp(); + while (s5 !== peg$FAILED) { + s4.push(s5); s5 = peg$parsewsp(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsewsp(); + } + s5 = peg$parsenumber(); + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsewsp(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsewsp(); } - if (s4 !== peg$FAILED) { - s5 = peg$parsenumber(); - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsewsp(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsewsp(); - } - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s7 = peg$c6; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } - } - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c20(s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 41) { + s7 = peg$c2; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } + if (s7 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f6(s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -989,12 +935,12 @@ function peg$parse(input, options) { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; - if (input.substr(peg$currPos, 5) === peg$c21) { - s1 = peg$c21; + if (input.substr(peg$currPos, 5) === peg$c7) { + s1 = peg$c7; peg$currPos += 5; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c22); } + if (peg$silentFails === 0) { peg$fail(peg$e7); } } if (s1 !== peg$FAILED) { s2 = []; @@ -1003,54 +949,38 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parsewsp(); } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 40) { - s3 = peg$c4; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c5); } - } - if (s3 !== peg$FAILED) { - s4 = []; + if (input.charCodeAt(peg$currPos) === 40) { + s3 = peg$c1; + peg$currPos++; + } else { + s3 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e1); } + } + if (s3 !== peg$FAILED) { + s4 = []; + s5 = peg$parsewsp(); + while (s5 !== peg$FAILED) { + s4.push(s5); s5 = peg$parsewsp(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsewsp(); + } + s5 = peg$parsenumber(); + if (s5 !== peg$FAILED) { + s6 = []; + s7 = peg$parsewsp(); + while (s7 !== peg$FAILED) { + s6.push(s7); + s7 = peg$parsewsp(); } - if (s4 !== peg$FAILED) { - s5 = peg$parsenumber(); - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsewsp(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsewsp(); - } - if (s6 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 41) { - s7 = peg$c6; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } - } - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c23(s5); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 41) { + s7 = peg$c2; + peg$currPos++; + } else { + s7 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e2); } + } + if (s7 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f7(s5); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1080,22 +1010,17 @@ function peg$parse(input, options) { if (s2 === peg$FAILED) { s2 = null; } - if (s2 !== peg$FAILED) { - s3 = peg$parsefloatingPointConstant(); - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } + s3 = peg$parsefloatingPointConstant(); + if (s3 !== peg$FAILED) { + s2 = [s2, s3]; + s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c24(s1); + s1 = peg$f8(s1); } s0 = s1; if (s0 === peg$FAILED) { @@ -1105,22 +1030,17 @@ function peg$parse(input, options) { if (s2 === peg$FAILED) { s2 = null; } - if (s2 !== peg$FAILED) { - s3 = peg$parseintegerConstant(); - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } + s3 = peg$parseintegerConstant(); + if (s3 !== peg$FAILED) { + s2 = [s2, s3]; + s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c25(s1); + s1 = peg$f9(s1); } s0 = s1; } @@ -1137,8 +1057,7 @@ function peg$parse(input, options) { s2 = peg$parsenumber(); if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c26(s2); - s0 = s1; + s0 = peg$f10(s2); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1164,8 +1083,7 @@ function peg$parse(input, options) { s4 = peg$parsenumber(); if (s4 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c27(s2, s4); - s0 = s1; + s0 = peg$f11(s2, s4); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1205,24 +1123,14 @@ function peg$parse(input, options) { if (s2 === peg$FAILED) { s2 = null; } - if (s2 !== peg$FAILED) { - s3 = []; + s3 = []; + s4 = peg$parsewsp(); + while (s4 !== peg$FAILED) { + s3.push(s4); s4 = peg$parsewsp(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsewsp(); - } - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; } + s1 = [s1, s2, s3]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1237,13 +1145,8 @@ function peg$parse(input, options) { s2.push(s3); s3 = peg$parsewsp(); } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + s1 = [s1, s2]; + s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1257,11 +1160,11 @@ function peg$parse(input, options) { var s0; if (input.charCodeAt(peg$currPos) === 44) { - s0 = peg$c28; + s0 = peg$c8; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c29); } + if (peg$silentFails === 0) { peg$fail(peg$e8); } } return s0; @@ -1274,7 +1177,7 @@ function peg$parse(input, options) { s1 = peg$parsedigitSequence(); if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c30(s1); + s1 = peg$f12(s1); } s0 = s1; @@ -1292,20 +1195,15 @@ function peg$parse(input, options) { if (s3 === peg$FAILED) { s3 = null; } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } + s2 = [s2, s3]; + s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c31(s1); + s1 = peg$f13(s1); } s0 = s1; if (s0 === peg$FAILED) { @@ -1327,7 +1225,7 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c32(s1); + s1 = peg$f14(s1); } s0 = s1; } @@ -1344,24 +1242,18 @@ function peg$parse(input, options) { if (s1 === peg$FAILED) { s1 = null; } - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 46) { - s2 = peg$c34; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } - } - if (s2 !== peg$FAILED) { - s3 = peg$parsedigitSequence(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$c36(s1, s3); - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } + if (input.charCodeAt(peg$currPos) === 46) { + s2 = peg$c9; + peg$currPos++; + } else { + s2 = peg$FAILED; + if (peg$silentFails === 0) { peg$fail(peg$e10); } + } + if (s2 !== peg$FAILED) { + s3 = peg$parsedigitSequence(); + if (s3 !== peg$FAILED) { + peg$savedPos = s0; + s0 = peg$f15(s1, s3); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1375,16 +1267,15 @@ function peg$parse(input, options) { s1 = peg$parsedigitSequence(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 46) { - s2 = peg$c34; + s2 = peg$c9; peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } + if (peg$silentFails === 0) { peg$fail(peg$e10); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c32(s1); - s0 = s1; + s0 = peg$f16(s1); } else { peg$currPos = s0; s0 = peg$FAILED; @@ -1397,7 +1288,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { peg$fail(peg$e9); } } return s0; @@ -1408,27 +1299,22 @@ function peg$parse(input, options) { s0 = peg$currPos; s1 = peg$currPos; - if (peg$c37.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); + s2 = input.charAt(peg$currPos); + if (peg$r0.test(s2)) { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c38); } + if (peg$silentFails === 0) { peg$fail(peg$e11); } } if (s2 !== peg$FAILED) { s3 = peg$parsesign(); if (s3 === peg$FAILED) { s3 = null; } - if (s3 !== peg$FAILED) { - s4 = peg$parsedigitSequence(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } + s4 = peg$parsedigitSequence(); + if (s4 !== peg$FAILED) { + s2 = [s2, s3, s4]; + s1 = s2; } else { peg$currPos = s1; s1 = peg$FAILED; @@ -1439,7 +1325,7 @@ function peg$parse(input, options) { } if (s1 !== peg$FAILED) { peg$savedPos = s0; - s1 = peg$c39(s1); + s1 = peg$f17(s1); } s0 = s1; @@ -1449,12 +1335,12 @@ function peg$parse(input, options) { function peg$parsesign() { var s0; - if (peg$c40.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); + s0 = input.charAt(peg$currPos); + if (peg$r1.test(s0)) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c41); } + if (peg$silentFails === 0) { peg$fail(peg$e12); } } return s0; @@ -1480,12 +1366,12 @@ function peg$parse(input, options) { function peg$parsedigit() { var s0; - if (peg$c42.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); + s0 = input.charAt(peg$currPos); + if (peg$r2.test(s0)) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c43); } + if (peg$silentFails === 0) { peg$fail(peg$e13); } } return s0; @@ -1494,55 +1380,63 @@ function peg$parse(input, options) { function peg$parsewsp() { var s0; - if (peg$c44.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); + s0 = input.charAt(peg$currPos); + if (peg$r3.test(s0)) { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c45); } + if (peg$silentFails === 0) { peg$fail(peg$e14); } } return s0; } - var deg2rad = Math.PI / 180; - - /* - ╔═ ═╗ ╔═ ═╗ ╔═ ═╗ - ║ al cl el ║ ║ ar cr er ║ ║ a c e ║ - ║ bl dl fl ║ * ║ br dr fr ║ = ║ b d f ║ - ║ 0 0 1 ║ ║ 0 0 1 ║ ║ 0 0 1 ║ - ╚═ ═╝ ╚═ ═╝ ╚═ ═╝ - */ - function multiply_matrices(l, r) { - var al = l[0]; - var cl = l[1]; - var el = l[2]; - var bl = l[3]; - var dl = l[4]; - var fl = l[5]; - - var ar = r[0]; - var cr = r[1]; - var er = r[2]; - var br = r[3]; - var dr = r[4]; - var fr = r[5]; - - var a = al * ar + cl * br; - var c = al * cr + cl * dr; - var e = al * er + cl * fr + el; - var b = bl * ar + dl * br; - var d = bl * cr + dl * dr; - var f = bl * er + dl * fr + fl; - - return [a, c, e, b, d, f]; - } - + var deg2rad = Math.PI / 180; + + /* + ╔═ ═╗ ╔═ ═╗ ╔═ ═╗ + ║ al cl el ║ ║ ar cr er ║ ║ a c e ║ + ║ bl dl fl ║ * ║ br dr fr ║ = ║ b d f ║ + ║ 0 0 1 ║ ║ 0 0 1 ║ ║ 0 0 1 ║ + ╚═ ═╝ ╚═ ═╝ ╚═ ═╝ + */ + function multiply_matrices(l, r) { + var al = l[0]; + var cl = l[1]; + var el = l[2]; + var bl = l[3]; + var dl = l[4]; + var fl = l[5]; + + var ar = r[0]; + var cr = r[1]; + var er = r[2]; + var br = r[3]; + var dr = r[4]; + var fr = r[5]; + + var a = al * ar + cl * br; + var c = al * cr + cl * dr; + var e = al * er + cl * fr + el; + var b = bl * ar + dl * br; + var d = bl * cr + dl * dr; + var f = bl * er + dl * fr + fl; + + return [a, c, e, b, d, f]; + } 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 { @@ -1560,7 +1454,12 @@ function peg$parse(input, options) { } } -module.exports = { - SyntaxError: peg$SyntaxError, - parse: peg$parse +const peg$allowedStartRules = [ + "transformList" +]; + +export { + peg$allowedStartRules as StartRules, + peg$SyntaxError as SyntaxError, + peg$parse as parse }; diff --git a/src/lib/extract/transformToRn.js b/src/lib/extract/transformToRn.js index 9f2c85c80..ab2148cff 100644 --- a/src/lib/extract/transformToRn.js +++ b/src/lib/extract/transformToRn.js @@ -2,12 +2,9 @@ // // https://peggyjs.org/ -'use strict'; function peg$subclass(child, parent) { - function C() { - this.constructor = child; - } + function C() { this.constructor = child; } C.prototype = parent.prototype; child.prototype = new C(); } @@ -21,24 +18,22 @@ function peg$SyntaxError(message, expected, found, location) { self.expected = expected; self.found = found; self.location = location; - self.name = 'SyntaxError'; + self.name = "SyntaxError"; return self; } peg$subclass(peg$SyntaxError, Error); function peg$padEnd(str, targetLength, padString) { - padString = padString || ' '; - if (str.length > targetLength) { - return str; - } + 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; +peg$SyntaxError.prototype.format = function(sources) { + var str = "Error: " + this.message; if (this.location) { var src = null; var k; @@ -49,68 +44,55 @@ peg$SyntaxError.prototype.format = function (sources) { } } 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; + 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 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, '^'); + 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; + str += "\n at " + loc; } } return str; }; -peg$SyntaxError.buildMessage = function (expected, found) { +peg$SyntaxError.buildMessage = function(expected, found) { var DESCRIBE_EXPECTATION_FNS = { - literal: function (expectation) { - return '"' + literalEscape(expectation.text) + '"'; + literal: function(expectation) { + return "\"" + literalEscape(expectation.text) + "\""; }, - class: function (expectation) { - var escapedParts = expectation.parts.map(function (part) { + class: function(expectation) { + var escapedParts = expectation.parts.map(function(part) { return Array.isArray(part) - ? classEscape(part[0]) + '-' + classEscape(part[1]) + ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part); }); - return ( - '[' + (expectation.inverted ? '^' : '') + escapedParts.join('') + ']' - ); + return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; }, - any: function () { - return 'any character'; + any: function() { + return "any character"; }, - end: function () { - return 'end of input'; + end: function() { + return "end of input"; }, - other: function (expectation) { + other: function(expectation) { return expectation.description; - }, + } }; function hex(ch) { @@ -119,36 +101,28 @@ peg$SyntaxError.buildMessage = function (expected, found) { 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); - }); + .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); - }); + .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) { @@ -176,28 +150,20 @@ peg$SyntaxError.buildMessage = function (expected, found) { return descriptions[0]; case 2: - return descriptions[0] + ' or ' + descriptions[1]; + return descriptions[0] + " or " + descriptions[1]; default: - return ( - descriptions.slice(0, -1).join(', ') + - ', or ' + - descriptions[descriptions.length - 1] - ); + return descriptions.slice(0, -1).join(", ") + + ", or " + + descriptions[descriptions.length - 1]; } } function describeFound(found) { - return found ? '"' + literalEscape(found) + '"' : 'end of input'; + return found ? "\"" + literalEscape(found) + "\"" : "end of input"; } - return ( - 'Expected ' + - describeExpected(expected) + - ' but ' + - describeFound(found) + - ' found.' - ); + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; }; function peg$parse(input, options) { @@ -209,54 +175,50 @@ function peg$parse(input, options) { var peg$startRuleFunctions = { start: peg$parsestart }; var peg$startRuleFunction = peg$parsestart; - var peg$c0 = 'matrix('; - var peg$c1 = ')'; - var peg$c2 = 'translate('; - var peg$c3 = 'scale('; - var peg$c4 = 'rotate('; - var peg$c5 = 'skewX('; - var peg$c6 = 'skewY('; - var peg$c7 = '.'; - var peg$c8 = 'e'; + var peg$c0 = "matrix("; + var peg$c1 = ")"; + var peg$c2 = "translate("; + var peg$c3 = "scale("; + var peg$c4 = "rotate("; + var peg$c5 = "skewX("; + var peg$c6 = "skewY("; + var peg$c7 = "."; + var peg$c8 = "e"; var peg$r0 = /^[ \t\n\r,]/; var peg$r1 = /^[ \t\n\r]/; var peg$r2 = /^[+\-]/; var peg$r3 = /^[0-9]/; - var peg$e0 = peg$otherExpectation('transform functions'); - var peg$e1 = peg$otherExpectation('transformFunctions'); - var peg$e2 = peg$otherExpectation('transform function'); - var peg$e3 = peg$otherExpectation('matrix'); - var peg$e4 = peg$literalExpectation('matrix(', false); - var peg$e5 = peg$literalExpectation(')', false); - var peg$e6 = peg$otherExpectation('translate'); - var peg$e7 = peg$literalExpectation('translate(', false); - var peg$e8 = peg$otherExpectation('scale'); - var peg$e9 = peg$literalExpectation('scale(', false); - var peg$e10 = peg$otherExpectation('rotate'); - var peg$e11 = peg$literalExpectation('rotate(', false); - var peg$e12 = peg$otherExpectation('x, y'); - var peg$e13 = peg$otherExpectation('skewX'); - var peg$e14 = peg$literalExpectation('skewX(', false); - var peg$e15 = peg$otherExpectation('skewY'); - var peg$e16 = peg$literalExpectation('skewY(', false); - var peg$e17 = peg$otherExpectation('space or comma'); - var peg$e18 = peg$classExpectation( - [' ', '\t', '\n', '\r', ','], - false, - false - ); - var peg$e19 = peg$otherExpectation('whitespace'); - var peg$e20 = peg$classExpectation([' ', '\t', '\n', '\r'], false, false); - var peg$e21 = peg$classExpectation(['+', '-'], false, false); - var peg$e22 = peg$classExpectation([['0', '9']], false, false); - var peg$e23 = peg$literalExpectation('.', false); - var peg$e24 = peg$literalExpectation('e', false); - - var peg$f0 = function (head, tail) { + var peg$e0 = peg$otherExpectation("transform functions"); + var peg$e1 = peg$otherExpectation("transformFunctions"); + var peg$e2 = peg$otherExpectation("transform function"); + var peg$e3 = peg$otherExpectation("matrix"); + var peg$e4 = peg$literalExpectation("matrix(", false); + var peg$e5 = peg$literalExpectation(")", false); + var peg$e6 = peg$otherExpectation("translate"); + var peg$e7 = peg$literalExpectation("translate(", false); + var peg$e8 = peg$otherExpectation("scale"); + var peg$e9 = peg$literalExpectation("scale(", false); + var peg$e10 = peg$otherExpectation("rotate"); + var peg$e11 = peg$literalExpectation("rotate(", false); + var peg$e12 = peg$otherExpectation("x, y"); + var peg$e13 = peg$otherExpectation("skewX"); + var peg$e14 = peg$literalExpectation("skewX(", false); + var peg$e15 = peg$otherExpectation("skewY"); + var peg$e16 = peg$literalExpectation("skewY(", false); + var peg$e17 = peg$otherExpectation("space or comma"); + var peg$e18 = peg$classExpectation([" ", "\t", "\n", "\r", ","], false, false); + var peg$e19 = peg$otherExpectation("whitespace"); + var peg$e20 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false); + var peg$e21 = peg$classExpectation(["+", "-"], false, false); + var peg$e22 = peg$classExpectation([["0", "9"]], false, false); + var peg$e23 = peg$literalExpectation(".", false); + var peg$e24 = peg$literalExpectation("e", false); + + var peg$f0 = function(head, tail) { const results = Array.isArray(head) ? head : [head]; - tail.forEach((element) => { + tail.forEach(element => { if (Array.isArray(element[1])) { results.push(...element[1]); } else { @@ -265,37 +227,46 @@ function peg$parse(input, options) { }); return results; }; - var peg$f1 = function (a, b, c, d, e, f, g, h, i) { - return { matrix: [a, b, c, d, e, f, g, h, i] }; + var peg$f1 = function(a, b, c, d, e, f, g, h, i) { + return { matrix: [a, b, c, d, e, f, g, h, i]}; }; - var peg$f2 = function (x, y) { + var peg$f2 = function(x, y) { if (y == undefined) { - return { translate: x }; + return { translate: x }; } return { translate: [x, y] }; }; - var peg$f3 = function (x, y) { + var peg$f3 = function(x, y) { if (y == undefined) { - return { scale: x }; + return { scale: x }; } - return [{ scaleX: x }, { scaleY: y }]; + return [ + { scaleX: x }, + { scaleY: y } + ]; }; - var peg$f4 = function (x, yz) { + var peg$f4 = function(x, yz) { if (yz !== null) { - return { rotate: `${x}deg` }; + return { rotate: `${x}deg` }; } - return [{ rotate: `${x}deg` }]; - }; - var peg$f5 = function (y, z) { - return [y, z]; + return [ + { rotate: `${x}deg` } + ]; }; - var peg$f6 = function (x) { - return [{ skewX: `${x}deg` }]; + var peg$f5 = function(y, z) { + return [y, z]; + }; + var peg$f6 = function(x) { + return [ + { skewX: `${x}deg` } + ]; }; - var peg$f7 = function (y) { - return [{ skewY: `${y}deg` }]; + var peg$f7 = function(y) { + return [ + { skewY: `${y}deg` } + ]; }; - var peg$f8 = function () { + var peg$f8 = function() { return parseFloat(text()); }; var peg$currPos = options.peg$currPos | 0; @@ -309,9 +280,7 @@ function peg$parse(input, options) { if (options.startRule) { if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error( - 'Can\'t start parsing from rule "' + options.startRule + '".' - ); + throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; @@ -329,7 +298,7 @@ function peg$parse(input, options) { return { source: peg$source, start: peg$savedPos, - end: peg$currPos, + end: peg$currPos }; } @@ -338,10 +307,9 @@ function peg$parse(input, options) { } function expected(description, location) { - location = - location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); + location = location !== undefined + ? location + : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError( [peg$otherExpectation(description)], @@ -351,37 +319,31 @@ function peg$parse(input, options) { } function error(message, location) { - location = - location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); + 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 }; + return { type: "literal", text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { - return { - type: 'class', - parts: parts, - inverted: inverted, - ignoreCase: ignoreCase, - }; + return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { - return { type: 'any' }; + return { type: "any" }; } function peg$endExpectation() { - return { type: 'end' }; + return { type: "end" }; } function peg$otherExpectation(description) { - return { type: 'other', description: description }; + return { type: "other", description: description }; } function peg$computePosDetails(pos) { @@ -401,7 +363,7 @@ function peg$parse(input, options) { details = peg$posDetailsCache[p]; details = { line: details.line, - column: details.column, + column: details.column }; while (p < pos) { @@ -430,15 +392,15 @@ function peg$parse(input, options) { start: { offset: startPos, line: startPosDetails.line, - column: startPosDetails.column, + column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, - column: endPosDetails.column, - }, + column: endPosDetails.column + } }; - if (offset && peg$source && typeof peg$source.offset === 'function') { + if (offset && peg$source && (typeof peg$source.offset === "function")) { res.start = peg$source.offset(res.start); res.end = peg$source.offset(res.end); } @@ -446,9 +408,7 @@ function peg$parse(input, options) { } function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { - return; - } + if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; @@ -479,9 +439,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e0); - } + if (peg$silentFails === 0) { peg$fail(peg$e0); } } return s0; @@ -527,9 +485,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e1); - } + if (peg$silentFails === 0) { peg$fail(peg$e1); } } return s0; @@ -558,39 +514,14 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e2); - } + if (peg$silentFails === 0) { peg$fail(peg$e2); } } return s0; } function peg$parsematrix() { - var s0, - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15, - s16, - s17, - s18, - s19, - s20, - s21, - s22, - s23; + var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21, s22, s23; peg$silentFails++; s0 = peg$currPos; @@ -600,9 +531,7 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e4); - } + if (peg$silentFails === 0) { peg$fail(peg$e4); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -638,9 +567,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s22 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e5); - } + if (peg$silentFails === 0) { peg$fail(peg$e5); } } if (s22 !== peg$FAILED) { s23 = peg$parse_(); @@ -693,9 +620,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e3); - } + if (peg$silentFails === 0) { peg$fail(peg$e3); } } return s0; @@ -712,9 +637,7 @@ function peg$parse(input, options) { peg$currPos += 10; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e7); - } + if (peg$silentFails === 0) { peg$fail(peg$e7); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -731,9 +654,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e5); - } + if (peg$silentFails === 0) { peg$fail(peg$e5); } } if (s8 !== peg$FAILED) { s9 = peg$parse_(); @@ -754,9 +675,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e6); - } + if (peg$silentFails === 0) { peg$fail(peg$e6); } } return s0; @@ -773,9 +692,7 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e9); - } + if (peg$silentFails === 0) { peg$fail(peg$e9); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -792,9 +709,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e5); - } + if (peg$silentFails === 0) { peg$fail(peg$e5); } } if (s8 !== peg$FAILED) { s9 = peg$parse_(); @@ -815,9 +730,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e8); - } + if (peg$silentFails === 0) { peg$fail(peg$e8); } } return s0; @@ -834,9 +747,7 @@ function peg$parse(input, options) { peg$currPos += 7; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e11); - } + if (peg$silentFails === 0) { peg$fail(peg$e11); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -852,9 +763,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e5); - } + if (peg$silentFails === 0) { peg$fail(peg$e5); } } if (s7 !== peg$FAILED) { s8 = peg$parse_(); @@ -875,9 +784,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e10); - } + if (peg$silentFails === 0) { peg$fail(peg$e10); } } return s0; @@ -907,9 +814,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e12); - } + if (peg$silentFails === 0) { peg$fail(peg$e12); } } return s0; @@ -926,9 +831,7 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } + if (peg$silentFails === 0) { peg$fail(peg$e14); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -940,9 +843,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e5); - } + if (peg$silentFails === 0) { peg$fail(peg$e5); } } if (s6 !== peg$FAILED) { s7 = peg$parse_(); @@ -963,9 +864,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e13); - } + if (peg$silentFails === 0) { peg$fail(peg$e13); } } return s0; @@ -982,9 +881,7 @@ function peg$parse(input, options) { peg$currPos += 6; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e16); - } + if (peg$silentFails === 0) { peg$fail(peg$e16); } } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -996,9 +893,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e5); - } + if (peg$silentFails === 0) { peg$fail(peg$e5); } } if (s6 !== peg$FAILED) { s7 = peg$parse_(); @@ -1019,9 +914,7 @@ function peg$parse(input, options) { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e15); - } + if (peg$silentFails === 0) { peg$fail(peg$e15); } } return s0; @@ -1037,9 +930,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e18); - } + if (peg$silentFails === 0) { peg$fail(peg$e18); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -1048,16 +939,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e18); - } + if (peg$silentFails === 0) { peg$fail(peg$e18); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e17); - } + if (peg$silentFails === 0) { peg$fail(peg$e17); } return s0; } @@ -1072,9 +959,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e20); - } + if (peg$silentFails === 0) { peg$fail(peg$e20); } } while (s1 !== peg$FAILED) { s0.push(s1); @@ -1083,16 +968,12 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e20); - } + if (peg$silentFails === 0) { peg$fail(peg$e20); } } } peg$silentFails--; s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e19); - } + if (peg$silentFails === 0) { peg$fail(peg$e19); } return s0; } @@ -1106,9 +987,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e21); - } + if (peg$silentFails === 0) { peg$fail(peg$e21); } } if (s1 === peg$FAILED) { s1 = null; @@ -1120,9 +999,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } + if (peg$silentFails === 0) { peg$fail(peg$e22); } } while (s4 !== peg$FAILED) { s3.push(s4); @@ -1131,9 +1008,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } + if (peg$silentFails === 0) { peg$fail(peg$e22); } } } if (input.charCodeAt(peg$currPos) === 46) { @@ -1141,9 +1016,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e23); - } + if (peg$silentFails === 0) { peg$fail(peg$e23); } } if (s4 !== peg$FAILED) { s5 = []; @@ -1152,9 +1025,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } + if (peg$silentFails === 0) { peg$fail(peg$e22); } } if (s6 !== peg$FAILED) { while (s6 !== peg$FAILED) { @@ -1164,9 +1035,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } + if (peg$silentFails === 0) { peg$fail(peg$e22); } } } } else { @@ -1190,9 +1059,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } + if (peg$silentFails === 0) { peg$fail(peg$e22); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { @@ -1202,9 +1069,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } + if (peg$silentFails === 0) { peg$fail(peg$e22); } } } } else { @@ -1218,9 +1083,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e24); - } + if (peg$silentFails === 0) { peg$fail(peg$e24); } } if (s4 !== peg$FAILED) { s5 = input.charAt(peg$currPos); @@ -1228,9 +1091,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e21); - } + if (peg$silentFails === 0) { peg$fail(peg$e21); } } if (s5 === peg$FAILED) { s5 = null; @@ -1241,9 +1102,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } + if (peg$silentFails === 0) { peg$fail(peg$e22); } } if (s7 !== peg$FAILED) { while (s7 !== peg$FAILED) { @@ -1253,9 +1112,7 @@ function peg$parse(input, options) { peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } + if (peg$silentFails === 0) { peg$fail(peg$e22); } } } } else { @@ -1293,7 +1150,7 @@ function peg$parse(input, options) { peg$currPos, peg$FAILED, peg$maxFailExpected, - peg$maxFailPos, + peg$maxFailPos }); } if (peg$result !== peg$FAILED && peg$currPos === input.length) { @@ -1313,8 +1170,12 @@ function peg$parse(input, options) { } } -module.exports = { - StartRules: ['start'], - SyntaxError: peg$SyntaxError, - parse: peg$parse, +const peg$allowedStartRules = [ + "start" +]; + +export { + peg$allowedStartRules as StartRules, + peg$SyntaxError as SyntaxError, + peg$parse as parse }; diff --git a/src/utils/fetchData.ts b/src/utils/fetchData.ts index d141be31c..fb2007f9b 100644 --- a/src/utils/fetchData.ts +++ b/src/utils/fetchData.ts @@ -1,5 +1,4 @@ import { Platform } from 'react-native'; -import { Buffer } from 'buffer'; export async function fetchText(uri?: string): Promise { if (!uri) { @@ -20,6 +19,7 @@ const decodeBase64Image = (uri: string) => { const dataType = splitContent[0] as BufferEncoding; const content = splitContent.slice(1).join(','); + if (typeof Buffer === "undefined") return window.atob(content) return Buffer.from(content, dataType).toString('utf-8'); }; diff --git a/yarn.lock b/yarn.lock index 148b49920..13ce059e4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9042,11 +9042,6 @@ peggy@4.0.3: commander "^12.1.0" source-map-generator "0.8.0" -pegjs@^0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/pegjs/-/pegjs-0.10.0.tgz#cf8bafae6eddff4b5a7efb185269eaaf4610ddbd" - integrity sha512-qI5+oFNEGi3L5HAxDwN2LA4Gg7irF70Zs25edhjld9QemOgp0CbvMtbFcMvFtEo1OityPrcCzkQFB8JP/hxgow== - pend@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50"