UNPKG

universal-siteswap

Version:

A library for parsing, validating, examining and finding transitions between all types of siteswaps

1,293 lines 64.5 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.parse = exports.SyntaxError = void 0; var common_1 = require("./common"); // Generated by peggy v. 2.0.1 (ts-pegjs plugin v. 2.1.0 ) // // https://peggyjs.org/ https://github.com/metadevpro/ts-pegjs "use strict"; 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); } var SyntaxError = /** @class */ (function (_super) { __extends(SyntaxError, _super); function SyntaxError(message, expected, found, location) { var _this = _super.call(this) || this; _this.message = message; _this.expected = expected; _this.found = found; _this.location = location; _this.name = "SyntaxError"; if (typeof Object.setPrototypeOf === "function") { Object.setPrototypeOf(_this, SyntaxError.prototype); } else { _this.__proto__ = SyntaxError.prototype; } if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(_this, SyntaxError); } return _this; } SyntaxError.buildMessage = function (expected, found) { 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) { switch (expectation.type) { case "literal": return "\"" + literalEscape(expectation.text) + "\""; case "class": var escapedParts = expectation.parts.map(function (part) { return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part); }); return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]"; case "any": return "any character"; case "end": return "end of input"; case "other": return expectation.description; } } function describeExpected(expected1) { var descriptions = expected1.map(describeExpectation); var i; var 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(found1) { return found1 ? "\"" + literalEscape(found1) + "\"" : "end of input"; } return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; }; SyntaxError.prototype.format = function (sources) { var str = 'Error: ' + this.message; if (this.location) { var src = null; var k = void 0; 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 loc = this.location.source + ':' + s.line + ':' + s.column; if (src) { var e = this.location.end; var filler = peg$padEnd('', s.line.toString().length, ' '); var line = src[s.line - 1]; var last = s.line === e.line ? e.column : line.length + 1; str += '\n --> ' + loc + '\n' + filler + ' |\n' + s.line + ' | ' + line + '\n' + filler + ' | ' + peg$padEnd('', s.column - 1, ' ') + peg$padEnd('', last - s.column, '^'); } else { str += '\n at ' + loc; } } return str; }; return SyntaxError; }(Error)); exports.SyntaxError = SyntaxError; function peg$parse(input, options) { options = options !== undefined ? options : {}; var peg$FAILED = {}; var peg$source = options.grammarSource; var peg$startRuleFunctions = { start: peg$parsestart }; var peg$startRuleFunction = peg$parsestart; var peg$c0 = function (solo) { return [[solo]]; }; var peg$c1 = "<"; var peg$c2 = peg$literalExpectation("<", false); var peg$c3 = "|"; var peg$c4 = peg$literalExpectation("|", false); var peg$c5 = ">"; var peg$c6 = peg$literalExpectation(">", false); var peg$c7 = function (delays, head, tail, count) { var jugglers = [head]; jugglers.push.apply(jugglers, tail.map(function (j) { return j[2]; })); if (count !== null) { var jCopy = jugglers.slice(); for (var i = 1; i < count; i++) { jugglers.push.apply(jugglers, jCopy); } } return [jugglers, delays]; }; var peg$c8 = "^"; var peg$c9 = peg$literalExpectation("^", false); var peg$c10 = /^[0-9]/; var peg$c11 = peg$classExpectation([["0", "9"]], false, false); var peg$c12 = function (count) { return parseInt(count.join('')); }; var peg$c13 = "{"; var peg$c14 = peg$literalExpectation("{", false); var peg$c15 = ","; var peg$c16 = peg$literalExpectation(",", false); var peg$c17 = "}"; var peg$c18 = peg$literalExpectation("}", false); var peg$c19 = function (head, tail) { var delays = [head]; delays.push.apply(delays, tail.map(function (d) { return d[2]; })); return delays; }; var peg$c20 = "."; var peg$c21 = peg$literalExpectation(".", false); var peg$c22 = function (val) { return parseFloat(val); }; var peg$c23 = "*"; var peg$c24 = peg$literalExpectation("*", false); var peg$c25 = function (beats, asterix) { var allBeats = []; for (var _i = 0, beats_1 = beats; _i < beats_1.length; _i++) { var beat = beats_1[_i]; if (beat[0] instanceof common_1.JugglerBeat) allBeats.push.apply(allBeats, beat); else if (beat[0] === 'repeat') allBeats.push.apply(allBeats, beat[1]); else allBeats.push(beat); } return new common_1.JugglerBeats(allBeats, asterix !== null); }; var peg$c26 = "("; var peg$c27 = peg$literalExpectation("(", false); var peg$c28 = ")"; var peg$c29 = peg$literalExpectation(")", false); var peg$c30 = function (beats, count) { var allBeats = []; var repeats = parseInt(count.join('')); for (var i = 0; i < repeats; i++) { allBeats.push.apply(allBeats, beats); } return ['repeat', allBeats]; }; var peg$c31 = /^[RL]/; var peg$c32 = peg$classExpectation(["R", "L"], false, false); var peg$c33 = function (hand, async) { if (hand === 'L') return new common_1.JugglerBeat(async, []); if (hand === 'R') return new common_1.JugglerBeat([], async); return async; }; var peg$c34 = "!"; var peg$c35 = peg$literalExpectation("!", false); var peg$c36 = function (left, right, skipEmpty) { var beats = [new common_1.JugglerBeat(left, right)]; if (!skipEmpty) beats.push(new common_1.JugglerBeat([], [])); return beats; }; var peg$c37 = "["; var peg$c38 = peg$literalExpectation("[", false); var peg$c39 = "]"; var peg$c40 = peg$literalExpectation("]", false); var peg$c41 = function (multiplex) { return multiplex.map(function (th) { return th[0]; }); }; var peg$c42 = function (height, modifiers) { var x = modifiers[0] !== null; var pass = modifiers[1] !== null; var passTo = modifiers[2]; return [new common_1.Throw(height, x, pass, passTo)]; }; var peg$c43 = "x"; var peg$c44 = peg$literalExpectation("x", false); var peg$c45 = function (x) { return [x, null, null]; }; var peg$c46 = "p"; var peg$c47 = peg$literalExpectation("p", false); var peg$c48 = /^[A-Z]/; var peg$c49 = peg$classExpectation([["A", "Z"]], false, false); var peg$c50 = function (pass, x, passTo) { return [x, pass, passTo ? (0, common_1.fromLetter)(passTo, 'A') : passTo]; }; var peg$c51 = /^[0-9a-z]/; var peg$c52 = peg$classExpectation([["0", "9"], ["a", "z"]], false, false); var peg$c53 = function (height) { return (0, common_1.ssToFloat)(height); }; var peg$c54 = " "; var peg$c55 = peg$literalExpectation(" ", false); var peg$currPos = 0; var peg$savedPos = 0; var peg$posDetailsCache = [{ line: 1, column: 1 }]; var peg$maxFailPos = 0; var peg$maxFailExpected = []; var peg$silentFails = 0; var peg$resultsCache = {}; var peg$result; if (options.startRule !== undefined) { 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 location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location1) { location1 = location1 !== undefined ? location1 : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildStructuredError([peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location1); } function error(message, location1) { location1 = location1 !== undefined ? location1 : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location1); } function peg$literalExpectation(text1, ignoreCase) { return { type: "literal", text: text1, 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 { p = pos - 1; while (!peg$posDetailsCache[p]) { 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) { var startPosDetails = peg$computePosDetails(startPos); var endPosDetails = peg$computePosDetails(endPos); return { source: peg$source, start: { offset: startPos, line: startPosDetails.line, column: startPosDetails.column }, end: { offset: endPos, line: endPosDetails.line, column: endPosDetails.column } }; } function peg$fail(expected1) { if (peg$currPos < peg$maxFailPos) { return; } if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; peg$maxFailExpected = []; } peg$maxFailExpected.push(expected1); } function peg$buildSimpleError(message, location1) { return new SyntaxError(message, [], "", location1); } function peg$buildStructuredError(expected1, found, location1) { return new SyntaxError(SyntaxError.buildMessage(expected1, found), expected1, found, location1); } function peg$parsestart() { var s0; var key = peg$currPos * 16 + 0; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$parsesiteswap(); peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parsesiteswap() { var s0, s1; var key = peg$currPos * 16 + 1; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$parsepassing(); if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsesolo(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c0(s1); } s0 = s1; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parsepassing() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; var key = peg$currPos * 16 + 2; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parsedelays(); if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parseWS(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 60) { s3 = peg$c1; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c2); } } if (s3 !== peg$FAILED) { s4 = peg$parseWS(); if (s4 !== peg$FAILED) { s5 = peg$parsesolo(); if (s5 !== peg$FAILED) { s6 = []; s7 = peg$currPos; if (input.charCodeAt(peg$currPos) === 124) { s8 = peg$c3; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s8 !== peg$FAILED) { s9 = peg$parseWS(); if (s9 !== peg$FAILED) { s10 = peg$parsesolo(); if (s10 !== peg$FAILED) { s8 = [s8, s9, s10]; s7 = s8; } else { peg$currPos = s7; s7 = peg$FAILED; } } else { peg$currPos = s7; s7 = peg$FAILED; } } else { peg$currPos = s7; s7 = peg$FAILED; } while (s7 !== peg$FAILED) { s6.push(s7); s7 = peg$currPos; if (input.charCodeAt(peg$currPos) === 124) { s8 = peg$c3; peg$currPos++; } else { s8 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s8 !== peg$FAILED) { s9 = peg$parseWS(); if (s9 !== peg$FAILED) { s10 = peg$parsesolo(); if (s10 !== peg$FAILED) { s8 = [s8, s9, s10]; s7 = s8; } else { peg$currPos = s7; s7 = peg$FAILED; } } else { peg$currPos = s7; s7 = peg$FAILED; } } else { peg$currPos = s7; s7 = peg$FAILED; } } if (s6 !== peg$FAILED) { s7 = peg$parseWS(); if (s7 !== peg$FAILED) { s8 = peg$parserepeat_count(); if (s8 === peg$FAILED) { s8 = null; } if (s8 !== peg$FAILED) { s9 = peg$parseWS(); if (s9 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 62) { s10 = peg$c5; peg$currPos++; } else { s10 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c6); } } if (s10 !== peg$FAILED) { s11 = peg$parseWS(); if (s11 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c7(s1, s5, s6, s8); 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; } } 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; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parserepeat_count() { var s0, s1, s2, s3, s4, s5, s6; var key = peg$currPos * 16 + 3; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseWS(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 124) { s2 = peg$c3; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c4); } } if (s2 !== peg$FAILED) { s3 = peg$parseWS(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 94) { s4 = peg$c8; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c9); } } if (s4 !== peg$FAILED) { s5 = []; if (peg$c10.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } if (s6 !== peg$FAILED) { while (s6 !== peg$FAILED) { s5.push(s6); if (peg$c10.test(input.charAt(peg$currPos))) { s6 = input.charAt(peg$currPos); peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } } } else { s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s6 = peg$parseWS(); if (s6 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c12(s5); 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; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parsedelays() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; var key = peg$currPos * 16 + 4; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { s1 = peg$c13; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c14); } } if (s1 !== peg$FAILED) { s2 = peg$parseWS(); if (s2 !== peg$FAILED) { s3 = peg$parsefloat(); if (s3 !== peg$FAILED) { s4 = peg$parseWS(); if (s4 !== peg$FAILED) { s5 = []; s6 = peg$currPos; if (input.charCodeAt(peg$currPos) === 44) { s7 = peg$c15; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c16); } } if (s7 !== peg$FAILED) { s8 = peg$parseWS(); if (s8 !== peg$FAILED) { s9 = peg$parsefloat(); if (s9 !== peg$FAILED) { s7 = [s7, s8, s9]; s6 = s7; } else { peg$currPos = s6; s6 = peg$FAILED; } } else { peg$currPos = s6; s6 = peg$FAILED; } } else { peg$currPos = s6; s6 = peg$FAILED; } while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$currPos; if (input.charCodeAt(peg$currPos) === 44) { s7 = peg$c15; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c16); } } if (s7 !== peg$FAILED) { s8 = peg$parseWS(); if (s8 !== peg$FAILED) { s9 = peg$parsefloat(); if (s9 !== peg$FAILED) { s7 = [s7, s8, s9]; s6 = s7; } else { peg$currPos = s6; s6 = peg$FAILED; } } else { peg$currPos = s6; s6 = peg$FAILED; } } else { peg$currPos = s6; s6 = peg$FAILED; } } if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s6 = peg$c17; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c18); } } if (s6 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c19(s3, s5); 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; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parsefloat() { var s0, s1, s2, s3, s4, s5, s6, s7; var key = peg$currPos * 16 + 5; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$currPos; s2 = peg$currPos; s3 = []; if (peg$c10.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); if (peg$c10.test(input.charAt(peg$currPos))) { s4 = input.charAt(peg$currPos); peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } } } else { s3 = peg$FAILED; } if (s3 !== peg$FAILED) { s4 = peg$currPos; if (input.charCodeAt(peg$currPos) === 46) { s5 = peg$c20; peg$currPos++; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s5 !== peg$FAILED) { s6 = []; if (peg$c10.test(input.charAt(peg$currPos))) { s7 = input.charAt(peg$currPos); peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } while (s7 !== peg$FAILED) { s6.push(s7); if (peg$c10.test(input.charAt(peg$currPos))) { s7 = input.charAt(peg$currPos); peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } } if (s6 !== peg$FAILED) { s5 = [s5, s6]; s4 = s5; } else { peg$currPos = s4; s4 = peg$FAILED; } } else { peg$currPos = s4; s4 = peg$FAILED; } if (s4 === peg$FAILED) { s4 = null; } if (s4 !== peg$FAILED) { s3 = [s3, s4]; s2 = s3; } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 !== peg$FAILED) { s1 = input.substring(s1, peg$currPos); } else { s1 = s2; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c22(s1); } s0 = s1; peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parsesolo() { var s0, s1, s2; var key = peg$currPos * 16 + 6; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = []; s2 = peg$parserepeat(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parserepeat(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 42) { s2 = peg$c23; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c24); } } if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c25(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parserepeat() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; var key = peg$currPos * 16 + 7; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$parsebeat(); if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseWS(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 40) { s2 = peg$c26; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s2 !== peg$FAILED) { s3 = peg$parseWS(); if (s3 !== peg$FAILED) { s4 = []; s5 = peg$parsebeat(); if (s5 !== peg$FAILED) { while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$parsebeat(); } } else { s4 = peg$FAILED; } if (s4 !== peg$FAILED) { s5 = peg$parseWS(); if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 94) { s6 = peg$c8; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c9); } } if (s6 !== peg$FAILED) { s7 = peg$parseWS(); if (s7 !== peg$FAILED) { s8 = []; if (peg$c10.test(input.charAt(peg$currPos))) { s9 = input.charAt(peg$currPos); peg$currPos++; } else { s9 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } if (s9 !== peg$FAILED) { while (s9 !== peg$FAILED) { s8.push(s9); if (peg$c10.test(input.charAt(peg$currPos))) { s9 = input.charAt(peg$currPos); peg$currPos++; } else { s9 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c11); } } } } else { s8 = peg$FAILED; } if (s8 !== peg$FAILED) { s9 = peg$parseWS(); if (s9 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s10 = peg$c28; peg$currPos++; } else { s10 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s10 !== peg$FAILED) { s11 = peg$parseWS(); if (s11 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c30(s4, s8); 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; } } 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; } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parsebeat() { var s0, s1, s2, s3; var key = peg$currPos * 16 + 8; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$parsesync(); if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseWS(); if (s1 !== peg$FAILED) { if (peg$c31.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c32); } } if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { s3 = peg$parseasync(); if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c33(s2, s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 }; return s0; } function peg$parsesync() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; var key = peg$currPos * 16 + 9; var cached = peg$resultsCache[key]; if (cached) { peg$currPos = cached.nextPos; return cached.result; } s0 = peg$currPos; s1 = peg$parseWS(); if (s1 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 40) { s2 = peg$c26; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s2 !== peg$FAILED) { s3 = peg$parseasync(); if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 44) { s4 = peg$c15; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c16); } } if (s4 !== peg$FAILED) { s5 = peg$parseasync(); if (s5 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s6 = peg$c28; peg$currPos++; } else { s6 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c29); } } if (s6 !== peg$FAILED) { s7 = peg$parseWS(); if (s7 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 33) { s8 = peg$c34; pe