mirror of
https://github.com/borbann-platform/end-of-semester-report.git
synced 2025-12-19 06:44:03 +01:00
16701 lines
491 KiB
JavaScript
16701 lines
491 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
const unifiedLatexUtilMatch = require("@unified-latex/unified-latex-util-match");
|
|
function decorateArrayForPegjs(array) {
|
|
array.charAt = function(i) {
|
|
return this[i];
|
|
};
|
|
array.charCodeAt = () => 0;
|
|
array.substring = function(i, j) {
|
|
return this.slice(i, j);
|
|
};
|
|
array.replace = function(a, b) {
|
|
const ret = JSON.stringify(this);
|
|
return ret.replace(a, b);
|
|
};
|
|
return array;
|
|
}
|
|
function splitStringsIntoSingleChars(nodes) {
|
|
return nodes.flatMap(
|
|
(node) => unifiedLatexUtilMatch.match.anyString(node) ? Array.from(node.content).map((c) => ({
|
|
type: "string",
|
|
content: c
|
|
})) : node
|
|
);
|
|
}
|
|
const _LatexPegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { document: peg$parsedocument, math: peg$parsemath };
|
|
var peg$startRuleFunction = peg$parsedocument;
|
|
var peg$c0 = "%";
|
|
var peg$c1 = ".";
|
|
var peg$c2 = "verb*";
|
|
var peg$c3 = "verb";
|
|
var peg$c4 = "[";
|
|
var peg$c5 = "]";
|
|
var peg$c6 = "lstinline";
|
|
var peg$c7 = "mintinline";
|
|
var peg$c8 = "mint";
|
|
var peg$c9 = "minted";
|
|
var peg$c10 = "verbatim*";
|
|
var peg$c11 = "verbatim";
|
|
var peg$c12 = "filecontents*";
|
|
var peg$c13 = "filecontents";
|
|
var peg$c14 = "comment";
|
|
var peg$c15 = "lstlisting";
|
|
var peg$c16 = "(";
|
|
var peg$c17 = ")";
|
|
var peg$c18 = "begin";
|
|
var peg$c19 = "end";
|
|
var peg$c20 = "equation*";
|
|
var peg$c21 = "equation";
|
|
var peg$c22 = "align*";
|
|
var peg$c23 = "align";
|
|
var peg$c24 = "alignat*";
|
|
var peg$c25 = "alignat";
|
|
var peg$c26 = "gather*";
|
|
var peg$c27 = "gather";
|
|
var peg$c28 = "multline*";
|
|
var peg$c29 = "multline";
|
|
var peg$c30 = "flalign*";
|
|
var peg$c31 = "flalign";
|
|
var peg$c32 = "split";
|
|
var peg$c33 = "math";
|
|
var peg$c34 = "displaymath";
|
|
var peg$c35 = "\\";
|
|
var peg$c36 = "{";
|
|
var peg$c37 = "}";
|
|
var peg$c38 = "$";
|
|
var peg$c39 = "&";
|
|
var peg$c40 = "\r";
|
|
var peg$c41 = "\n";
|
|
var peg$c42 = "\r\n";
|
|
var peg$c43 = "#";
|
|
var peg$c44 = "^";
|
|
var peg$c45 = "_";
|
|
var peg$c46 = "\0";
|
|
var peg$r0 = /^[^ \t\n\r]/;
|
|
var peg$r1 = /^[ \t]/;
|
|
var peg$r2 = /^[a-zA-Z]/;
|
|
var peg$r3 = /^[0-9]/;
|
|
var peg$r4 = /^[.,;:\-*\/()!?=+<>[\]`'"~]/;
|
|
var peg$e0 = peg$otherExpectation("document");
|
|
var peg$e1 = peg$otherExpectation("math");
|
|
var peg$e2 = peg$otherExpectation("token");
|
|
var peg$e3 = peg$anyExpectation();
|
|
var peg$e4 = peg$otherExpectation("parbreak");
|
|
var peg$e5 = peg$otherExpectation("math token");
|
|
var peg$e6 = peg$otherExpectation("nonchar token");
|
|
var peg$e7 = peg$literalExpectation("%", false);
|
|
var peg$e8 = peg$otherExpectation("whitespace");
|
|
var peg$e9 = peg$otherExpectation("number");
|
|
var peg$e10 = peg$literalExpectation(".", false);
|
|
var peg$e11 = peg$otherExpectation("special macro");
|
|
var peg$e12 = peg$literalExpectation("verb*", false);
|
|
var peg$e13 = peg$literalExpectation("verb", false);
|
|
var peg$e14 = peg$literalExpectation("[", false);
|
|
var peg$e15 = peg$literalExpectation("]", false);
|
|
var peg$e16 = peg$classExpectation([" ", " ", "\n", "\r"], true, false);
|
|
var peg$e17 = peg$otherExpectation("verbatim listings");
|
|
var peg$e18 = peg$literalExpectation("lstinline", false);
|
|
var peg$e19 = peg$otherExpectation("verbatim minted");
|
|
var peg$e20 = peg$literalExpectation("mintinline", false);
|
|
var peg$e21 = peg$literalExpectation("mint", false);
|
|
var peg$e22 = peg$otherExpectation("verbatim minted environment");
|
|
var peg$e23 = peg$literalExpectation("minted", false);
|
|
var peg$e24 = peg$otherExpectation("verbatim environment");
|
|
var peg$e25 = peg$literalExpectation("verbatim*", false);
|
|
var peg$e26 = peg$literalExpectation("verbatim", false);
|
|
var peg$e27 = peg$literalExpectation("filecontents*", false);
|
|
var peg$e28 = peg$literalExpectation("filecontents", false);
|
|
var peg$e29 = peg$literalExpectation("comment", false);
|
|
var peg$e30 = peg$literalExpectation("lstlisting", false);
|
|
var peg$e31 = peg$otherExpectation("macro");
|
|
var peg$e32 = peg$otherExpectation("group");
|
|
var peg$e33 = peg$otherExpectation("environment");
|
|
var peg$e34 = peg$otherExpectation("math environment");
|
|
var peg$e36 = peg$literalExpectation("(", false);
|
|
var peg$e37 = peg$literalExpectation(")", false);
|
|
var peg$e38 = peg$literalExpectation("begin", false);
|
|
var peg$e39 = peg$literalExpectation("end", false);
|
|
var peg$e40 = peg$literalExpectation("equation*", false);
|
|
var peg$e41 = peg$literalExpectation("equation", false);
|
|
var peg$e42 = peg$literalExpectation("align*", false);
|
|
var peg$e43 = peg$literalExpectation("align", false);
|
|
var peg$e44 = peg$literalExpectation("alignat*", false);
|
|
var peg$e45 = peg$literalExpectation("alignat", false);
|
|
var peg$e46 = peg$literalExpectation("gather*", false);
|
|
var peg$e47 = peg$literalExpectation("gather", false);
|
|
var peg$e48 = peg$literalExpectation("multline*", false);
|
|
var peg$e49 = peg$literalExpectation("multline", false);
|
|
var peg$e50 = peg$literalExpectation("flalign*", false);
|
|
var peg$e51 = peg$literalExpectation("flalign", false);
|
|
var peg$e52 = peg$literalExpectation("split", false);
|
|
var peg$e53 = peg$literalExpectation("math", false);
|
|
var peg$e54 = peg$literalExpectation("displaymath", false);
|
|
var peg$e55 = peg$otherExpectation("escape");
|
|
var peg$e56 = peg$literalExpectation("\\", false);
|
|
var peg$e57 = peg$literalExpectation("{", false);
|
|
var peg$e58 = peg$literalExpectation("}", false);
|
|
var peg$e59 = peg$literalExpectation("$", false);
|
|
var peg$e60 = peg$literalExpectation("&", false);
|
|
var peg$e61 = peg$otherExpectation("newline");
|
|
var peg$e62 = peg$literalExpectation("\r", false);
|
|
var peg$e63 = peg$literalExpectation("\n", false);
|
|
var peg$e64 = peg$literalExpectation("\r\n", false);
|
|
var peg$e65 = peg$literalExpectation("#", false);
|
|
var peg$e66 = peg$literalExpectation("^", false);
|
|
var peg$e67 = peg$literalExpectation("_", false);
|
|
var peg$e68 = peg$literalExpectation("\0", false);
|
|
var peg$e69 = peg$classExpectation([" ", " "], false, false);
|
|
var peg$e70 = peg$otherExpectation("letter");
|
|
var peg$e71 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false);
|
|
var peg$e72 = peg$otherExpectation("digit");
|
|
var peg$e73 = peg$classExpectation([["0", "9"]], false, false);
|
|
var peg$e74 = peg$otherExpectation("punctuation");
|
|
var peg$e75 = peg$classExpectation([".", ",", ";", ":", "-", "*", "/", "(", ")", "!", "?", "=", "+", "<", ">", "[", "]", "`", "'", '"', "~"], false, false);
|
|
var peg$e76 = peg$otherExpectation("full comment");
|
|
var peg$e77 = peg$otherExpectation("comment");
|
|
var peg$f0 = function(content) {
|
|
return createNode("root", { content: content.flatMap((x) => x) });
|
|
};
|
|
var peg$f1 = function(t) {
|
|
return t;
|
|
};
|
|
var peg$f2 = function(eq) {
|
|
return createNode("inlinemath", { content: eq.flatMap((x) => x) });
|
|
};
|
|
var peg$f3 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f4 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f5 = function() {
|
|
return createNode("parbreak");
|
|
};
|
|
var peg$f6 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f7 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f8 = function() {
|
|
return createNode("macro", { content: "^", escapeToken: "" });
|
|
};
|
|
var peg$f9 = function() {
|
|
return createNode("macro", { content: "_", escapeToken: "" });
|
|
};
|
|
var peg$f10 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f11 = function() {
|
|
return createNode("whitespace");
|
|
};
|
|
var peg$f12 = function(a, b) {
|
|
return a.join("") + "." + b.join("");
|
|
};
|
|
var peg$f13 = function(b) {
|
|
return "." + b.join("");
|
|
};
|
|
var peg$f14 = function(a) {
|
|
return a.join("") + ".";
|
|
};
|
|
var peg$f15 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f16 = function(env, e, end) {
|
|
return end == e;
|
|
};
|
|
var peg$f17 = function(env, e, x) {
|
|
return x;
|
|
};
|
|
var peg$f18 = function(env, e, x, end) {
|
|
return end == e;
|
|
};
|
|
var peg$f19 = function(env, e, x) {
|
|
return createNode("verb", {
|
|
env,
|
|
escape: e,
|
|
content: x.join("")
|
|
});
|
|
};
|
|
var peg$f20 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f21 = function(x) {
|
|
return createNode("displaymath", { content: x.flatMap((x2) => x2) });
|
|
};
|
|
var peg$f22 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f23 = function(x) {
|
|
return createNode("inlinemath", { content: x.flatMap((x2) => x2) });
|
|
};
|
|
var peg$f24 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f25 = function(x) {
|
|
return createNode("displaymath", { content: x.flatMap((x2) => x2) });
|
|
};
|
|
var peg$f26 = function(end) {
|
|
return end.type === "string" && end.content === "]";
|
|
};
|
|
var peg$f27 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f28 = function(o) {
|
|
return [
|
|
createNode("string", { content: "[" }),
|
|
...o,
|
|
createNode("string", { content: "]" })
|
|
];
|
|
};
|
|
var peg$f29 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f30 = function(v) {
|
|
return createNode("group", {
|
|
content: createNode("string", { content: v.join("") })
|
|
});
|
|
};
|
|
var peg$f31 = function(d, end) {
|
|
return end == d;
|
|
};
|
|
var peg$f32 = function(d, x) {
|
|
return x;
|
|
};
|
|
var peg$f33 = function(d, v, end) {
|
|
return end == d;
|
|
};
|
|
var peg$f34 = function(d, v) {
|
|
return [
|
|
createNode("string", { content: d }),
|
|
createNode("string", { content: v.join("") }),
|
|
createNode("string", { content: d })
|
|
];
|
|
};
|
|
var peg$f35 = function(macro, option, verbatim) {
|
|
return [
|
|
createNode("macro", { content: macro }),
|
|
...option || [],
|
|
...[].concat(verbatim)
|
|
];
|
|
};
|
|
var peg$f36 = function(macro, option, language, verbatim) {
|
|
return [
|
|
createNode("macro", { content: macro }),
|
|
...option || [],
|
|
language,
|
|
...[].concat(verbatim)
|
|
];
|
|
};
|
|
var peg$f37 = function(env, option, language, end_env) {
|
|
return compare_env({ content: [env] }, end_env);
|
|
};
|
|
var peg$f38 = function(env, option, language, body) {
|
|
const content = [
|
|
...option || [],
|
|
language,
|
|
{ type: "string", content: body }
|
|
];
|
|
return createNode("environment", {
|
|
env,
|
|
content
|
|
});
|
|
};
|
|
var peg$f39 = function(env, end_env) {
|
|
return compare_env({ content: [env] }, end_env);
|
|
};
|
|
var peg$f40 = function(env, x) {
|
|
return x;
|
|
};
|
|
var peg$f41 = function(env, body) {
|
|
return createNode("verbatim", {
|
|
env,
|
|
content: body
|
|
});
|
|
};
|
|
var peg$f42 = function(n) {
|
|
return n.join("");
|
|
};
|
|
var peg$f43 = function(n) {
|
|
return n;
|
|
};
|
|
var peg$f44 = function(m) {
|
|
return createNode("macro", { content: m });
|
|
};
|
|
var peg$f45 = function(c) {
|
|
return c;
|
|
};
|
|
var peg$f46 = function(x) {
|
|
return createNode("group", { content: x.flatMap((x2) => x2) });
|
|
};
|
|
var peg$f47 = function(g) {
|
|
return text().slice(1, -1);
|
|
};
|
|
var peg$f48 = function(env, env_comment, end_env) {
|
|
return compare_env(env, end_env);
|
|
};
|
|
var peg$f49 = function(env, env_comment, x) {
|
|
return x;
|
|
};
|
|
var peg$f50 = function(env, env_comment, body) {
|
|
body = body.flatMap((x) => x);
|
|
return createNode("environment", {
|
|
env,
|
|
content: env_comment ? [env_comment, ...body] : body
|
|
});
|
|
};
|
|
var peg$f51 = function(env, env_comment, end_env) {
|
|
return compare_env({ content: [env] }, end_env);
|
|
};
|
|
var peg$f52 = function(env, env_comment, x) {
|
|
return x;
|
|
};
|
|
var peg$f53 = function(env, env_comment, body) {
|
|
body = body.flatMap((x) => x);
|
|
return createNode("mathenv", {
|
|
env,
|
|
content: env_comment ? [env_comment, ...body] : body
|
|
});
|
|
};
|
|
var peg$f56 = function(e) {
|
|
return createNode("string", { content: e });
|
|
};
|
|
var peg$f57 = function() {
|
|
return createNode("string", { content: "\\" });
|
|
};
|
|
var peg$f58 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f59 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f60 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f61 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f62 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f63 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f64 = function(s) {
|
|
return createNode("string", { content: s });
|
|
};
|
|
var peg$f65 = function() {
|
|
return " ";
|
|
};
|
|
var peg$f66 = function(p) {
|
|
return createNode("string", { content: p });
|
|
};
|
|
var peg$f67 = function(leading_sp, comment) {
|
|
return createNode("comment", {
|
|
...comment,
|
|
sameline: false,
|
|
leadingWhitespace: leading_sp.length > 0
|
|
});
|
|
};
|
|
var peg$f68 = function(spaces, x) {
|
|
return createNode("comment", {
|
|
...x,
|
|
sameline: true,
|
|
leadingWhitespace: spaces.length > 0
|
|
});
|
|
};
|
|
var peg$f69 = function(c) {
|
|
return c;
|
|
};
|
|
var peg$f70 = function(c) {
|
|
return { content: c.join(""), suffixParbreak: true };
|
|
};
|
|
var peg$f71 = function(c) {
|
|
return c;
|
|
};
|
|
var peg$f72 = function(c) {
|
|
return { content: c.join("") };
|
|
};
|
|
var peg$f73 = function() {
|
|
var loc = location();
|
|
return loc.start.column === 1;
|
|
};
|
|
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 ("startRule" in options) {
|
|
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 peg$literalExpectation(text2, ignoreCase) {
|
|
return { type: "literal", text: text2, ignoreCase };
|
|
}
|
|
function peg$classExpectation(parts, inverted, ignoreCase) {
|
|
return { type: "class", parts, inverted, ignoreCase };
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
function peg$otherExpectation(description) {
|
|
return { type: "other", 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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parsedocument() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 0;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsetoken();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsetoken();
|
|
}
|
|
peg$savedPos = s0;
|
|
s1 = peg$f0(s1);
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsemath() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 1;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = [];
|
|
s1 = peg$parsemath_token();
|
|
while (s1 !== peg$FAILED) {
|
|
s0.push(s1);
|
|
s1 = peg$parsemath_token();
|
|
}
|
|
peg$silentFails--;
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e1);
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsetoken() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
var key = peg$currPos * 52 + 2;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$parsespecial_macro();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsemacro();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsefull_comment();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsegroup();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsemath_shift();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsemath_shift();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemath_token();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f1(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsemath_shift();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemath_token();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f1(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsemath_shift();
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f2(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsealignment_tab();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseparbreak();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsemacro_parameter();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseignore();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsenumber();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsewhitespace();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsepunctuation();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsenonchar_token();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s4 = [s4, s5];
|
|
s3 = s4;
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsenonchar_token();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s4 = [s4, s5];
|
|
s3 = s4;
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
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$f3(s1);
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsebegin_group();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseend_group();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsemath_shift();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f4(s1);
|
|
}
|
|
s0 = s1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseparbreak() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
var key = peg$currPos * 52 + 3;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = [];
|
|
s3 = peg$parsesp();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsesp();
|
|
}
|
|
s3 = peg$parsenl();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$currPos;
|
|
s6 = [];
|
|
s7 = peg$parsesp();
|
|
while (s7 !== peg$FAILED) {
|
|
s6.push(s7);
|
|
s7 = peg$parsesp();
|
|
}
|
|
s7 = peg$parsenl();
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$currPos;
|
|
s6 = [];
|
|
s7 = peg$parsesp();
|
|
while (s7 !== peg$FAILED) {
|
|
s6.push(s7);
|
|
s7 = peg$parsesp();
|
|
}
|
|
s7 = peg$parsenl();
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = [];
|
|
s6 = peg$parsesp();
|
|
while (s6 !== peg$FAILED) {
|
|
s5.push(s6);
|
|
s6 = peg$parsesp();
|
|
}
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$parsecomment_start();
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s2 = [s2, s3, s4, s5, s6];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$currPos;
|
|
s2 = [];
|
|
s3 = peg$parsesp();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsesp();
|
|
}
|
|
s3 = peg$parsenl();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$currPos;
|
|
s6 = [];
|
|
s7 = peg$parsesp();
|
|
while (s7 !== peg$FAILED) {
|
|
s6.push(s7);
|
|
s7 = peg$parsesp();
|
|
}
|
|
s7 = peg$parsenl();
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$currPos;
|
|
s6 = [];
|
|
s7 = peg$parsesp();
|
|
while (s7 !== peg$FAILED) {
|
|
s6.push(s7);
|
|
s7 = peg$parsesp();
|
|
}
|
|
s7 = peg$parsenl();
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s2 = [s2, s3, s4];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f5();
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e4);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsemath_token() {
|
|
var s0, s1, s2, s3, s4;
|
|
var key = peg$currPos * 52 + 4;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$parsespecial_macro();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsemacro();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsefull_comment();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
}
|
|
s2 = peg$parsegroup();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parsewhitespace();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsewhitespace();
|
|
}
|
|
peg$savedPos = s0;
|
|
s0 = peg$f6(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
}
|
|
s2 = peg$parsealignment_tab();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parsewhitespace();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsewhitespace();
|
|
}
|
|
peg$savedPos = s0;
|
|
s0 = peg$f7(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsemacro_parameter();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
}
|
|
s2 = peg$parsesuperscript();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parsewhitespace();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsewhitespace();
|
|
}
|
|
peg$savedPos = s0;
|
|
s0 = peg$f8();
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
}
|
|
s2 = peg$parsesubscript();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parsewhitespace();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsewhitespace();
|
|
}
|
|
peg$savedPos = s0;
|
|
s0 = peg$f9();
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseignore();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsewhitespace();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f10(s1);
|
|
}
|
|
s0 = s1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsenonchar_token() {
|
|
var s0;
|
|
var key = peg$currPos * 52 + 5;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$parseescape();
|
|
if (s0 === peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 37) {
|
|
s0 = peg$c0;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e7);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsebegin_group();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseend_group();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsemath_shift();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsealignment_tab();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsenl();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsemacro_parameter();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseignore();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsesp();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsepunctuation();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseEOF();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e6);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsewhitespace() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
var key = peg$currPos * 52 + 6;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$parsenl();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parsesp();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsesp();
|
|
}
|
|
s2 = [s2, s3];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$currPos;
|
|
s2 = [];
|
|
s3 = peg$parsesp();
|
|
if (s3 !== peg$FAILED) {
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsesp();
|
|
}
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsenl();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsecomment_start();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = [];
|
|
s6 = peg$parsesp();
|
|
while (s6 !== peg$FAILED) {
|
|
s5.push(s6);
|
|
s6 = peg$parsesp();
|
|
}
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$parsenl();
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s2 = [s2, s3, s4, s5, s6];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
s1 = [];
|
|
s2 = peg$parsesp();
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsesp();
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f11();
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e8);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsenumber() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
var key = peg$currPos * 52 + 7;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = [];
|
|
s3 = peg$parsenum();
|
|
if (s3 !== peg$FAILED) {
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsenum();
|
|
}
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 46) {
|
|
s3 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e10);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$parsenum();
|
|
if (s5 !== peg$FAILED) {
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$parsenum();
|
|
}
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
peg$savedPos = s1;
|
|
s1 = peg$f12(s2, s4);
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 46) {
|
|
s2 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e10);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parsenum();
|
|
if (s4 !== peg$FAILED) {
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsenum();
|
|
}
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s1;
|
|
s1 = peg$f13(s3);
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$currPos;
|
|
s2 = [];
|
|
s3 = peg$parsenum();
|
|
if (s3 !== peg$FAILED) {
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsenum();
|
|
}
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 46) {
|
|
s3 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e10);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s1;
|
|
s1 = peg$f14(s2);
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f15(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e9);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsespecial_macro() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
|
var key = peg$currPos * 52 + 8;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseescape();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.substr(peg$currPos, 5) === peg$c2) {
|
|
s2 = peg$c2;
|
|
peg$currPos += 5;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e12);
|
|
}
|
|
}
|
|
if (s2 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 4) === peg$c3) {
|
|
s2 = peg$c3;
|
|
peg$currPos += 4;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e13);
|
|
}
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$currPos;
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s8 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s8 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s8 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s9 = peg$f16(s2, s3, s8);
|
|
if (s9) {
|
|
s9 = void 0;
|
|
} else {
|
|
s9 = peg$FAILED;
|
|
}
|
|
if (s9 !== peg$FAILED) {
|
|
s8 = [s8, s9];
|
|
s7 = s8;
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s7 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
peg$savedPos = s5;
|
|
s5 = peg$f17(s2, s3, s7);
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$currPos;
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s8 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s8 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s8 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s9 = peg$f16(s2, s3, s8);
|
|
if (s9) {
|
|
s9 = void 0;
|
|
} else {
|
|
s9 = peg$FAILED;
|
|
}
|
|
if (s9 !== peg$FAILED) {
|
|
s8 = [s8, s9];
|
|
s7 = s8;
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s7 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
peg$savedPos = s5;
|
|
s5 = peg$f17(s2, s3, s7);
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
}
|
|
s5 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s7 = peg$f18(s2, s3, s4, s6);
|
|
if (s7) {
|
|
s7 = void 0;
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f19(s2, s3, s4);
|
|
} 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;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseverbatim_listings();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseverbatim_minted();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseverbatim_minted_environment();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseverbatim_environment();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebegin_display_math();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parseend_display_math();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemath_token();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f20(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parseend_display_math();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemath_token();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f20(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s3 = peg$parseend_display_math();
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f21(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebegin_inline_math();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parseend_inline_math();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemath_token();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f22(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parseend_inline_math();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemath_token();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f22(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s3 = peg$parseend_inline_math();
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f23(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsemath_shift();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsemath_shift();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$currPos;
|
|
s5 = peg$currPos;
|
|
peg$silentFails++;
|
|
s6 = peg$currPos;
|
|
s7 = peg$parsemath_shift();
|
|
if (s7 !== peg$FAILED) {
|
|
s8 = peg$parsemath_shift();
|
|
if (s8 !== peg$FAILED) {
|
|
s7 = [s7, s8];
|
|
s6 = s7;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s6 === peg$FAILED) {
|
|
s5 = void 0;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parsemath_token();
|
|
if (s6 !== peg$FAILED) {
|
|
peg$savedPos = s4;
|
|
s4 = peg$f24(s6);
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$currPos;
|
|
s5 = peg$currPos;
|
|
peg$silentFails++;
|
|
s6 = peg$currPos;
|
|
s7 = peg$parsemath_shift();
|
|
if (s7 !== peg$FAILED) {
|
|
s8 = peg$parsemath_shift();
|
|
if (s8 !== peg$FAILED) {
|
|
s7 = [s7, s8];
|
|
s6 = s7;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s6 === peg$FAILED) {
|
|
s5 = void 0;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parsemath_token();
|
|
if (s6 !== peg$FAILED) {
|
|
peg$savedPos = s4;
|
|
s4 = peg$f24(s6);
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
}
|
|
s4 = peg$parsemath_shift();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemath_shift();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f25(s3);
|
|
} 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;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsemath_environment();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseenvironment();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e11);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsesquare_bracket_argument() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
var key = peg$currPos * 52 + 9;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 91) {
|
|
s1 = peg$c4;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e14);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$currPos;
|
|
s6 = peg$parsetoken();
|
|
if (s6 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s7 = peg$f26(s6);
|
|
if (s7) {
|
|
s7 = void 0;
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsetoken();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f27(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$currPos;
|
|
s6 = peg$parsetoken();
|
|
if (s6 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s7 = peg$f26(s6);
|
|
if (s7) {
|
|
s7 = void 0;
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsetoken();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f27(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
if (input.charCodeAt(peg$currPos) === 93) {
|
|
s3 = peg$c5;
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e15);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f28(s2);
|
|
} 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$parseverbatim_group() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
var key = peg$currPos * 52 + 10;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebegin_group();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parseend_group();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f29(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parseend_group();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f29(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s3 = peg$parseend_group();
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f30(s2);
|
|
} 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$parseverbatim_delimited_by_char() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
var key = peg$currPos * 52 + 11;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e16);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s7 = peg$f31(s1, s6);
|
|
if (s7) {
|
|
s7 = void 0;
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f32(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s7 = peg$f31(s1, s6);
|
|
if (s7) {
|
|
s7 = void 0;
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f32(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s3 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s4 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s5 = peg$f33(s1, s2, s4);
|
|
if (s5) {
|
|
s5 = void 0;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s4 = [s4, s5];
|
|
s3 = s4;
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f34(s1, s2);
|
|
} 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$parseverbatim_listings() {
|
|
var s0, s1, s2, s3, s4;
|
|
var key = peg$currPos * 52 + 12;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseescape();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.substr(peg$currPos, 9) === peg$c6) {
|
|
s2 = peg$c6;
|
|
peg$currPos += 9;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e18);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsesquare_bracket_argument();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s4 = peg$parseverbatim_group();
|
|
if (s4 === peg$FAILED) {
|
|
s4 = peg$parseverbatim_delimited_by_char();
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f35(s2, s3, s4);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e17);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseverbatim_minted() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
var key = peg$currPos * 52 + 13;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseescape();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.substr(peg$currPos, 10) === peg$c7) {
|
|
s2 = peg$c7;
|
|
peg$currPos += 10;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
if (s2 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 4) === peg$c8) {
|
|
s2 = peg$c8;
|
|
peg$currPos += 4;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e21);
|
|
}
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsesquare_bracket_argument();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s4 = peg$parsegroup();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parseverbatim_group();
|
|
if (s5 === peg$FAILED) {
|
|
s5 = peg$parseverbatim_delimited_by_char();
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f36(s2, s3, s4, s5);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e19);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseverbatim_minted_environment() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14;
|
|
var key = peg$currPos * 52 + 14;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebegin_env();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsebegin_group();
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.substr(peg$currPos, 6) === peg$c9) {
|
|
s3 = peg$c9;
|
|
peg$currPos += 6;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e23);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parseend_group();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsesquare_bracket_argument();
|
|
if (s5 === peg$FAILED) {
|
|
s5 = null;
|
|
}
|
|
s6 = peg$parsegroup();
|
|
if (s6 !== peg$FAILED) {
|
|
s7 = peg$currPos;
|
|
s8 = [];
|
|
s9 = peg$currPos;
|
|
s10 = peg$currPos;
|
|
peg$silentFails++;
|
|
s11 = peg$currPos;
|
|
s12 = peg$parseend_env();
|
|
if (s12 !== peg$FAILED) {
|
|
s13 = peg$parsegroup();
|
|
if (s13 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s14 = peg$f37(s3, s5, s6, s13);
|
|
if (s14) {
|
|
s14 = void 0;
|
|
} else {
|
|
s14 = peg$FAILED;
|
|
}
|
|
if (s14 !== peg$FAILED) {
|
|
s12 = [s12, s13, s14];
|
|
s11 = s12;
|
|
} else {
|
|
peg$currPos = s11;
|
|
s11 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s11;
|
|
s11 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s11;
|
|
s11 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s11 === peg$FAILED) {
|
|
s10 = void 0;
|
|
} else {
|
|
peg$currPos = s10;
|
|
s10 = peg$FAILED;
|
|
}
|
|
if (s10 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s11 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s11 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s11 !== peg$FAILED) {
|
|
s10 = [s10, s11];
|
|
s9 = s10;
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
while (s9 !== peg$FAILED) {
|
|
s8.push(s9);
|
|
s9 = peg$currPos;
|
|
s10 = peg$currPos;
|
|
peg$silentFails++;
|
|
s11 = peg$currPos;
|
|
s12 = peg$parseend_env();
|
|
if (s12 !== peg$FAILED) {
|
|
s13 = peg$parsegroup();
|
|
if (s13 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s14 = peg$f37(s3, s5, s6, s13);
|
|
if (s14) {
|
|
s14 = void 0;
|
|
} else {
|
|
s14 = peg$FAILED;
|
|
}
|
|
if (s14 !== peg$FAILED) {
|
|
s12 = [s12, s13, s14];
|
|
s11 = s12;
|
|
} else {
|
|
peg$currPos = s11;
|
|
s11 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s11;
|
|
s11 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s11;
|
|
s11 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s11 === peg$FAILED) {
|
|
s10 = void 0;
|
|
} else {
|
|
peg$currPos = s10;
|
|
s10 = peg$FAILED;
|
|
}
|
|
if (s10 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s11 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s11 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s11 !== peg$FAILED) {
|
|
s10 = [s10, s11];
|
|
s9 = s10;
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
}
|
|
s7 = input.substring(s7, peg$currPos);
|
|
s8 = peg$parseend_env();
|
|
if (s8 !== peg$FAILED) {
|
|
s9 = peg$parsebegin_group();
|
|
if (s9 !== peg$FAILED) {
|
|
if (input.substr(peg$currPos, 6) === peg$c9) {
|
|
s10 = peg$c9;
|
|
peg$currPos += 6;
|
|
} else {
|
|
s10 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e23);
|
|
}
|
|
}
|
|
if (s10 !== peg$FAILED) {
|
|
s11 = peg$parseend_group();
|
|
if (s11 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f38(s3, s5, s6, s7);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e22);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseverbatim_environment() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
|
|
var key = peg$currPos * 52 + 15;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebegin_env();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsebegin_group();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parseverbatim_env_name();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parseend_group();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$currPos;
|
|
s6 = [];
|
|
s7 = peg$currPos;
|
|
s8 = peg$currPos;
|
|
peg$silentFails++;
|
|
s9 = peg$currPos;
|
|
s10 = peg$parseend_env();
|
|
if (s10 !== peg$FAILED) {
|
|
s11 = peg$parsegroup();
|
|
if (s11 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s12 = peg$f39(s3, s11);
|
|
if (s12) {
|
|
s12 = void 0;
|
|
} else {
|
|
s12 = peg$FAILED;
|
|
}
|
|
if (s12 !== peg$FAILED) {
|
|
s10 = [s10, s11, s12];
|
|
s9 = s10;
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s9 === peg$FAILED) {
|
|
s8 = void 0;
|
|
} else {
|
|
peg$currPos = s8;
|
|
s8 = peg$FAILED;
|
|
}
|
|
if (s8 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s9 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s9 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s9 !== peg$FAILED) {
|
|
peg$savedPos = s7;
|
|
s7 = peg$f40(s3, s9);
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
while (s7 !== peg$FAILED) {
|
|
s6.push(s7);
|
|
s7 = peg$currPos;
|
|
s8 = peg$currPos;
|
|
peg$silentFails++;
|
|
s9 = peg$currPos;
|
|
s10 = peg$parseend_env();
|
|
if (s10 !== peg$FAILED) {
|
|
s11 = peg$parsegroup();
|
|
if (s11 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s12 = peg$f39(s3, s11);
|
|
if (s12) {
|
|
s12 = void 0;
|
|
} else {
|
|
s12 = peg$FAILED;
|
|
}
|
|
if (s12 !== peg$FAILED) {
|
|
s10 = [s10, s11, s12];
|
|
s9 = s10;
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s9 === peg$FAILED) {
|
|
s8 = void 0;
|
|
} else {
|
|
peg$currPos = s8;
|
|
s8 = peg$FAILED;
|
|
}
|
|
if (s8 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s9 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s9 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s9 !== peg$FAILED) {
|
|
peg$savedPos = s7;
|
|
s7 = peg$f40(s3, s9);
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
}
|
|
s5 = input.substring(s5, peg$currPos);
|
|
s6 = peg$parseend_env();
|
|
if (s6 !== peg$FAILED) {
|
|
s7 = peg$parsebegin_group();
|
|
if (s7 !== peg$FAILED) {
|
|
s8 = peg$parseverbatim_env_name();
|
|
if (s8 !== peg$FAILED) {
|
|
s9 = peg$parseend_group();
|
|
if (s9 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f41(s3, s5);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} 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$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e24);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseverbatim_env_name() {
|
|
var s0;
|
|
var key = peg$currPos * 52 + 16;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
if (input.substr(peg$currPos, 9) === peg$c10) {
|
|
s0 = peg$c10;
|
|
peg$currPos += 9;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e25);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 8) === peg$c11) {
|
|
s0 = peg$c11;
|
|
peg$currPos += 8;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e26);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 13) === peg$c12) {
|
|
s0 = peg$c12;
|
|
peg$currPos += 13;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e27);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 12) === peg$c13) {
|
|
s0 = peg$c13;
|
|
peg$currPos += 12;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e28);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 7) === peg$c14) {
|
|
s0 = peg$c14;
|
|
peg$currPos += 7;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e29);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 10) === peg$c15) {
|
|
s0 = peg$c15;
|
|
peg$currPos += 10;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e30);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsemacro() {
|
|
var s0, s1, s2, s3, s4;
|
|
var key = peg$currPos * 52 + 17;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$parseescape();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parsechar();
|
|
if (s4 !== peg$FAILED) {
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsechar();
|
|
}
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s1;
|
|
s1 = peg$f42(s3);
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$currPos;
|
|
s2 = peg$parseescape();
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s1;
|
|
s1 = peg$f43(s3);
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f44(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e31);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsegroup() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
var key = peg$currPos * 52 + 18;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebegin_group();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parseend_group();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsetoken();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f45(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parseend_group();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsetoken();
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f45(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s3 = peg$parseend_group();
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f46(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e32);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsegroup_contents_as_string() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 19;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsegroup();
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f47();
|
|
}
|
|
s0 = s1;
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseenvironment() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
|
|
var key = peg$currPos * 52 + 20;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebegin_env();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsegroup_contents_as_string();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsesameline_comment();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s4 = [];
|
|
s5 = peg$currPos;
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$currPos;
|
|
s8 = peg$parseend_env();
|
|
if (s8 !== peg$FAILED) {
|
|
s9 = peg$parsegroup_contents_as_string();
|
|
if (s9 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s10 = peg$f48(s2, s3, s9);
|
|
if (s10) {
|
|
s10 = void 0;
|
|
} else {
|
|
s10 = peg$FAILED;
|
|
}
|
|
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;
|
|
}
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s7 = peg$parsetoken();
|
|
if (s7 !== peg$FAILED) {
|
|
peg$savedPos = s5;
|
|
s5 = peg$f49(s2, s3, s7);
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$currPos;
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$currPos;
|
|
s8 = peg$parseend_env();
|
|
if (s8 !== peg$FAILED) {
|
|
s9 = peg$parsegroup_contents_as_string();
|
|
if (s9 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s10 = peg$f48(s2, s3, s9);
|
|
if (s10) {
|
|
s10 = void 0;
|
|
} else {
|
|
s10 = peg$FAILED;
|
|
}
|
|
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;
|
|
}
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s7 = peg$parsetoken();
|
|
if (s7 !== peg$FAILED) {
|
|
peg$savedPos = s5;
|
|
s5 = peg$f49(s2, s3, s7);
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
}
|
|
s5 = peg$parseend_env();
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parsegroup_contents_as_string();
|
|
if (s6 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f50(s2, s3, s4);
|
|
} 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$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e33);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsemath_environment() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12;
|
|
var key = peg$currPos * 52 + 21;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebegin_env();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsebegin_group();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsemath_env_name();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parseend_group();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsesameline_comment();
|
|
if (s5 === peg$FAILED) {
|
|
s5 = null;
|
|
}
|
|
s6 = [];
|
|
s7 = peg$currPos;
|
|
s8 = peg$currPos;
|
|
peg$silentFails++;
|
|
s9 = peg$currPos;
|
|
s10 = peg$parseend_env();
|
|
if (s10 !== peg$FAILED) {
|
|
s11 = peg$parsegroup();
|
|
if (s11 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s12 = peg$f51(s3, s5, s11);
|
|
if (s12) {
|
|
s12 = void 0;
|
|
} else {
|
|
s12 = peg$FAILED;
|
|
}
|
|
if (s12 !== peg$FAILED) {
|
|
s10 = [s10, s11, s12];
|
|
s9 = s10;
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s9 === peg$FAILED) {
|
|
s8 = void 0;
|
|
} else {
|
|
peg$currPos = s8;
|
|
s8 = peg$FAILED;
|
|
}
|
|
if (s8 !== peg$FAILED) {
|
|
s9 = peg$parsemath_token();
|
|
if (s9 !== peg$FAILED) {
|
|
peg$savedPos = s7;
|
|
s7 = peg$f52(s3, s5, s9);
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
while (s7 !== peg$FAILED) {
|
|
s6.push(s7);
|
|
s7 = peg$currPos;
|
|
s8 = peg$currPos;
|
|
peg$silentFails++;
|
|
s9 = peg$currPos;
|
|
s10 = peg$parseend_env();
|
|
if (s10 !== peg$FAILED) {
|
|
s11 = peg$parsegroup();
|
|
if (s11 !== peg$FAILED) {
|
|
peg$savedPos = peg$currPos;
|
|
s12 = peg$f51(s3, s5, s11);
|
|
if (s12) {
|
|
s12 = void 0;
|
|
} else {
|
|
s12 = peg$FAILED;
|
|
}
|
|
if (s12 !== peg$FAILED) {
|
|
s10 = [s10, s11, s12];
|
|
s9 = s10;
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s9;
|
|
s9 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s9 === peg$FAILED) {
|
|
s8 = void 0;
|
|
} else {
|
|
peg$currPos = s8;
|
|
s8 = peg$FAILED;
|
|
}
|
|
if (s8 !== peg$FAILED) {
|
|
s9 = peg$parsemath_token();
|
|
if (s9 !== peg$FAILED) {
|
|
peg$savedPos = s7;
|
|
s7 = peg$f52(s3, s5, s9);
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
}
|
|
s7 = peg$parseend_env();
|
|
if (s7 !== peg$FAILED) {
|
|
s8 = peg$parsebegin_group();
|
|
if (s8 !== peg$FAILED) {
|
|
s9 = peg$parsemath_env_name();
|
|
if (s9 !== peg$FAILED) {
|
|
s10 = peg$parseend_group();
|
|
if (s10 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f53(s3, s5, s6);
|
|
} 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$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e34);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsebegin_display_math() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 23;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseescape();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 91) {
|
|
s2 = peg$c4;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e14);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [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$parseend_display_math() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 24;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseescape();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 93) {
|
|
s2 = peg$c5;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e15);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [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$parsebegin_inline_math() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 25;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseescape();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 40) {
|
|
s2 = peg$c16;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e36);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [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$parseend_inline_math() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 26;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseescape();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 41) {
|
|
s2 = peg$c17;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e37);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [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$parsebegin_env() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 27;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseescape();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.substr(peg$currPos, 5) === peg$c18) {
|
|
s2 = peg$c18;
|
|
peg$currPos += 5;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e38);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [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$parseend_env() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 28;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseescape();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.substr(peg$currPos, 3) === peg$c19) {
|
|
s2 = peg$c19;
|
|
peg$currPos += 3;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e39);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [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$parsemath_env_name() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 29;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
if (input.substr(peg$currPos, 9) === peg$c20) {
|
|
s1 = peg$c20;
|
|
peg$currPos += 9;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e40);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 8) === peg$c21) {
|
|
s1 = peg$c21;
|
|
peg$currPos += 8;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e41);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 6) === peg$c22) {
|
|
s1 = peg$c22;
|
|
peg$currPos += 6;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e42);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 5) === peg$c23) {
|
|
s1 = peg$c23;
|
|
peg$currPos += 5;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e43);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 8) === peg$c24) {
|
|
s1 = peg$c24;
|
|
peg$currPos += 8;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e44);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 7) === peg$c25) {
|
|
s1 = peg$c25;
|
|
peg$currPos += 7;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e45);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 7) === peg$c26) {
|
|
s1 = peg$c26;
|
|
peg$currPos += 7;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e46);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 6) === peg$c27) {
|
|
s1 = peg$c27;
|
|
peg$currPos += 6;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e47);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 9) === peg$c28) {
|
|
s1 = peg$c28;
|
|
peg$currPos += 9;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e48);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 8) === peg$c29) {
|
|
s1 = peg$c29;
|
|
peg$currPos += 8;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e49);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 8) === peg$c30) {
|
|
s1 = peg$c30;
|
|
peg$currPos += 8;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e50);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 7) === peg$c31) {
|
|
s1 = peg$c31;
|
|
peg$currPos += 7;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e51);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 5) === peg$c32) {
|
|
s1 = peg$c32;
|
|
peg$currPos += 5;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e52);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 4) === peg$c33) {
|
|
s1 = peg$c33;
|
|
peg$currPos += 4;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e53);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 11) === peg$c34) {
|
|
s1 = peg$c34;
|
|
peg$currPos += 11;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e54);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f56(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseescape() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 30;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 92) {
|
|
s1 = peg$c35;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e56);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f57();
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e55);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsebegin_group() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 31;
|
|
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$c36;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e57);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f58(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseend_group() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 32;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 125) {
|
|
s1 = peg$c37;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e58);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f59(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsemath_shift() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 33;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 36) {
|
|
s1 = peg$c38;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e59);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f60(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsealignment_tab() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 34;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 38) {
|
|
s1 = peg$c39;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e60);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f61(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsenl() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 35;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.charCodeAt(peg$currPos) === 13) {
|
|
s2 = peg$c40;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e62);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s2 === peg$FAILED) {
|
|
s1 = void 0;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 10) {
|
|
s2 = peg$c41;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e63);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 13) {
|
|
s0 = peg$c40;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e62);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c42) {
|
|
s0 = peg$c42;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e64);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e61);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsemacro_parameter() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 36;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 35) {
|
|
s1 = peg$c43;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e65);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f62(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsesuperscript() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 37;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 94) {
|
|
s1 = peg$c44;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e66);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f63(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsesubscript() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 38;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 95) {
|
|
s1 = peg$c45;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e67);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f64(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseignore() {
|
|
var s0;
|
|
var key = peg$currPos * 52 + 39;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
if (input.charCodeAt(peg$currPos) === 0) {
|
|
s0 = peg$c46;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e68);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsesp() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 40;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e69);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e69);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f65();
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e8);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsechar() {
|
|
var s0;
|
|
var key = peg$currPos * 52 + 41;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
if (peg$r2.test(input.charAt(peg$currPos))) {
|
|
s0 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e71);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e70);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsenum() {
|
|
var s0;
|
|
var key = peg$currPos * 52 + 42;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
if (peg$r3.test(input.charAt(peg$currPos))) {
|
|
s0 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e73);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e72);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsepunctuation() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 43;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (peg$r4.test(input.charAt(peg$currPos))) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e75);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s1 = peg$f66(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e74);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsecomment_start() {
|
|
var s0;
|
|
var key = peg$currPos * 52 + 44;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
if (input.charCodeAt(peg$currPos) === 37) {
|
|
s0 = peg$c0;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e7);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsefull_comment() {
|
|
var s0;
|
|
var key = peg$currPos * 52 + 45;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$parseownline_comment();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsesameline_comment();
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e76);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseownline_comment() {
|
|
var s0, s1, s2, s3;
|
|
var key = peg$currPos * 52 + 46;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = [];
|
|
s3 = peg$parsesp();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsesp();
|
|
}
|
|
s3 = peg$parsenl();
|
|
if (s3 !== peg$FAILED) {
|
|
s2 = [s2, s3];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
s1 = null;
|
|
}
|
|
s2 = peg$parseleading_sp();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsecomment();
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f67(s2, s3);
|
|
} 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$parsesameline_comment() {
|
|
var s0, s1, s2;
|
|
var key = peg$currPos * 52 + 47;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsesp();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsesp();
|
|
}
|
|
s2 = peg$parsecomment();
|
|
if (s2 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f68(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsecomment() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
var key = peg$currPos * 52 + 48;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecomment_start();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsenl();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f69(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsenl();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f69(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s3 = peg$currPos;
|
|
peg$silentFails++;
|
|
s4 = peg$parseparbreak();
|
|
peg$silentFails--;
|
|
if (s4 !== peg$FAILED) {
|
|
peg$currPos = s3;
|
|
s3 = void 0;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f70(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecomment_start();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsenl();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f71(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsenl();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
peg$savedPos = s3;
|
|
s3 = peg$f71(s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s3 = peg$currPos;
|
|
s4 = peg$parsenl();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = [];
|
|
s6 = peg$parsesp();
|
|
while (s6 !== peg$FAILED) {
|
|
s5.push(s6);
|
|
s6 = peg$parsesp();
|
|
}
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$parsecomment_start();
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s4 = [s4, s5, s6];
|
|
s3 = s4;
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsenl();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseEOF();
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f72(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e77);
|
|
}
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseleading_sp() {
|
|
var s0, s1, s2, s3, s4;
|
|
var key = peg$currPos * 52 + 49;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$parsestart_of_line();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parsesp();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsesp();
|
|
}
|
|
s2 = [s2, s3];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s0 = input.substring(s0, peg$currPos);
|
|
} else {
|
|
s0 = s1;
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parsestart_of_line() {
|
|
var s0;
|
|
var key = peg$currPos * 52 + 50;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
peg$savedPos = peg$currPos;
|
|
s0 = peg$f73();
|
|
if (s0) {
|
|
s0 = void 0;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function peg$parseEOF() {
|
|
var s0, s1;
|
|
var key = peg$currPos * 52 + 51;
|
|
var cached = peg$resultsCache[key];
|
|
if (cached) {
|
|
peg$currPos = cached.nextPos;
|
|
return cached.result;
|
|
}
|
|
s0 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s1 === peg$FAILED) {
|
|
s0 = void 0;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
|
|
return s0;
|
|
}
|
|
function toString(e) {
|
|
if (typeof e === "string") {
|
|
return e;
|
|
}
|
|
if (typeof e.content === "string") {
|
|
return e.content;
|
|
}
|
|
if (e && e.type === "whitespace") {
|
|
return " ";
|
|
}
|
|
return e;
|
|
}
|
|
function compare_env(g1, g2) {
|
|
const g1Name = typeof g1 === "string" ? g1 : g1.content.map(toString).join("");
|
|
const g2Name = typeof g2 === "string" ? g2 : g2.content.map(toString).join("");
|
|
return g1Name === g2Name;
|
|
}
|
|
function createNode(type, extra = {}) {
|
|
return { type, ...extra, position: location() };
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _AlignEnvironmentPegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { body: peg$parsebody };
|
|
var peg$startRuleFunction = peg$parsebody;
|
|
var peg$e0 = peg$anyExpectation();
|
|
var peg$f0 = function() {
|
|
return [];
|
|
};
|
|
var peg$f1 = function(x) {
|
|
return { cells: [], colSeps: [], ...x };
|
|
};
|
|
var peg$f2 = function(rowItems, rowSep, trailingComment) {
|
|
return { ...rowItems, rowSep, trailingComment };
|
|
};
|
|
var peg$f3 = function(rowItems, trailingComment) {
|
|
return { ...rowItems, rowSep: null, trailingComment };
|
|
};
|
|
var peg$f4 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f5 = function(x) {
|
|
return {
|
|
cells: [],
|
|
colSeps: [],
|
|
rowSep: null,
|
|
trailingComment: x
|
|
};
|
|
};
|
|
var peg$f6 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f7 = function(colSep, cell) {
|
|
return { colSep, cell };
|
|
};
|
|
var peg$f8 = function(colSep) {
|
|
return { colSep };
|
|
};
|
|
var peg$f9 = function(a, b) {
|
|
return processRow(a, b);
|
|
};
|
|
var peg$f10 = function(b) {
|
|
return processRow(null, b);
|
|
};
|
|
var peg$f11 = function(tok) {
|
|
return options.isSameLineComment(tok);
|
|
};
|
|
var peg$f12 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f13 = function(tok) {
|
|
return options.isOwnLineComment(tok);
|
|
};
|
|
var peg$f14 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f15 = function(tok) {
|
|
return options.isWhitespace(tok);
|
|
};
|
|
var peg$f16 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f17 = function(tok) {
|
|
return options.isRowSep(tok);
|
|
};
|
|
var peg$f18 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f19 = function(tok) {
|
|
return options.isColSep(tok);
|
|
};
|
|
var peg$f20 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$currPos = 0;
|
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
var peg$maxFailPos = 0;
|
|
var peg$maxFailExpected = [];
|
|
var peg$silentFails = 0;
|
|
var peg$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parsebody() {
|
|
var s0, s1;
|
|
s0 = [];
|
|
s1 = peg$parsecomment_only_line();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parserow_with_end();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parserow_without_end();
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
while (s1 !== peg$FAILED) {
|
|
s0.push(s1);
|
|
s1 = peg$parsecomment_only_line();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parserow_with_end();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parserow_without_end();
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseEOL();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f0();
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parserow_with_end() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$parserow_items();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
s2 = peg$f1(s2);
|
|
s1 = s2;
|
|
s2 = peg$parserow_sep();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsetrailing_comment();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s0 = peg$f2(s1, s2, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parserow_without_end() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parserow_items();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsetrailing_comment();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
s0 = peg$f3(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsetrailing_comment() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
}
|
|
s2 = peg$parsesame_line_comment();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f4(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecomment_only_line() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
}
|
|
s2 = peg$parseown_line_comment();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f5(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsetoken() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
peg$silentFails++;
|
|
s2 = peg$parserow_sep();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsecol_sep();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsetrailing_comment();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseown_line_comment();
|
|
}
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s2 === peg$FAILED) {
|
|
s1 = void 0;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f6(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecell() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsetoken();
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsetoken();
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s0 = input.substring(s0, peg$currPos);
|
|
} else {
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseseparated_cell() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecol_sep();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsecell();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f7(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecol_sep();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f8(s1);
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parserow_items() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecell();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parseseparated_cell();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parseseparated_cell();
|
|
}
|
|
s0 = peg$f9(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parseseparated_cell();
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parseseparated_cell();
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f10(s1);
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesame_line_comment() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f11(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f12(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseown_line_comment() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f13(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f14(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsewhitespace() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f15(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f16(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parserow_sep() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f17(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f18(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecol_sep() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f19(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f20(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseEOL() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s1 === peg$FAILED) {
|
|
s0 = void 0;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function processRow(leadCell, otherCells) {
|
|
const cells = [leadCell || []];
|
|
const seps = [];
|
|
for (const x of otherCells) {
|
|
cells.push(x.cell || []);
|
|
seps.push(x.colSep);
|
|
}
|
|
return { cells, colSeps: seps };
|
|
}
|
|
if (!options.isWhitespace) {
|
|
try {
|
|
Object.assign(
|
|
options,
|
|
createMatchers(["\\", "hline", "cr"], ["&"])
|
|
);
|
|
} catch (e) {
|
|
console.warn("Error when initializing parser", e);
|
|
}
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _ArgSpecPegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { args_spec_list: peg$parseargs_spec_list };
|
|
var peg$startRuleFunction = peg$parseargs_spec_list;
|
|
var peg$c1 = "v";
|
|
var peg$c2 = "b";
|
|
var peg$c3 = "!";
|
|
var peg$c4 = "D";
|
|
var peg$c5 = "d";
|
|
var peg$c6 = "s";
|
|
var peg$c7 = "O";
|
|
var peg$c8 = "o";
|
|
var peg$c9 = "e";
|
|
var peg$c10 = "E";
|
|
var peg$c11 = "t";
|
|
var peg$c12 = "R";
|
|
var peg$c13 = "r";
|
|
var peg$c14 = "u";
|
|
var peg$c15 = "m";
|
|
var peg$c16 = "{";
|
|
var peg$c17 = "}";
|
|
var peg$c18 = " ";
|
|
var peg$c19 = "\n";
|
|
var peg$c20 = "\r";
|
|
var peg$c21 = "\\";
|
|
var peg$r0 = /^[{ ]/;
|
|
var peg$r1 = /^[a-zA-Z]/;
|
|
var peg$r2 = /^[{}]/;
|
|
var peg$e0 = peg$literalExpectation("+", false);
|
|
var peg$e1 = peg$literalExpectation("v", false);
|
|
var peg$e2 = peg$anyExpectation();
|
|
var peg$e3 = peg$literalExpectation("b", false);
|
|
var peg$e4 = peg$literalExpectation("!", false);
|
|
var peg$e5 = peg$literalExpectation("D", false);
|
|
var peg$e6 = peg$literalExpectation("d", false);
|
|
var peg$e7 = peg$literalExpectation("s", false);
|
|
var peg$e8 = peg$literalExpectation("O", false);
|
|
var peg$e9 = peg$literalExpectation("o", false);
|
|
var peg$e10 = peg$literalExpectation("e", false);
|
|
var peg$e11 = peg$literalExpectation("E", false);
|
|
var peg$e12 = peg$literalExpectation("t", false);
|
|
var peg$e13 = peg$literalExpectation("R", false);
|
|
var peg$e14 = peg$literalExpectation("r", false);
|
|
var peg$e15 = peg$literalExpectation("u", false);
|
|
var peg$e16 = peg$classExpectation(["{", " "], false, false);
|
|
var peg$e17 = peg$literalExpectation("m", false);
|
|
var peg$e18 = peg$literalExpectation("{", false);
|
|
var peg$e19 = peg$literalExpectation("}", false);
|
|
var peg$e20 = peg$literalExpectation(" ", false);
|
|
var peg$e21 = peg$literalExpectation("\n", false);
|
|
var peg$e22 = peg$literalExpectation("\r", false);
|
|
var peg$e23 = peg$literalExpectation("\\", false);
|
|
var peg$e24 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false);
|
|
var peg$e25 = peg$classExpectation(["{", "}"], false, false);
|
|
var peg$f0 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f1 = function(spec) {
|
|
return spec;
|
|
};
|
|
var peg$f2 = function(spec) {
|
|
return spec;
|
|
};
|
|
var peg$f3 = function(openBrace) {
|
|
return createNode("verbatim", { openBrace, closeBrace: openBrace });
|
|
};
|
|
var peg$f4 = function() {
|
|
return createNode("body");
|
|
};
|
|
var peg$f5 = function(leading_bang, spec) {
|
|
return leading_bang ? { ...spec, noLeadingWhitespace: true } : spec;
|
|
};
|
|
var peg$f6 = function(braceSpec, defaultArg) {
|
|
return createNode("optional", { ...braceSpec, defaultArg });
|
|
};
|
|
var peg$f7 = function(braceSpec) {
|
|
return createNode("optional", braceSpec);
|
|
};
|
|
var peg$f8 = function() {
|
|
return createNode("optionalStar");
|
|
};
|
|
var peg$f9 = function(g) {
|
|
return createNode("optional", { defaultArg: g });
|
|
};
|
|
var peg$f10 = function() {
|
|
return createNode("optional");
|
|
};
|
|
var peg$f11 = function(args) {
|
|
return createNode("embellishment", {
|
|
embellishmentTokens: args
|
|
});
|
|
};
|
|
var peg$f12 = function(args, g) {
|
|
return createNode("embellishment", {
|
|
embellishmentTokens: args,
|
|
defaultArg: g
|
|
});
|
|
};
|
|
var peg$f13 = function(tok) {
|
|
return createNode("optionalToken", { token: tok });
|
|
};
|
|
var peg$f14 = function(braceSpec, defaultArg) {
|
|
return createNode("mandatory", { ...braceSpec, defaultArg });
|
|
};
|
|
var peg$f15 = function(braceSpec) {
|
|
return createNode("mandatory", braceSpec);
|
|
};
|
|
var peg$f16 = function(stopTokens) {
|
|
return createNode("until", { stopTokens });
|
|
};
|
|
var peg$f17 = function(x) {
|
|
return [x];
|
|
};
|
|
var peg$f18 = function(g) {
|
|
return g.content;
|
|
};
|
|
var peg$f19 = function() {
|
|
return createNode("mandatory");
|
|
};
|
|
var peg$f20 = function(openBrace, closeBrace) {
|
|
return { openBrace, closeBrace };
|
|
};
|
|
var peg$f21 = function(g) {
|
|
return g.content.map(groupToStr).join("");
|
|
};
|
|
var peg$f22 = function(t) {
|
|
return [t];
|
|
};
|
|
var peg$f23 = function(args) {
|
|
return args.filter((a) => !a.match(/^\s*$/));
|
|
};
|
|
var peg$f24 = function(content) {
|
|
return { type: "group", content };
|
|
};
|
|
var peg$f25 = function() {
|
|
return "";
|
|
};
|
|
var peg$currPos = 0;
|
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
var peg$maxFailPos = 0;
|
|
var peg$maxFailExpected = [];
|
|
var peg$silentFails = 0;
|
|
var peg$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function peg$literalExpectation(text2, ignoreCase) {
|
|
return { type: "literal", text: text2, ignoreCase };
|
|
}
|
|
function peg$classExpectation(parts, inverted, ignoreCase) {
|
|
return { type: "class", parts, inverted, ignoreCase };
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parseargs_spec_list() {
|
|
var s0, s1, s2, s4;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$currPos;
|
|
peg$parsewhitespace();
|
|
s4 = peg$parsearg_spec();
|
|
if (s4 !== peg$FAILED) {
|
|
s2 = peg$f0(s4);
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$currPos;
|
|
peg$parsewhitespace();
|
|
s4 = peg$parsearg_spec();
|
|
if (s4 !== peg$FAILED) {
|
|
s2 = peg$f0(s4);
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
}
|
|
s2 = peg$parsewhitespace();
|
|
s0 = peg$f1(s1);
|
|
return s0;
|
|
}
|
|
function peg$parsearg_spec() {
|
|
var s0, s2;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 43) {
|
|
peg$currPos++;
|
|
} else {
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
s2 = peg$parseoptional();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsemandatory();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseverbatim();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parserequired();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsebody();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseuntil();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f2(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseverbatim() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 118) {
|
|
s1 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e1);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f3(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsebody() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 98) {
|
|
s1 = peg$c2;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f4();
|
|
}
|
|
s0 = s1;
|
|
return s0;
|
|
}
|
|
function peg$parseoptional() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 33) {
|
|
s1 = peg$c3;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e4);
|
|
}
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
s1 = null;
|
|
}
|
|
s2 = peg$parseoptional_star();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseoptional_standard();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseoptional_delimited();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseoptional_embellishment();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseoptional_token();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f5(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseoptional_delimited() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 68) {
|
|
s1 = peg$c4;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsebrace_spec();
|
|
s3 = peg$parsearg();
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f6(s2, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 100) {
|
|
s1 = peg$c5;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e6);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsebrace_spec();
|
|
s0 = peg$f7(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseoptional_star() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 115) {
|
|
s1 = peg$c6;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e7);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f8();
|
|
}
|
|
s0 = s1;
|
|
return s0;
|
|
}
|
|
function peg$parseoptional_standard() {
|
|
var s0, s1, s3;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 79) {
|
|
s1 = peg$c7;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e8);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$parsewhitespace();
|
|
s3 = peg$parsearg();
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f9(s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 111) {
|
|
s1 = peg$c8;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e9);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f10();
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseoptional_embellishment() {
|
|
var s0, s1, s3, s5;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 101) {
|
|
s1 = peg$c9;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e10);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$parsewhitespace();
|
|
s3 = peg$parseargs();
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f11(s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 69) {
|
|
s1 = peg$c10;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e11);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
peg$parsewhitespace();
|
|
s3 = peg$parseargs();
|
|
if (s3 !== peg$FAILED) {
|
|
peg$parsewhitespace();
|
|
s5 = peg$parseargs();
|
|
if (s5 !== peg$FAILED) {
|
|
s0 = peg$f12(s3, s5);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseoptional_token() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 116) {
|
|
s1 = peg$c11;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e12);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f13(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parserequired() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 82) {
|
|
s1 = peg$c12;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e13);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsebrace_spec();
|
|
s3 = peg$parsearg();
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f14(s2, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 114) {
|
|
s1 = peg$c13;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e14);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsebrace_spec();
|
|
s0 = peg$f15(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseuntil() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 117) {
|
|
s1 = peg$c14;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e15);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseuntil_stop_token();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f16(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseuntil_stop_token() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e16);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s2 === peg$FAILED) {
|
|
s1 = void 0;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f17(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebraced_group();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f18(s1);
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsemandatory() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 109) {
|
|
s1 = peg$c15;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e17);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f19();
|
|
}
|
|
s0 = s1;
|
|
return s0;
|
|
}
|
|
function peg$parsebrace_spec() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$currPos;
|
|
s3 = peg$currPos;
|
|
peg$silentFails++;
|
|
s4 = peg$parsewhitespace_token();
|
|
peg$silentFails--;
|
|
if (s4 === peg$FAILED) {
|
|
s3 = void 0;
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parsemacro();
|
|
if (s4 === peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s4 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s3 = [s3, s4];
|
|
s2 = s3;
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
s1 = input.substring(s1, peg$currPos);
|
|
s2 = peg$currPos;
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
peg$silentFails++;
|
|
s5 = peg$parsewhitespace_token();
|
|
peg$silentFails--;
|
|
if (s5 === peg$FAILED) {
|
|
s4 = void 0;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemacro();
|
|
if (s5 === peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s4 = [s4, s5];
|
|
s3 = s4;
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s2 = input.substring(s2, peg$currPos);
|
|
s0 = peg$f20(s1, s2);
|
|
return s0;
|
|
}
|
|
function peg$parsearg() {
|
|
var s0, s1;
|
|
s0 = peg$parsetoken();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsebraced_group();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f21(s1);
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseargs() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsetoken();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f22(s1);
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 123) {
|
|
s1 = peg$c16;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e18);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parsearg();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsewhitespace_token();
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsearg();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsewhitespace_token();
|
|
}
|
|
}
|
|
if (input.charCodeAt(peg$currPos) === 125) {
|
|
s3 = peg$c17;
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e19);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f23(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsebraced_group() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 123) {
|
|
s1 = peg$c16;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e18);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
s5 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.charCodeAt(peg$currPos) === 125) {
|
|
s6 = peg$c17;
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e19);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s6 === peg$FAILED) {
|
|
s5 = void 0;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$parsebraced_group();
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s7 = peg$parsetoken();
|
|
if (s7 === peg$FAILED) {
|
|
s7 = peg$parsewhitespace_token();
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s5 = [s5, s6, s7];
|
|
s4 = s5;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s3 = input.substring(s3, peg$currPos);
|
|
} else {
|
|
s3 = s4;
|
|
}
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsebraced_group();
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$currPos;
|
|
s5 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.charCodeAt(peg$currPos) === 125) {
|
|
s6 = peg$c17;
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e19);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s6 === peg$FAILED) {
|
|
s5 = void 0;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$parsebraced_group();
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s7 = peg$parsetoken();
|
|
if (s7 === peg$FAILED) {
|
|
s7 = peg$parsewhitespace_token();
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s5 = [s5, s6, s7];
|
|
s4 = s5;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s3 = input.substring(s3, peg$currPos);
|
|
} else {
|
|
s3 = s4;
|
|
}
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsebraced_group();
|
|
}
|
|
}
|
|
if (input.charCodeAt(peg$currPos) === 125) {
|
|
s3 = peg$c17;
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e19);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f24(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsewhitespace() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace_token();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace_token();
|
|
}
|
|
s1 = peg$f25();
|
|
s0 = s1;
|
|
return s0;
|
|
}
|
|
function peg$parsewhitespace_token() {
|
|
var s0;
|
|
if (input.charCodeAt(peg$currPos) === 32) {
|
|
s0 = peg$c18;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 10) {
|
|
s0 = peg$c19;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e21);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 13) {
|
|
s0 = peg$c20;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e22);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsemacro() {
|
|
var s0, s1, s2, s3, s4;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 92) {
|
|
s2 = peg$c21;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e23);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s4 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e24);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s4 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e24);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s2 = [s2, s3];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s0 = input.substring(s0, peg$currPos);
|
|
} else {
|
|
s0 = s1;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 92) {
|
|
s2 = peg$c21;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e23);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s4 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e24);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s4 === peg$FAILED) {
|
|
s3 = void 0;
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s4 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s2 = [s2, s3, s4];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s0 = input.substring(s0, peg$currPos);
|
|
} else {
|
|
s0 = s1;
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsetoken() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$parsemacro();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (peg$r2.test(input.charAt(peg$currPos))) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e25);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s2 === peg$FAILED) {
|
|
s1 = void 0;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$currPos;
|
|
peg$silentFails++;
|
|
s3 = peg$parsewhitespace_token();
|
|
peg$silentFails--;
|
|
if (s3 === peg$FAILED) {
|
|
s2 = void 0;
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = s3;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
const DEFAULT_OPTIONS = {
|
|
optional: { openBrace: "[", closeBrace: "]" },
|
|
mandatory: { openBrace: "{", closeBrace: "}" }
|
|
};
|
|
function createNode(type, options2) {
|
|
const computedOptions = DEFAULT_OPTIONS[type] || {};
|
|
return { type, ...computedOptions, ...options2 };
|
|
}
|
|
function groupToStr(node) {
|
|
if (typeof node !== "object" || !node) {
|
|
return node;
|
|
}
|
|
if (node.type === "group") {
|
|
return `{${node.content.map(groupToStr).join("")}}`;
|
|
}
|
|
return node;
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _PgfkeysPegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { body: peg$parsebody };
|
|
var peg$startRuleFunction = peg$parsebody;
|
|
var peg$e0 = peg$anyExpectation();
|
|
var peg$f0 = function() {
|
|
return [];
|
|
};
|
|
var peg$f1 = function(rowItems, trailingComment) {
|
|
return {
|
|
itemParts: [],
|
|
...rowItems,
|
|
trailingComment,
|
|
trailingComma: true
|
|
};
|
|
};
|
|
var peg$f2 = function(rowItems, trailingComment) {
|
|
return { ...rowItems, trailingComment };
|
|
};
|
|
var peg$f3 = function(a, b) {
|
|
return processItem(a, b);
|
|
};
|
|
var peg$f4 = function(b) {
|
|
return processItem(null, b);
|
|
};
|
|
var peg$f5 = function(cell) {
|
|
return { cell };
|
|
};
|
|
var peg$f6 = function() {
|
|
return {};
|
|
};
|
|
var peg$f7 = function(part) {
|
|
return part;
|
|
};
|
|
var peg$f8 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f9 = function(space, x) {
|
|
return {
|
|
trailingComment: x,
|
|
leadingParbreak: space.parbreak > 0
|
|
};
|
|
};
|
|
var peg$f10 = function(list) {
|
|
return {
|
|
whitespace: list.filter((x) => options.isWhitespace(x)).length,
|
|
parbreak: list.filter((x) => options.isParbreak(x)).length
|
|
};
|
|
};
|
|
var peg$f11 = function() {
|
|
return !options.allowParenGroups;
|
|
};
|
|
var peg$f12 = function(tok) {
|
|
return options.isSameLineComment(tok);
|
|
};
|
|
var peg$f13 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f14 = function(tok) {
|
|
return options.isOwnLineComment(tok);
|
|
};
|
|
var peg$f15 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f16 = function(tok) {
|
|
return options.isWhitespace(tok);
|
|
};
|
|
var peg$f17 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f18 = function(tok) {
|
|
return options.isParbreak(tok);
|
|
};
|
|
var peg$f19 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f20 = function(tok) {
|
|
return options.isComma(tok);
|
|
};
|
|
var peg$f21 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f22 = function(tok) {
|
|
return options.isEquals(tok);
|
|
};
|
|
var peg$f23 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f24 = function(tok) {
|
|
return options.isChar(tok, "(");
|
|
};
|
|
var peg$f25 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f26 = function(tok) {
|
|
return options.isChar(tok, ")");
|
|
};
|
|
var peg$f27 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$currPos = 0;
|
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
var peg$maxFailPos = 0;
|
|
var peg$maxFailExpected = [];
|
|
var peg$silentFails = 0;
|
|
var peg$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parsebody() {
|
|
var s0, s1, s2;
|
|
s0 = [];
|
|
s1 = peg$parsecomment_only_line();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parseitem_with_end();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parseitem_without_end();
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
while (s1 !== peg$FAILED) {
|
|
s0.push(s1);
|
|
s1 = peg$parsecomment_only_line();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parseitem_with_end();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parseitem_without_end();
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
}
|
|
s2 = peg$parseEOL();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f0();
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseitem_with_end() {
|
|
var s0, s2, s4, s5, s6, s7, s8;
|
|
s0 = peg$currPos;
|
|
peg$parsewhitespace_or_parbreaks();
|
|
s2 = peg$parserow_items();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
peg$parsewhitespace_or_parbreaks();
|
|
s4 = peg$parseitem_sep();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = [];
|
|
s6 = peg$parsewhitespace();
|
|
while (s6 !== peg$FAILED) {
|
|
s5.push(s6);
|
|
s6 = peg$parsewhitespace();
|
|
}
|
|
s6 = peg$parsetrailing_comment();
|
|
if (s6 === peg$FAILED) {
|
|
s6 = null;
|
|
}
|
|
s7 = [];
|
|
s8 = peg$parsewhitespace();
|
|
while (s8 !== peg$FAILED) {
|
|
s7.push(s8);
|
|
s8 = peg$parsewhitespace();
|
|
}
|
|
s0 = peg$f1(s2, s6);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseitem_without_end() {
|
|
var s0, s2, s3;
|
|
s0 = peg$currPos;
|
|
peg$parsewhitespace_or_parbreaks();
|
|
s2 = peg$parserow_items();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsetrailing_comment();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s0 = peg$f2(s2, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parserow_items() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseitem_part();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parseseparated_part();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parseseparated_part();
|
|
}
|
|
s0 = peg$f3(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parseseparated_part();
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parseseparated_part();
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f4(s1);
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseseparated_part() {
|
|
var s0, s1, s2, s3, s4;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parseparbreak();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parseparbreak();
|
|
}
|
|
s2 = peg$parseequals();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parseparbreak();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parseparbreak();
|
|
}
|
|
s4 = peg$parseitem_part();
|
|
if (s4 !== peg$FAILED) {
|
|
s0 = peg$f5(s4);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parseparbreak();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parseparbreak();
|
|
}
|
|
s2 = peg$parseequals();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f6();
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseitem_part() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
}
|
|
s2 = peg$currPos;
|
|
s3 = [];
|
|
s4 = peg$parsenon_whitespace_non_parbreak_token();
|
|
if (s4 === peg$FAILED) {
|
|
s4 = peg$currPos;
|
|
s5 = peg$parsewhitespace();
|
|
if (s5 === peg$FAILED) {
|
|
s5 = peg$parseparbreak();
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$currPos;
|
|
s8 = [];
|
|
s9 = peg$parsewhitespace();
|
|
if (s9 === peg$FAILED) {
|
|
s9 = peg$parseparbreak();
|
|
}
|
|
while (s9 !== peg$FAILED) {
|
|
s8.push(s9);
|
|
s9 = peg$parsewhitespace();
|
|
if (s9 === peg$FAILED) {
|
|
s9 = peg$parseparbreak();
|
|
}
|
|
}
|
|
s9 = peg$parsenon_whitespace_non_parbreak_token();
|
|
if (s9 !== peg$FAILED) {
|
|
s8 = [s8, s9];
|
|
s7 = s8;
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s7 !== peg$FAILED) {
|
|
peg$currPos = s6;
|
|
s6 = void 0;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
}
|
|
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) {
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsenon_whitespace_non_parbreak_token();
|
|
if (s4 === peg$FAILED) {
|
|
s4 = peg$currPos;
|
|
s5 = peg$parsewhitespace();
|
|
if (s5 === peg$FAILED) {
|
|
s5 = peg$parseparbreak();
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$currPos;
|
|
s8 = [];
|
|
s9 = peg$parsewhitespace();
|
|
if (s9 === peg$FAILED) {
|
|
s9 = peg$parseparbreak();
|
|
}
|
|
while (s9 !== peg$FAILED) {
|
|
s8.push(s9);
|
|
s9 = peg$parsewhitespace();
|
|
if (s9 === peg$FAILED) {
|
|
s9 = peg$parseparbreak();
|
|
}
|
|
}
|
|
s9 = peg$parsenon_whitespace_non_parbreak_token();
|
|
if (s9 !== peg$FAILED) {
|
|
s8 = [s8, s9];
|
|
s7 = s8;
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s7 !== peg$FAILED) {
|
|
peg$currPos = s6;
|
|
s6 = void 0;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s5 = [s5, s6];
|
|
s4 = s5;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s2 = input.substring(s2, peg$currPos);
|
|
} else {
|
|
s2 = s3;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parsewhitespace();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsewhitespace();
|
|
}
|
|
s0 = peg$f7(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsetrailing_comment() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
}
|
|
s2 = peg$parsesame_line_comment();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f8(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecomment_only_line() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsewhitespace_or_parbreaks();
|
|
s2 = peg$parseown_line_comment();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f9(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsetoken() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$currPos;
|
|
peg$silentFails++;
|
|
s3 = peg$parsenon_token();
|
|
peg$silentFails--;
|
|
if (s3 === peg$FAILED) {
|
|
s2 = void 0;
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s2 = [s2, s3];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s0 = input.substring(s0, peg$currPos);
|
|
} else {
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsenon_whitespace_non_parbreak_token() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$currPos;
|
|
peg$silentFails++;
|
|
s3 = peg$parsewhitespace();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseparbreak();
|
|
}
|
|
peg$silentFails--;
|
|
if (s3 === peg$FAILED) {
|
|
s2 = void 0;
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parseparen_block();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsetoken();
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s2 = [s2, s3];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s0 = input.substring(s0, peg$currPos);
|
|
} else {
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsenon_token() {
|
|
var s0;
|
|
s0 = peg$parseitem_sep();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseequals();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsetrailing_comment();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseown_line_comment();
|
|
}
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsewhitespace_or_parbreaks() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsewhitespace();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseparbreak();
|
|
}
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsewhitespace();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseparbreak();
|
|
}
|
|
}
|
|
s1 = peg$f10(s1);
|
|
s0 = s1;
|
|
return s0;
|
|
}
|
|
function peg$parseparen_block() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8;
|
|
s0 = peg$currPos;
|
|
s1 = peg$f11();
|
|
if (s1) {
|
|
s1 = peg$FAILED;
|
|
} else {
|
|
s1 = void 0;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$currPos;
|
|
s3 = peg$currPos;
|
|
s4 = peg$parseopen_paren();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = [];
|
|
s6 = peg$currPos;
|
|
s7 = peg$currPos;
|
|
peg$silentFails++;
|
|
s8 = peg$parseclose_paren();
|
|
peg$silentFails--;
|
|
if (s8 === peg$FAILED) {
|
|
s7 = void 0;
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s8 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s8 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s8 !== peg$FAILED) {
|
|
s7 = [s7, s8];
|
|
s6 = s7;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
while (s6 !== peg$FAILED) {
|
|
s5.push(s6);
|
|
s6 = peg$currPos;
|
|
s7 = peg$currPos;
|
|
peg$silentFails++;
|
|
s8 = peg$parseclose_paren();
|
|
peg$silentFails--;
|
|
if (s8 === peg$FAILED) {
|
|
s7 = void 0;
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s8 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s8 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s8 !== peg$FAILED) {
|
|
s7 = [s7, s8];
|
|
s6 = s7;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
}
|
|
s6 = peg$parseclose_paren();
|
|
if (s6 !== peg$FAILED) {
|
|
s4 = [s4, s5, s6];
|
|
s3 = s4;
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s2 = input.substring(s2, peg$currPos);
|
|
} else {
|
|
s2 = s3;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesame_line_comment() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f12(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f13(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseown_line_comment() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f14(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f15(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsewhitespace() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f16(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f17(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseparbreak() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f18(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f19(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseitem_sep() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f20(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f21(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseequals() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f22(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f23(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseopen_paren() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f24(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f25(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseclose_paren() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f26(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f27(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseEOL() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s1 === peg$FAILED) {
|
|
s0 = void 0;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function processItem(leadCell, otherCells) {
|
|
const cells = [leadCell || []];
|
|
for (const x of otherCells) {
|
|
cells.push(x.cell || []);
|
|
}
|
|
return { itemParts: cells };
|
|
}
|
|
if (!options.isWhitespace) {
|
|
try {
|
|
Object.assign(options, {
|
|
isChar: (node, char) => node.type === "string" && node.content === char,
|
|
isComma(node) {
|
|
return node.type === "string" && node.content === ",";
|
|
},
|
|
isEquals(node) {
|
|
return node.type === "string" && node.content === "=";
|
|
},
|
|
isParbreak(node) {
|
|
return node.type === "parbreak";
|
|
},
|
|
isWhitespace(node) {
|
|
return node.type === "whitespace";
|
|
},
|
|
isSameLineComment: (node) => node.type === "comment" && node.sameline,
|
|
isOwnLineComment: (node) => node.type === "comment" && !node.sameline,
|
|
isComment: (node) => node.type === "comment",
|
|
allowParenGroups: true
|
|
});
|
|
} catch (e) {
|
|
console.warn("Error when initializing parser", e);
|
|
}
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _MacroSubstitutionPegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { body: peg$parsebody };
|
|
var peg$startRuleFunction = peg$parsebody;
|
|
var peg$e0 = peg$anyExpectation();
|
|
var peg$f0 = function(e) {
|
|
return [].concat(...e).filter((n) => !!n);
|
|
};
|
|
var peg$f1 = function() {
|
|
return [];
|
|
};
|
|
var peg$f2 = function(tok) {
|
|
return options.isHash(tok);
|
|
};
|
|
var peg$f3 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f4 = function(tok) {
|
|
return options.isNumber(tok);
|
|
};
|
|
var peg$f5 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f6 = function() {
|
|
return { type: "string", content: "#" };
|
|
};
|
|
var peg$f7 = function(num) {
|
|
const split = options.splitNumber(num);
|
|
return [{ type: "hash_number", number: split.number }, split.rest];
|
|
};
|
|
var peg$currPos = 0;
|
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
var peg$maxFailPos = 0;
|
|
var peg$maxFailExpected = [];
|
|
var peg$silentFails = 0;
|
|
var peg$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parsebody() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsedouble_hash();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsehash_number();
|
|
if (s2 === peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsedouble_hash();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsehash_number();
|
|
if (s2 === peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f0(s1);
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseEOL();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f1();
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsehash() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f2(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f3(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsenumber() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f4(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f5(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedouble_hash() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsehash();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsehash();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f6();
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsehash_number() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsehash();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsenumber();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f7(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseEOL() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s1 === peg$FAILED) {
|
|
s0 = void 0;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
if (!options.isHash) {
|
|
try {
|
|
Object.assign(options, {
|
|
isHash: (node) => node.type === "string" && node.content === "#",
|
|
isNumber: (node) => node.type === "string" && 0 < +node.content.charAt(0),
|
|
splitNumber: (node) => {
|
|
const number = +node.content.charAt(0);
|
|
if (node.content.length > 1) {
|
|
return {
|
|
number,
|
|
rest: {
|
|
type: "string",
|
|
content: node.content.slice(1)
|
|
}
|
|
};
|
|
}
|
|
return { number };
|
|
}
|
|
});
|
|
} catch (e) {
|
|
console.warn("Error when initializing parser", e);
|
|
}
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _LigaturesPegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { body: peg$parsebody };
|
|
var peg$startRuleFunction = peg$parsebody;
|
|
var peg$e0 = peg$anyExpectation();
|
|
var peg$f0 = function(e) {
|
|
return [].concat(...e).filter((n) => !!n);
|
|
};
|
|
var peg$f1 = function() {
|
|
return [];
|
|
};
|
|
var peg$f2 = function(toks) {
|
|
return options.isRecognized(toks);
|
|
};
|
|
var peg$f3 = function(toks) {
|
|
return options.isRecognized(toks);
|
|
};
|
|
var peg$f4 = function(tok1, tok2) {
|
|
const split = options.split(tok2);
|
|
return options.isRecognized([tok1, split[0]]);
|
|
};
|
|
var peg$f5 = function(tok1, tok2) {
|
|
const split = options.split(tok2);
|
|
return [options.isRecognized([tok1, split[0]]), split[1]];
|
|
};
|
|
var peg$f6 = function(tok1, tok2) {
|
|
return options.isRecognized([tok1, tok2]);
|
|
};
|
|
var peg$f7 = function(tok1, tok2) {
|
|
return options.isRecognized([tok1, tok2]);
|
|
};
|
|
var peg$f8 = function(toks) {
|
|
return options.isRecognized(toks);
|
|
};
|
|
var peg$f9 = function(toks) {
|
|
return options.isRecognized(toks);
|
|
};
|
|
var peg$f10 = function(tok) {
|
|
return options.isRecognized([tok]);
|
|
};
|
|
var peg$f11 = function(tok) {
|
|
return options.isRecognized([tok]);
|
|
};
|
|
var peg$f12 = function(tok) {
|
|
return options.isMacro(tok);
|
|
};
|
|
var peg$f13 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f14 = function(tok) {
|
|
return options.isWhitespace(tok);
|
|
};
|
|
var peg$f15 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f16 = function(tok) {
|
|
return options.isSplitable(tok);
|
|
};
|
|
var peg$f17 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$currPos = 0;
|
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
var peg$maxFailPos = 0;
|
|
var peg$maxFailExpected = [];
|
|
var peg$silentFails = 0;
|
|
var peg$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parsebody() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsetriple_ligature();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsedouble_ligature();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsemono_ligature();
|
|
if (s2 === peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsetriple_ligature();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsedouble_ligature();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsemono_ligature();
|
|
if (s2 === peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f0(s1);
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseEOL();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f1();
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsetriple_ligature() {
|
|
var s0, s1, s2, s3, s4;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s4 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s2 = [s2, s3, s4];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f2(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f3(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedouble_ligature() {
|
|
var s0;
|
|
s0 = peg$parsedouble_macro_ligature();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsedouble_macro_ligature_extracted();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsedouble_char_ligature();
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedouble_macro_ligature_extracted() {
|
|
var s0, s1, s2, s3, s4;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsemacro();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parsewhitespace();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsewhitespace();
|
|
}
|
|
s3 = peg$parsesplitable();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$f4(s1, s3);
|
|
if (s4) {
|
|
s4 = void 0;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s0 = peg$f5(s1, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedouble_macro_ligature() {
|
|
var s0, s1, s2, s3, s4;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsemacro();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parsewhitespace();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsewhitespace();
|
|
}
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$f6(s1, s3);
|
|
if (s4) {
|
|
s4 = void 0;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s0 = peg$f7(s1, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedouble_char_ligature() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s2 = [s2, s3];
|
|
s1 = s2;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f8(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f9(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsemono_ligature() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f10(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f11(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsemacro() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f12(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f13(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsewhitespace() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f14(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f15(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesplitable() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f16(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f17(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseEOL() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s1 === peg$FAILED) {
|
|
s0 = void 0;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
if (!options.isWhitespace) {
|
|
try {
|
|
Object.assign(options, {
|
|
isMacro: (node) => node.type === "macro",
|
|
isWhitespace: (node) => node.type === "whitespace",
|
|
isRecognized: (nodes) => {
|
|
if (nodes.length == 2 && nodes[0].content === "^" && nodes[1].content === "o") {
|
|
return { type: "string", content: "ô" };
|
|
}
|
|
return null;
|
|
},
|
|
isSplitable: (node) => node.type === "string" && node.content.length > 1,
|
|
split: (node) => [
|
|
{ type: "string", content: node.content.charAt(0) },
|
|
{ type: "string", content: node.content.slice(1) }
|
|
]
|
|
});
|
|
} catch (e) {
|
|
console.warn("Error when initializing parser", e);
|
|
}
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _XColorPegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { start: peg$parsestart };
|
|
var peg$startRuleFunction = peg$parsestart;
|
|
var peg$c0 = ";";
|
|
var peg$c1 = ",";
|
|
var peg$c2 = ":";
|
|
var peg$c3 = "/";
|
|
var peg$c4 = ">";
|
|
var peg$c5 = "!";
|
|
var peg$c6 = ".";
|
|
var peg$c7 = "!![";
|
|
var peg$c8 = "]";
|
|
var peg$c9 = "!!";
|
|
var peg$c10 = "+";
|
|
var peg$c11 = "-";
|
|
var peg$r0 = /^[a-zA-Z0-9]/;
|
|
var peg$r1 = /^[0-9]/;
|
|
var peg$r2 = /^[ \t\n\r]/;
|
|
var peg$r3 = /^[0-9a-fA-F]/;
|
|
var peg$e0 = peg$anyExpectation();
|
|
var peg$e1 = peg$literalExpectation(";", false);
|
|
var peg$e2 = peg$literalExpectation(",", false);
|
|
var peg$e3 = peg$otherExpectation("model list");
|
|
var peg$e4 = peg$literalExpectation(":", false);
|
|
var peg$e5 = peg$literalExpectation("/", false);
|
|
var peg$e6 = peg$otherExpectation("model");
|
|
var peg$e7 = peg$otherExpectation("color spec list");
|
|
var peg$e8 = peg$otherExpectation("color spec");
|
|
var peg$e9 = peg$otherExpectation("color");
|
|
var peg$e10 = peg$otherExpectation("function expression");
|
|
var peg$e11 = peg$literalExpectation(">", false);
|
|
var peg$e12 = peg$otherExpectation("function");
|
|
var peg$e13 = peg$otherExpectation("extended expression");
|
|
var peg$e14 = peg$otherExpectation("core model");
|
|
var peg$e15 = peg$otherExpectation("expr");
|
|
var peg$e16 = peg$literalExpectation("!", false);
|
|
var peg$e17 = peg$otherExpectation("mix expr");
|
|
var peg$e18 = peg$otherExpectation("name");
|
|
var peg$e19 = peg$literalExpectation(".", false);
|
|
var peg$e20 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false);
|
|
var peg$e21 = peg$otherExpectation("postfix");
|
|
var peg$e22 = peg$literalExpectation("!![", false);
|
|
var peg$e23 = peg$literalExpectation("]", false);
|
|
var peg$e24 = peg$literalExpectation("!!", false);
|
|
var peg$e25 = peg$otherExpectation("prefix");
|
|
var peg$e26 = peg$otherExpectation("plus");
|
|
var peg$e27 = peg$literalExpectation("+", false);
|
|
var peg$e28 = peg$otherExpectation("minus");
|
|
var peg$e29 = peg$literalExpectation("-", false);
|
|
var peg$e30 = peg$otherExpectation("num");
|
|
var peg$e31 = peg$classExpectation([["0", "9"]], false, false);
|
|
var peg$e32 = peg$otherExpectation("positive float");
|
|
var peg$e33 = peg$otherExpectation("divisor");
|
|
var peg$e34 = peg$otherExpectation("int");
|
|
var peg$e36 = peg$classExpectation([" ", " ", "\n", "\r"], false, false);
|
|
var peg$e37 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false);
|
|
var peg$f0 = function(m) {
|
|
return m;
|
|
};
|
|
var peg$f1 = function(m) {
|
|
return m;
|
|
};
|
|
var peg$f2 = function(m) {
|
|
return m;
|
|
};
|
|
var peg$f3 = function(m) {
|
|
return m;
|
|
};
|
|
var peg$f4 = function(m) {
|
|
return m;
|
|
};
|
|
var peg$f5 = function(a) {
|
|
return { type: "invalid_spec", content: a };
|
|
};
|
|
var peg$f6 = function(f, c) {
|
|
return c;
|
|
};
|
|
var peg$f7 = function(f, r) {
|
|
return { type: "color_set", content: [f].concat(r) };
|
|
};
|
|
var peg$f8 = function(n, s) {
|
|
return { type: "color_set_item", name: n, spec_list: s };
|
|
};
|
|
var peg$f9 = function(c, m) {
|
|
return { type: "model_list", contents: m, core_model: c };
|
|
};
|
|
var peg$f10 = function(m) {
|
|
return { type: "model_list", contents: m, core_model: null };
|
|
};
|
|
var peg$f11 = function(m, a) {
|
|
return a;
|
|
};
|
|
var peg$f12 = function(m, r) {
|
|
return [m].concat(r);
|
|
};
|
|
var peg$f13 = function(s, a) {
|
|
return a;
|
|
};
|
|
var peg$f14 = function(s, r) {
|
|
return { type: "spec_list", content: [s].concat(r) };
|
|
};
|
|
var peg$f15 = function(c) {
|
|
return { type: "hex_spec", content: [c] };
|
|
};
|
|
var peg$f16 = function(c, d) {
|
|
return d;
|
|
};
|
|
var peg$f17 = function(c, d) {
|
|
return d;
|
|
};
|
|
var peg$f18 = function(c, r) {
|
|
return { type: "num_spec", content: r ? [c].concat(r) : [c] };
|
|
};
|
|
var peg$f19 = function(c, fs) {
|
|
return { type: "color", color: c, functions: fs };
|
|
};
|
|
var peg$f20 = function(f, n) {
|
|
return n;
|
|
};
|
|
var peg$f21 = function(f, args) {
|
|
return { type: "function", name: f, args };
|
|
};
|
|
var peg$f22 = function(core, d, e, es) {
|
|
return {
|
|
type: "extended_expr",
|
|
core_model: core,
|
|
div: d,
|
|
expressions: [e].concat(es)
|
|
};
|
|
};
|
|
var peg$f23 = function(core, e, es) {
|
|
return {
|
|
type: "extended_expr",
|
|
core_model: core,
|
|
div: null,
|
|
expressions: [e].concat(es)
|
|
};
|
|
};
|
|
var peg$f24 = function(e, d) {
|
|
return { type: "weighted_expr", color: e, weight: d };
|
|
};
|
|
var peg$f25 = function(e) {
|
|
return e;
|
|
};
|
|
var peg$f26 = function(p, n, e, po) {
|
|
return {
|
|
type: "expr",
|
|
prefix: p,
|
|
name: n,
|
|
mix_expr: e,
|
|
postfix: po
|
|
};
|
|
};
|
|
var peg$f27 = function(p, n) {
|
|
return { type: "complete_mix", mix_percent: p, name: n };
|
|
};
|
|
var peg$f28 = function(p) {
|
|
return { type: "partial_mix", mix_percent: p };
|
|
};
|
|
var peg$f29 = function(c, p) {
|
|
return c.concat(p || []);
|
|
};
|
|
var peg$f30 = function(n) {
|
|
return { type: "postfix", num: n };
|
|
};
|
|
var peg$f31 = function(p) {
|
|
return { type: "postfix", plusses: p };
|
|
};
|
|
var peg$f32 = function(n) {
|
|
return parseInt(n, 10);
|
|
};
|
|
var peg$f33 = function(n) {
|
|
return parseFloat(n);
|
|
};
|
|
var peg$f34 = function(n) {
|
|
return n;
|
|
};
|
|
var peg$f35 = function(n) {
|
|
return -n;
|
|
};
|
|
var peg$f36 = function(m, n) {
|
|
return m ? -n : n;
|
|
};
|
|
var peg$f37 = function(h) {
|
|
return h.toUpperCase();
|
|
};
|
|
var peg$currPos = 0;
|
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
var peg$maxFailPos = 0;
|
|
var peg$maxFailExpected = [];
|
|
var peg$silentFails = 0;
|
|
var peg$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function peg$literalExpectation(text2, ignoreCase) {
|
|
return { type: "literal", text: text2, ignoreCase };
|
|
}
|
|
function peg$classExpectation(parts, inverted, ignoreCase) {
|
|
return { type: "class", parts, inverted, ignoreCase };
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
function peg$otherExpectation(description) {
|
|
return { type: "other", 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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parsestart() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsespec();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseEOL();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f0(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsespec_list();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseEOL();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f1(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecolor();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseEOL();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f2(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsemodel_list();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseEOL();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f3(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecolor_set_spec();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseEOL();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f4(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = [];
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
}
|
|
s1 = input.substring(s1, peg$currPos);
|
|
s1 = peg$f5(s1);
|
|
s0 = s1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecolor_set_spec() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecolor_set_item();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 59) {
|
|
s4 = peg$c0;
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e1);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsecolor_set_item();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f6(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 59) {
|
|
s4 = peg$c0;
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e1);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsecolor_set_item();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f6(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s0 = peg$f7(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecolor_set_item() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsename();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 44) {
|
|
s2 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsespec_list();
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f8(s1, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsemodel_list() {
|
|
var s0, s1, s2, s3;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecore_model();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 58) {
|
|
s2 = peg$c2;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e4);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsemodel_list_tail();
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f9(s1, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsemodel_list_tail();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f10(s1);
|
|
}
|
|
s0 = s1;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsemodel_list_tail() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsemodel();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 47) {
|
|
s4 = peg$c3;
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemodel();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f11(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 47) {
|
|
s4 = peg$c3;
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsemodel();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f11(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s0 = peg$f12(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsemodel() {
|
|
var s0;
|
|
peg$silentFails++;
|
|
s0 = peg$parsecore_model();
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e6);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsespec_list() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsespec();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 47) {
|
|
s4 = peg$c3;
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsespec();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f13(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 47) {
|
|
s4 = peg$c3;
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsespec();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f13(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
s0 = peg$f14(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e7);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsespec() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$currPos;
|
|
s3 = peg$parsehex();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parsehex();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsehex();
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parsehex();
|
|
if (s6 !== peg$FAILED) {
|
|
s7 = peg$parsehex();
|
|
if (s7 !== peg$FAILED) {
|
|
s8 = peg$parsehex();
|
|
if (s8 !== peg$FAILED) {
|
|
s3 = [s3, s4, s5, s6, s7, s8];
|
|
s2 = s3;
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
} 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) {
|
|
s1 = peg$f15(s1);
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsedec();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 44) {
|
|
s4 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsedec();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f16(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 44) {
|
|
s4 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsedec();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f16(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 === peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$currPos;
|
|
s4 = peg$parsesp();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsedec();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f17(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$currPos;
|
|
s4 = peg$parsesp();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parsedec();
|
|
if (s5 !== peg$FAILED) {
|
|
s3 = peg$f17(s1, s5);
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s3;
|
|
s3 = peg$FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
}
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
s0 = peg$f18(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e8);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecolor() {
|
|
var s0, s1, s2, s3;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecolor_expr();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parsefunc_expr();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsefunc_expr();
|
|
}
|
|
s0 = peg$f19(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e9);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecolor_expr() {
|
|
var s0;
|
|
s0 = peg$parseext_expr();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parseexpr();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$parsename();
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsefunc_expr() {
|
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 62) {
|
|
s1 = peg$c4;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e11);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsefunction();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 44) {
|
|
s5 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parseint();
|
|
if (s6 !== peg$FAILED) {
|
|
s4 = peg$f20(s2, s6);
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 44) {
|
|
s5 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parseint();
|
|
if (s6 !== peg$FAILED) {
|
|
s4 = peg$f20(s2, s6);
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
}
|
|
s0 = peg$f21(s2, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e10);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsefunction() {
|
|
var s0;
|
|
peg$silentFails++;
|
|
s0 = peg$parsename();
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e12);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseext_expr() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecore_model();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 44) {
|
|
s2 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsediv();
|
|
if (s3 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 58) {
|
|
s4 = peg$c2;
|
|
peg$currPos++;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e4);
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parseweighted_expr();
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = [];
|
|
s7 = peg$parseadditional_weighted_expr();
|
|
while (s7 !== peg$FAILED) {
|
|
s6.push(s7);
|
|
s7 = peg$parseadditional_weighted_expr();
|
|
}
|
|
s0 = peg$f22(s1, s3, s5, s6);
|
|
} 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;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecore_model();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 58) {
|
|
s2 = peg$c2;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e4);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parseweighted_expr();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$parseadditional_weighted_expr();
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$parseadditional_weighted_expr();
|
|
}
|
|
s0 = peg$f23(s1, s3, s4);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e13);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseweighted_expr() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseexpr();
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 44) {
|
|
s2 = peg$c1;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsedec();
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f24(s1, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseadditional_weighted_expr() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 59) {
|
|
s1 = peg$c0;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e1);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseweighted_expr();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f25(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecore_model() {
|
|
var s0;
|
|
peg$silentFails++;
|
|
s0 = peg$parsename();
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e14);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseexpr() {
|
|
var s0, s1, s2, s3, s4;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseprefix();
|
|
s2 = peg$parsename();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsemix_expr();
|
|
s4 = peg$parsepostfix();
|
|
if (s4 === peg$FAILED) {
|
|
s4 = null;
|
|
}
|
|
s0 = peg$f26(s1, s2, s3, s4);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e15);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecomplete_mix() {
|
|
var s0, s1, s2, s3, s4;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 33) {
|
|
s1 = peg$c5;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e16);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsepct();
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 33) {
|
|
s3 = peg$c5;
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e16);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parsename();
|
|
if (s4 !== peg$FAILED) {
|
|
s0 = peg$f27(s2, s4);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsepartial_mix() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 33) {
|
|
s1 = peg$c5;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e16);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsepct();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f28(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsemix_expr() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsecomplete_mix();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsecomplete_mix();
|
|
}
|
|
s2 = peg$parsepartial_mix();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
s0 = peg$f29(s1, s2);
|
|
peg$silentFails--;
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e17);
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsename() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
if (input.charCodeAt(peg$currPos) === 46) {
|
|
s0 = peg$c6;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e19);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s0 = input.substring(s0, peg$currPos);
|
|
} else {
|
|
s0 = s1;
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e18);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsepostfix() {
|
|
var s0, s1, s2, s3, s4;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.substr(peg$currPos, 3) === peg$c7) {
|
|
s1 = peg$c7;
|
|
peg$currPos += 3;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e22);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsenum();
|
|
if (s2 !== peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 93) {
|
|
s3 = peg$c8;
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e23);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f30(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.substr(peg$currPos, 2) === peg$c9) {
|
|
s1 = peg$c9;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e24);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$currPos;
|
|
s3 = [];
|
|
s4 = peg$parseplus();
|
|
if (s4 !== peg$FAILED) {
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parseplus();
|
|
}
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s2 = input.substring(s2, peg$currPos);
|
|
} else {
|
|
s2 = s3;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f31(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e21);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseprefix() {
|
|
var s0;
|
|
peg$silentFails++;
|
|
s0 = peg$parseminus();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = null;
|
|
}
|
|
peg$silentFails--;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e25);
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseplus() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
if (input.charCodeAt(peg$currPos) === 43) {
|
|
s2 = peg$c10;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e27);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
if (input.charCodeAt(peg$currPos) === 43) {
|
|
s2 = peg$c10;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e27);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s0 = input.substring(s0, peg$currPos);
|
|
} else {
|
|
s0 = s1;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e26);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseminus() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
if (input.charCodeAt(peg$currPos) === 45) {
|
|
s2 = peg$c11;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e29);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
if (input.charCodeAt(peg$currPos) === 45) {
|
|
s2 = peg$c11;
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e29);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s0 = input.substring(s0, peg$currPos);
|
|
} else {
|
|
s0 = s1;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e28);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsenum() {
|
|
var s0, s1, s2, s3;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = [];
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e31);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e31);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = input.substring(s1, peg$currPos);
|
|
} else {
|
|
s1 = s2;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f32(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e30);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsepct() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$currPos;
|
|
s3 = peg$currPos;
|
|
s4 = [];
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e31);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e31);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s3 = input.substring(s3, peg$currPos);
|
|
} else {
|
|
s3 = s4;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$currPos;
|
|
s5 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 46) {
|
|
s6 = peg$c6;
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e19);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s7 = peg$currPos;
|
|
s8 = [];
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s9 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s9 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e31);
|
|
}
|
|
}
|
|
while (s9 !== peg$FAILED) {
|
|
s8.push(s9);
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s9 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s9 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e31);
|
|
}
|
|
}
|
|
}
|
|
s7 = input.substring(s7, peg$currPos);
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 === peg$FAILED) {
|
|
s5 = null;
|
|
}
|
|
s4 = input.substring(s4, peg$currPos);
|
|
s3 = [s3, s4];
|
|
s2 = s3;
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = input.substring(s1, peg$currPos);
|
|
} else {
|
|
s1 = s2;
|
|
}
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$currPos;
|
|
s2 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 46) {
|
|
s3 = peg$c6;
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e19);
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$currPos;
|
|
s5 = [];
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e31);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
while (s6 !== peg$FAILED) {
|
|
s5.push(s6);
|
|
if (peg$r1.test(input.charAt(peg$currPos))) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e31);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
s4 = input.substring(s4, peg$currPos);
|
|
} else {
|
|
s4 = s5;
|
|
}
|
|
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) {
|
|
s1 = peg$f33(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e32);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsediv() {
|
|
var s0;
|
|
peg$silentFails++;
|
|
s0 = peg$parsepct();
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e33);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedec() {
|
|
var s0, s1, s2;
|
|
s0 = peg$parsepct();
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 43) {
|
|
s1 = peg$c10;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e27);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsepct();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f34(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
if (input.charCodeAt(peg$currPos) === 45) {
|
|
s1 = peg$c11;
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e29);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsepct();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f35(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseint() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseminus();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = null;
|
|
}
|
|
s2 = peg$parsenum();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f36(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e34);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesp() {
|
|
var s0, s1;
|
|
s0 = [];
|
|
if (peg$r2.test(input.charAt(peg$currPos))) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e36);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
while (s1 !== peg$FAILED) {
|
|
s0.push(s1);
|
|
if (peg$r2.test(input.charAt(peg$currPos))) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e36);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsehex() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
if (peg$r3.test(input.charAt(peg$currPos))) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e37);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f37(s1);
|
|
}
|
|
s0 = s1;
|
|
return s0;
|
|
}
|
|
function peg$parseEOL() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s1 === peg$FAILED) {
|
|
s0 = void 0;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _TabularPegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { body: peg$parsebody };
|
|
var peg$startRuleFunction = peg$parsebody;
|
|
var peg$e0 = peg$otherExpectation("decl_start");
|
|
var peg$e1 = peg$otherExpectation("decl_end");
|
|
var peg$e2 = peg$otherExpectation("vert");
|
|
var peg$e3 = peg$anyExpectation();
|
|
var peg$e4 = peg$otherExpectation("l");
|
|
var peg$e5 = peg$otherExpectation("r");
|
|
var peg$e6 = peg$otherExpectation("c");
|
|
var peg$e7 = peg$otherExpectation("p");
|
|
var peg$e8 = peg$otherExpectation("m");
|
|
var peg$e9 = peg$otherExpectation("b");
|
|
var peg$e10 = peg$otherExpectation("w");
|
|
var peg$e11 = peg$otherExpectation("W");
|
|
var peg$e12 = peg$otherExpectation("X");
|
|
var peg$e13 = peg$otherExpectation("!");
|
|
var peg$e14 = peg$otherExpectation("@");
|
|
var peg$e15 = peg$otherExpectation("<");
|
|
var peg$e16 = peg$otherExpectation(">");
|
|
var peg$e17 = peg$otherExpectation("group");
|
|
var peg$e18 = peg$otherExpectation("whitespace");
|
|
var peg$f0 = function(c) {
|
|
return c;
|
|
};
|
|
var peg$f1 = function(cols) {
|
|
return cols;
|
|
};
|
|
var peg$f2 = function() {
|
|
return [];
|
|
};
|
|
var peg$f3 = function(divs1, start, a, end, divs2) {
|
|
return {
|
|
type: "column",
|
|
pre_dividers: divs1,
|
|
post_dividers: divs2,
|
|
before_start_code: start,
|
|
before_end_code: end,
|
|
alignment: a
|
|
};
|
|
};
|
|
var peg$f4 = function() {
|
|
return {
|
|
type: "vert_divider"
|
|
};
|
|
};
|
|
var peg$f5 = function(b, g) {
|
|
return {
|
|
type: "bang_divider",
|
|
content: g[0].content
|
|
};
|
|
};
|
|
var peg$f6 = function(g) {
|
|
return {
|
|
type: "at_divider",
|
|
content: g[0].content
|
|
};
|
|
};
|
|
var peg$f7 = function(div) {
|
|
return div;
|
|
};
|
|
var peg$f8 = function(g) {
|
|
return { type: "decl_code", code: g[0].content };
|
|
};
|
|
var peg$f9 = function(g) {
|
|
return { type: "decl_code", code: g[0].content };
|
|
};
|
|
var peg$f10 = function() {
|
|
return { type: "alignment", alignment: "left" };
|
|
};
|
|
var peg$f11 = function() {
|
|
return { type: "alignment", alignment: "center" };
|
|
};
|
|
var peg$f12 = function() {
|
|
return { type: "alignment", alignment: "right" };
|
|
};
|
|
var peg$f13 = function() {
|
|
return { type: "alignment", alignment: "X" };
|
|
};
|
|
var peg$f14 = function() {
|
|
return "top";
|
|
};
|
|
var peg$f15 = function() {
|
|
return "default";
|
|
};
|
|
var peg$f16 = function() {
|
|
return "bottom";
|
|
};
|
|
var peg$f17 = function(a, g) {
|
|
return {
|
|
type: "alignment",
|
|
alignment: "parbox",
|
|
baseline: a,
|
|
size: g[0].content
|
|
};
|
|
};
|
|
var peg$f18 = function(g1, g2) {
|
|
return {
|
|
type: "alignment",
|
|
alignment: "parbox",
|
|
baseline: g1[0].content,
|
|
size: g2[0].content
|
|
};
|
|
};
|
|
var peg$f19 = function(tok) {
|
|
return options.matchChar(tok, "|");
|
|
};
|
|
var peg$f20 = function(tok) {
|
|
return options.matchChar(tok, "l");
|
|
};
|
|
var peg$f21 = function(tok) {
|
|
return options.matchChar(tok, "r");
|
|
};
|
|
var peg$f22 = function(tok) {
|
|
return options.matchChar(tok, "c");
|
|
};
|
|
var peg$f23 = function(tok) {
|
|
return options.matchChar(tok, "p");
|
|
};
|
|
var peg$f24 = function(tok) {
|
|
return options.matchChar(tok, "m");
|
|
};
|
|
var peg$f25 = function(tok) {
|
|
return options.matchChar(tok, "b");
|
|
};
|
|
var peg$f26 = function(tok) {
|
|
return options.matchChar(tok, "w");
|
|
};
|
|
var peg$f27 = function(tok) {
|
|
return options.matchChar(tok, "W");
|
|
};
|
|
var peg$f28 = function(tok) {
|
|
return options.matchChar(tok, "X");
|
|
};
|
|
var peg$f29 = function(tok) {
|
|
return options.matchChar(tok, "!");
|
|
};
|
|
var peg$f30 = function(tok) {
|
|
return options.matchChar(tok, "@");
|
|
};
|
|
var peg$f31 = function(tok) {
|
|
return options.matchChar(tok, "<");
|
|
};
|
|
var peg$f32 = function(tok) {
|
|
return options.matchChar(tok, ">");
|
|
};
|
|
var peg$f33 = function(tok) {
|
|
return options.isGroup(tok);
|
|
};
|
|
var peg$f34 = function(tok) {
|
|
return options.isWhitespace(tok);
|
|
};
|
|
var peg$currPos = 0;
|
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
var peg$maxFailPos = 0;
|
|
var peg$maxFailExpected = [];
|
|
var peg$silentFails = 0;
|
|
var peg$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
function peg$otherExpectation(description) {
|
|
return { type: "other", 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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parsebody() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$currPos;
|
|
s3 = peg$parsecolumn();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$parse_();
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$parse_();
|
|
}
|
|
s2 = peg$f0(s3);
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$currPos;
|
|
s3 = peg$parsecolumn();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$parse_();
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$parse_();
|
|
}
|
|
s2 = peg$f0(s3);
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f1(s1);
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseEOL();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f2();
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecolumn() {
|
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsecolumn_divider();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsecolumn_divider();
|
|
}
|
|
s2 = peg$parsedecl_start();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
s3 = peg$parsealignment();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parsedecl_end();
|
|
if (s4 === peg$FAILED) {
|
|
s4 = null;
|
|
}
|
|
s5 = [];
|
|
s6 = peg$parsecolumn_divider();
|
|
while (s6 !== peg$FAILED) {
|
|
s5.push(s6);
|
|
s6 = peg$parsecolumn_divider();
|
|
}
|
|
s0 = peg$f3(s1, s2, s3, s4, s5);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecolumn_divider() {
|
|
var s0, s1, s2, s3, s4;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parse_();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parse_();
|
|
}
|
|
s2 = peg$currPos;
|
|
s3 = peg$parsevert();
|
|
if (s3 !== peg$FAILED) {
|
|
s3 = peg$f4();
|
|
}
|
|
s2 = s3;
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$currPos;
|
|
s3 = peg$parsebang();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parsegroup();
|
|
if (s4 !== peg$FAILED) {
|
|
s2 = peg$f5(s3, s4);
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$currPos;
|
|
s3 = peg$parseat();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parsegroup();
|
|
if (s4 !== peg$FAILED) {
|
|
s2 = peg$f6(s4);
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parse_();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parse_();
|
|
}
|
|
s0 = peg$f7(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedecl_start() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsegreater();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsegroup();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f8(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedecl_end() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseless();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsegroup();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f9(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e1);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsealignment() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsel();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f10();
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsec();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f11();
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parser();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f12();
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseX();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f13();
|
|
}
|
|
s0 = s1;
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$parsep();
|
|
if (s2 !== peg$FAILED) {
|
|
s2 = peg$f14();
|
|
}
|
|
s1 = s2;
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$currPos;
|
|
s2 = peg$parsem();
|
|
if (s2 !== peg$FAILED) {
|
|
s2 = peg$f15();
|
|
}
|
|
s1 = s2;
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$currPos;
|
|
s2 = peg$parseb();
|
|
if (s2 !== peg$FAILED) {
|
|
s2 = peg$f16();
|
|
}
|
|
s1 = s2;
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parse_();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parse_();
|
|
}
|
|
s3 = peg$parsegroup();
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f17(s1, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsew();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parseW();
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parse_();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parse_();
|
|
}
|
|
s3 = peg$parsegroup();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$parse_();
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$parse_();
|
|
}
|
|
s5 = peg$parsegroup();
|
|
if (s5 !== peg$FAILED) {
|
|
s0 = peg$f18(s3, s5);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsevert() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f19(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsel() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f20(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e4);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parser() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f21(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsec() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f22(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e6);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsep() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f23(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e7);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsem() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f24(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e8);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseb() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f25(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e9);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsew() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f26(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e10);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseW() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f27(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e11);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseX() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f28(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e12);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsebang() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f29(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e13);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseat() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f30(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e14);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseless() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f31(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e15);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsegreater() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f32(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e16);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsegroup() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f33(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e17);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parse_() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f34(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e18);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseEOL() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s1 === peg$FAILED) {
|
|
s0 = void 0;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
if (!options.isHash) {
|
|
try {
|
|
Object.assign(options, {
|
|
matchChar: (node, char) => node.type === "string" && node.content === char,
|
|
isGroup: (node) => node.type === "group",
|
|
isWhitespace: (node) => node.type === "whitespace"
|
|
});
|
|
} catch (e) {
|
|
console.warn("Error when initializing parser", e);
|
|
}
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _SystemePegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { body: peg$parsebody };
|
|
var peg$startRuleFunction = peg$parsebody;
|
|
var peg$e1 = peg$otherExpectation("item");
|
|
var peg$e2 = peg$anyExpectation();
|
|
var peg$e3 = peg$otherExpectation("equation");
|
|
var peg$e4 = peg$otherExpectation("trailing comment");
|
|
var peg$e5 = peg$otherExpectation("comment only line");
|
|
var peg$e6 = peg$otherExpectation("non-var token");
|
|
var peg$e7 = peg$otherExpectation("token");
|
|
var peg$e8 = peg$otherExpectation("same line comment");
|
|
var peg$e9 = peg$otherExpectation("own line comment");
|
|
var peg$e10 = peg$otherExpectation(",");
|
|
var peg$e11 = peg$otherExpectation("@");
|
|
var peg$e12 = peg$otherExpectation("variable token");
|
|
var peg$e13 = peg$otherExpectation("+/-");
|
|
var peg$e14 = peg$otherExpectation("=");
|
|
var peg$f0 = function(a, b) {
|
|
return a.concat(b ? b : []);
|
|
};
|
|
var peg$f1 = function() {
|
|
return [];
|
|
};
|
|
var peg$f3 = function(op, a, b, c) {
|
|
return { type: "item", op, variable: b, content: a.concat(b, c) };
|
|
};
|
|
var peg$f4 = function(op, a) {
|
|
return { type: "item", op, variable: null, content: a };
|
|
};
|
|
var peg$f5 = function(line, sep, comment) {
|
|
return { ...line, sep: [].concat(sep), trailingComment: comment };
|
|
};
|
|
var peg$f6 = function(line, comment) {
|
|
return { ...line, trailingComment: comment };
|
|
};
|
|
var peg$f7 = function(eq, ann) {
|
|
return {
|
|
type: "line",
|
|
equation: eq,
|
|
annotation: ann,
|
|
sep: null
|
|
};
|
|
};
|
|
var peg$f8 = function(at, ann) {
|
|
return at ? { type: "annotation", marker: at, content: ann } : null;
|
|
};
|
|
var peg$f9 = function(left, eq, right) {
|
|
return { type: "equation", left, right, equals: eq };
|
|
};
|
|
var peg$f10 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f11 = function(x) {
|
|
return {
|
|
type: "line",
|
|
trailingComment: x
|
|
};
|
|
};
|
|
var peg$f12 = function(v, s) {
|
|
return [v].concat(s ? s : []);
|
|
};
|
|
var peg$f13 = function(t) {
|
|
return t;
|
|
};
|
|
var peg$f14 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f15 = function(x) {
|
|
return x;
|
|
};
|
|
var peg$f16 = function(tok) {
|
|
return options.isSameLineComment(tok);
|
|
};
|
|
var peg$f17 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f18 = function(tok) {
|
|
return options.isOwnLineComment(tok);
|
|
};
|
|
var peg$f19 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f20 = function(tok) {
|
|
return options.isWhitespace(tok);
|
|
};
|
|
var peg$f21 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f22 = function(tok) {
|
|
return options.isSep(tok);
|
|
};
|
|
var peg$f23 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f24 = function(tok) {
|
|
return options.isAt(tok);
|
|
};
|
|
var peg$f25 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f26 = function(tok) {
|
|
return options.isVar(tok);
|
|
};
|
|
var peg$f27 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f28 = function(tok) {
|
|
return options.isOperation(tok);
|
|
};
|
|
var peg$f29 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f30 = function(tok) {
|
|
return options.isEquals(tok);
|
|
};
|
|
var peg$f31 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f32 = function(tok) {
|
|
return options.isSubscript(tok);
|
|
};
|
|
var peg$f33 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$currPos = 0;
|
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
var peg$maxFailPos = 0;
|
|
var peg$maxFailExpected = [];
|
|
var peg$silentFails = 0;
|
|
var peg$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
function peg$otherExpectation(description) {
|
|
return { type: "other", 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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parsebody() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parsecomment_only_line();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseline_with_sep();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsepartial_line_with_comment();
|
|
}
|
|
}
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parsecomment_only_line();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseline_with_sep();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsepartial_line_with_comment();
|
|
}
|
|
}
|
|
}
|
|
s2 = peg$parseline_without_sep();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseEOL();
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f0(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseEOL();
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f1();
|
|
}
|
|
s0 = s1;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseitem() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseoperation();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = null;
|
|
}
|
|
s2 = [];
|
|
s3 = peg$parse_();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parse_();
|
|
}
|
|
s3 = [];
|
|
s4 = peg$parsenon_var_token();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsenon_var_token();
|
|
}
|
|
s4 = [];
|
|
s5 = peg$parse_();
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$parse_();
|
|
}
|
|
s5 = peg$parsevar();
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = [];
|
|
s7 = peg$parse_();
|
|
while (s7 !== peg$FAILED) {
|
|
s6.push(s7);
|
|
s7 = peg$parse_();
|
|
}
|
|
s7 = [];
|
|
s8 = peg$parsetoken();
|
|
while (s8 !== peg$FAILED) {
|
|
s7.push(s8);
|
|
s8 = peg$parsetoken();
|
|
}
|
|
s8 = [];
|
|
s9 = peg$parse_();
|
|
while (s9 !== peg$FAILED) {
|
|
s8.push(s9);
|
|
s9 = peg$parse_();
|
|
}
|
|
s0 = peg$f3(s1, s3, s5, s7);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseoperation();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = null;
|
|
}
|
|
s2 = [];
|
|
s3 = peg$parse_();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parse_();
|
|
}
|
|
s3 = [];
|
|
s4 = peg$parsenon_var_token();
|
|
if (s4 !== peg$FAILED) {
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsenon_var_token();
|
|
}
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$parse_();
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$parse_();
|
|
}
|
|
s0 = peg$f4(s1, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e1);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseline_with_sep() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseline_without_sep();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsesep();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsetrailing_comment();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s0 = peg$f5(s1, s2, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsepartial_line_with_comment() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseline_without_sep();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsetrailing_comment();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f6(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseline_without_sep() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s2 !== peg$FAILED) {
|
|
peg$currPos = s1;
|
|
s1 = void 0;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseequation();
|
|
s3 = peg$parseannotation();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s0 = peg$f7(s2, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseannotation() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseat();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parsenon_sep_token();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parsenon_sep_token();
|
|
}
|
|
s0 = peg$f8(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseequation() {
|
|
var s0, s1, s2, s3, s4;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parseitem();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parseitem();
|
|
}
|
|
s2 = peg$parseequals();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
s3 = [];
|
|
s4 = peg$parsetoken();
|
|
if (s4 === peg$FAILED) {
|
|
s4 = peg$parseoperation();
|
|
}
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parsetoken();
|
|
if (s4 === peg$FAILED) {
|
|
s4 = peg$parseoperation();
|
|
}
|
|
}
|
|
s0 = peg$f9(s1, s2, s3);
|
|
peg$silentFails--;
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsetrailing_comment() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parse_();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parse_();
|
|
}
|
|
s2 = peg$parsesame_line_comment();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f10(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e4);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecomment_only_line() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parse_();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parse_();
|
|
}
|
|
s2 = peg$parseown_line_comment();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f11(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsevar() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsevar_token();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
s3 = peg$parse_();
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
s3 = peg$parse_();
|
|
}
|
|
s3 = peg$parsesubscript();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s0 = peg$f12(s1, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsenon_var_token() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
peg$silentFails++;
|
|
s2 = peg$parsevar();
|
|
peg$silentFails--;
|
|
if (s2 === peg$FAILED) {
|
|
s1 = void 0;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsetoken();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f13(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e6);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsenon_sep_token() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
peg$silentFails++;
|
|
s2 = peg$parsesep();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsetrailing_comment();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseown_line_comment();
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s2 === peg$FAILED) {
|
|
s1 = void 0;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f14(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsetoken() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
peg$silentFails++;
|
|
s2 = peg$parsesep();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseat();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseoperation();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseequals();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parsetrailing_comment();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = peg$parseown_line_comment();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s2 === peg$FAILED) {
|
|
s1 = void 0;
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f15(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e7);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesame_line_comment() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f16(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f17(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e8);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseown_line_comment() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f18(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f19(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e9);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parse_() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f20(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f21(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesep() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f22(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f23(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e10);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseat() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f24(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f25(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e11);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsevar_token() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f26(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f27(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e12);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseoperation() {
|
|
var s0, s1, s2, s3, s4;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parse_();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parse_();
|
|
}
|
|
if (input.length > peg$currPos) {
|
|
s2 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = [];
|
|
s4 = peg$parse_();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parse_();
|
|
}
|
|
s4 = peg$f28(s2);
|
|
if (s4) {
|
|
s4 = void 0;
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s0 = peg$f29(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e13);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseequals() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f30(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f31(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e14);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesubscript() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f32(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f33(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseEOL() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
peg$silentFails++;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
peg$silentFails--;
|
|
if (s1 === peg$FAILED) {
|
|
s0 = void 0;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
if (!options.isWhitespace) {
|
|
try {
|
|
Object.assign(options, {
|
|
isSep: (node) => node.type === "string" && node.content === ",",
|
|
isVar: (node) => node.type === "string" && node.content.match(/[a-zA-Z]/),
|
|
isOperation: (node) => node.type === "string" && node.content.match(/[+-]/),
|
|
isEquals: (node) => node.type === "string" && node.content === "=",
|
|
isAt: (node) => node.type === "string" && node.content === "@",
|
|
isSubscript: (node) => node.content === "_",
|
|
isWhitespace: (node) => node.type === "whitespace",
|
|
isSameLineComment: (node) => node.type === "comment" && node.sameline,
|
|
isOwnLineComment: (node) => node.type === "comment" && !node.sameline
|
|
});
|
|
} catch (e) {
|
|
console.warn("Error when initializing parser", e);
|
|
}
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _GluePegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { root: peg$parseroot };
|
|
var peg$startRuleFunction = peg$parseroot;
|
|
var peg$c0 = "plus";
|
|
var peg$c1 = "minus";
|
|
var peg$c2 = "pt";
|
|
var peg$c3 = "mm";
|
|
var peg$c4 = "cm";
|
|
var peg$c5 = "in";
|
|
var peg$c6 = "ex";
|
|
var peg$c7 = "em";
|
|
var peg$c8 = "bp";
|
|
var peg$c9 = "pc";
|
|
var peg$c10 = "dd";
|
|
var peg$c11 = "cc";
|
|
var peg$c12 = "nd";
|
|
var peg$c13 = "nc";
|
|
var peg$c14 = "sp";
|
|
var peg$c15 = "filll";
|
|
var peg$c16 = "fill";
|
|
var peg$c17 = "fil";
|
|
var peg$c18 = ".";
|
|
var peg$c19 = "+";
|
|
var peg$c20 = "-";
|
|
var peg$r0 = /^[0-9]/;
|
|
var peg$e0 = peg$anyExpectation();
|
|
var peg$e1 = peg$literalExpectation("plus", false);
|
|
var peg$e2 = peg$literalExpectation("minus", false);
|
|
var peg$e3 = peg$literalExpectation("pt", false);
|
|
var peg$e4 = peg$literalExpectation("mm", false);
|
|
var peg$e5 = peg$literalExpectation("cm", false);
|
|
var peg$e6 = peg$literalExpectation("in", false);
|
|
var peg$e7 = peg$literalExpectation("ex", false);
|
|
var peg$e8 = peg$literalExpectation("em", false);
|
|
var peg$e9 = peg$literalExpectation("bp", false);
|
|
var peg$e10 = peg$literalExpectation("pc", false);
|
|
var peg$e11 = peg$literalExpectation("dd", false);
|
|
var peg$e12 = peg$literalExpectation("cc", false);
|
|
var peg$e13 = peg$literalExpectation("nd", false);
|
|
var peg$e14 = peg$literalExpectation("nc", false);
|
|
var peg$e15 = peg$literalExpectation("sp", false);
|
|
var peg$e16 = peg$literalExpectation("filll", false);
|
|
var peg$e17 = peg$literalExpectation("fill", false);
|
|
var peg$e18 = peg$literalExpectation("fil", false);
|
|
var peg$e19 = peg$otherExpectation("number");
|
|
var peg$e20 = peg$classExpectation([["0", "9"]], false, false);
|
|
var peg$e21 = peg$literalExpectation(".", false);
|
|
var peg$e22 = peg$literalExpectation("+", false);
|
|
var peg$e23 = peg$literalExpectation("-", false);
|
|
var peg$f0 = function(b, st, sh) {
|
|
return {
|
|
type: "glue",
|
|
fixed: b,
|
|
stretchable: st,
|
|
shrinkable: sh,
|
|
position: location()
|
|
};
|
|
};
|
|
var peg$f1 = function(glue) {
|
|
return glue;
|
|
};
|
|
var peg$f2 = function(n, u) {
|
|
return { type: "dim", value: n, unit: u };
|
|
};
|
|
var peg$f3 = function(n, u) {
|
|
return { type: "dim", value: n, unit: u };
|
|
};
|
|
var peg$f4 = function(n, u) {
|
|
return { type: "dim", value: n, unit: u };
|
|
};
|
|
var peg$f5 = function(n) {
|
|
return parseFloat(n);
|
|
};
|
|
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$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function location() {
|
|
return peg$computeLocation(peg$savedPos, peg$currPos);
|
|
}
|
|
function peg$literalExpectation(text2, ignoreCase) {
|
|
return { type: "literal", text: text2, ignoreCase };
|
|
}
|
|
function peg$classExpectation(parts, inverted, ignoreCase) {
|
|
return { type: "class", parts, inverted, ignoreCase };
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
function peg$otherExpectation(description) {
|
|
return { type: "other", 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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parseroot() {
|
|
var s0, s1, s2, s3, s4;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$parsebase();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parsestretchable();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s4 = peg$parseshrinkable();
|
|
if (s4 === peg$FAILED) {
|
|
s4 = null;
|
|
}
|
|
peg$savedPos = s1;
|
|
s1 = peg$f0(s2, s3, s4);
|
|
} else {
|
|
peg$currPos = s1;
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = [];
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
while (s3 !== peg$FAILED) {
|
|
s2.push(s3);
|
|
if (input.length > peg$currPos) {
|
|
s3 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
}
|
|
peg$savedPos = s0;
|
|
s0 = peg$f1(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsebase() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsenumber();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseunit();
|
|
if (s2 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f2(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsestretchable() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
if (input.substr(peg$currPos, 4) === peg$c0) {
|
|
s1 = peg$c0;
|
|
peg$currPos += 4;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e1);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsenumber();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parserubber_unit();
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f3(s2, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseshrinkable() {
|
|
var s0, s1, s2, s3;
|
|
s0 = peg$currPos;
|
|
if (input.substr(peg$currPos, 5) === peg$c1) {
|
|
s1 = peg$c1;
|
|
peg$currPos += 5;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e2);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsenumber();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$parserubber_unit();
|
|
if (s3 !== peg$FAILED) {
|
|
peg$savedPos = s0;
|
|
s0 = peg$f4(s2, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseunit() {
|
|
var s0;
|
|
if (input.substr(peg$currPos, 2) === peg$c2) {
|
|
s0 = peg$c2;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c3) {
|
|
s0 = peg$c3;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e4);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c4) {
|
|
s0 = peg$c4;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c5) {
|
|
s0 = peg$c5;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e6);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c6) {
|
|
s0 = peg$c6;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e7);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c7) {
|
|
s0 = peg$c7;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e8);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c8) {
|
|
s0 = peg$c8;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e9);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c9) {
|
|
s0 = peg$c9;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e10);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c10) {
|
|
s0 = peg$c10;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e11);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c11) {
|
|
s0 = peg$c11;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e12);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c12) {
|
|
s0 = peg$c12;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e13);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c13) {
|
|
s0 = peg$c13;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e14);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 2) === peg$c14) {
|
|
s0 = peg$c14;
|
|
peg$currPos += 2;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e15);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parserubber_unit() {
|
|
var s0;
|
|
s0 = peg$parseunit();
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 5) === peg$c15) {
|
|
s0 = peg$c15;
|
|
peg$currPos += 5;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e16);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 4) === peg$c16) {
|
|
s0 = peg$c16;
|
|
peg$currPos += 4;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e17);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.substr(peg$currPos, 3) === peg$c17) {
|
|
s0 = peg$c17;
|
|
peg$currPos += 3;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e18);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsenumber() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$currPos;
|
|
s3 = peg$parsesign();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s4 = peg$currPos;
|
|
s5 = [];
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
while (s6 !== peg$FAILED) {
|
|
s5.push(s6);
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
}
|
|
if (input.charCodeAt(peg$currPos) === 46) {
|
|
s6 = peg$c18;
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e21);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s7 = [];
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s8 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s8 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
if (s8 !== peg$FAILED) {
|
|
while (s8 !== peg$FAILED) {
|
|
s7.push(s8);
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s8 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s8 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s5 = [s5, s6, s7];
|
|
s4 = s5;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 === peg$FAILED) {
|
|
s4 = [];
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
if (peg$r0.test(input.charAt(peg$currPos))) {
|
|
s5 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s5 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e20);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
s4 = peg$FAILED;
|
|
}
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
s3 = [s3, s4];
|
|
s2 = s3;
|
|
} 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$f5(s1);
|
|
}
|
|
s0 = s1;
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e19);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesign() {
|
|
var s0;
|
|
if (input.charCodeAt(peg$currPos) === 43) {
|
|
s0 = peg$c19;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e22);
|
|
}
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
if (input.charCodeAt(peg$currPos) === 45) {
|
|
s0 = peg$c20;
|
|
peg$currPos++;
|
|
} else {
|
|
s0 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e23);
|
|
}
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const _TikzPegParser = (
|
|
// Generated by Peggy 3.0.2.
|
|
//
|
|
// https://peggyjs.org/
|
|
function() {
|
|
function peg$subclass(child, parent) {
|
|
function C() {
|
|
this.constructor = child;
|
|
}
|
|
C.prototype = parent.prototype;
|
|
child.prototype = new C();
|
|
}
|
|
function peg$SyntaxError(message, expected, found, location) {
|
|
var self = Error.call(this, message);
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
}
|
|
self.expected = expected;
|
|
self.found = found;
|
|
self.location = location;
|
|
self.name = "SyntaxError";
|
|
return self;
|
|
}
|
|
peg$subclass(peg$SyntaxError, Error);
|
|
function peg$padEnd(str, targetLength, padString) {
|
|
padString = padString || " ";
|
|
if (str.length > targetLength) {
|
|
return str;
|
|
}
|
|
targetLength -= str.length;
|
|
padString += padString.repeat(targetLength);
|
|
return str + padString.slice(0, targetLength);
|
|
}
|
|
peg$SyntaxError.prototype.format = function(sources) {
|
|
var str = "Error: " + this.message;
|
|
if (this.location) {
|
|
var src = null;
|
|
var k;
|
|
for (k = 0; k < sources.length; k++) {
|
|
if (sources[k].source === this.location.source) {
|
|
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
break;
|
|
}
|
|
}
|
|
var s = this.location.start;
|
|
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
if (src) {
|
|
var e = this.location.end;
|
|
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
var line = src[s.line - 1];
|
|
var last = s.line === e.line ? e.column : line.length + 1;
|
|
var hatLen = last - s.column || 1;
|
|
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
} else {
|
|
str += "\n at " + loc;
|
|
}
|
|
}
|
|
return str;
|
|
};
|
|
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
var DESCRIBE_EXPECTATION_FNS = {
|
|
literal: function(expectation) {
|
|
return '"' + literalEscape(expectation.text) + '"';
|
|
},
|
|
class: function(expectation) {
|
|
var escapedParts = expectation.parts.map(function(part) {
|
|
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
});
|
|
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
},
|
|
any: function() {
|
|
return "any character";
|
|
},
|
|
end: function() {
|
|
return "end of input";
|
|
},
|
|
other: function(expectation) {
|
|
return expectation.description;
|
|
}
|
|
};
|
|
function hex(ch) {
|
|
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
}
|
|
function literalEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function classEscape(s) {
|
|
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
return "\\x0" + hex(ch);
|
|
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
return "\\x" + hex(ch);
|
|
});
|
|
}
|
|
function describeExpectation(expectation) {
|
|
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
}
|
|
function describeExpected(expected2) {
|
|
var descriptions = expected2.map(describeExpectation);
|
|
var i, j;
|
|
descriptions.sort();
|
|
if (descriptions.length > 0) {
|
|
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
if (descriptions[i - 1] !== descriptions[i]) {
|
|
descriptions[j] = descriptions[i];
|
|
j++;
|
|
}
|
|
}
|
|
descriptions.length = j;
|
|
}
|
|
switch (descriptions.length) {
|
|
case 1:
|
|
return descriptions[0];
|
|
case 2:
|
|
return descriptions[0] + " or " + descriptions[1];
|
|
default:
|
|
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
}
|
|
}
|
|
function describeFound(found2) {
|
|
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
}
|
|
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
};
|
|
function peg$parse(input, options) {
|
|
options = options !== void 0 ? options : {};
|
|
var peg$FAILED = {};
|
|
var peg$source = options.grammarSource;
|
|
var peg$startRuleFunctions = { path_spec: peg$parsepath_spec, foreach_body: peg$parseforeach_body };
|
|
var peg$startRuleFunction = peg$parsepath_spec;
|
|
var peg$e0 = peg$anyExpectation();
|
|
var peg$e3 = peg$otherExpectation("comment");
|
|
var peg$e4 = peg$otherExpectation("floating comment");
|
|
var peg$e5 = peg$otherExpectation("operation");
|
|
var peg$e6 = peg$otherExpectation("=");
|
|
var peg$f0 = function(v) {
|
|
return v;
|
|
};
|
|
var peg$f1 = function(ops) {
|
|
return { type: "path_spec", content: ops };
|
|
};
|
|
var peg$f2 = function(c1, op, comment) {
|
|
return { op, comment };
|
|
};
|
|
var peg$f3 = function(c1, ops, c2, body) {
|
|
const comments = [c1, ...ops.map((x) => x.comment), c2].filter(
|
|
(x) => x
|
|
);
|
|
const attribute = ops.map((x) => x.op.content.content).join(" ");
|
|
return {
|
|
type: "animation",
|
|
comments,
|
|
attribute,
|
|
content: body.content
|
|
};
|
|
};
|
|
var peg$f4 = function(start, b) {
|
|
return { ...b, start, type: "foreach" };
|
|
};
|
|
var peg$f5 = function(c1, variables, options2, c2, c3, list, c4, command) {
|
|
const comments = [c1, c2, c3, c4].filter((x) => x);
|
|
return {
|
|
type: "foreach_body",
|
|
variables,
|
|
options: options2 && options2.content,
|
|
list,
|
|
command,
|
|
comments
|
|
};
|
|
};
|
|
var peg$f6 = function(c1, options2, c2, body) {
|
|
const comments = [c1, c2].filter((x) => x);
|
|
return {
|
|
type: "svg_operation",
|
|
options: options2 && options2.content,
|
|
content: body,
|
|
comments
|
|
};
|
|
};
|
|
var peg$f7 = function(c1, c2, coord, c3, c4, x) {
|
|
return { coord: x, comment: c4 };
|
|
};
|
|
var peg$f8 = function(c1, c2, coord, c3, a, c5) {
|
|
const comments = [c1, c2, c3, a && a.comment, c5].filter((x) => x);
|
|
return {
|
|
type: "curve_to",
|
|
controls: a ? [coord, a.coord] : [coord],
|
|
comments
|
|
};
|
|
};
|
|
var peg$f9 = function() {
|
|
return { type: "line_to", command: "|-" };
|
|
};
|
|
var peg$f10 = function() {
|
|
return { type: "line_to", command: "-|" };
|
|
};
|
|
var peg$f11 = function() {
|
|
return { type: "line_to", command: "--" };
|
|
};
|
|
var peg$f12 = function(prefix, content) {
|
|
return { type: "coordinate", content, prefix };
|
|
};
|
|
var peg$f13 = function(content) {
|
|
return { type: "square_brace_group", content };
|
|
};
|
|
var peg$f14 = function(v) {
|
|
return { type: "unknown", content: v };
|
|
};
|
|
var peg$f19 = function(tok) {
|
|
return options.isComment(tok);
|
|
};
|
|
var peg$f20 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f21 = function(tok) {
|
|
return options.isWhitespace(tok);
|
|
};
|
|
var peg$f22 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f23 = function(c) {
|
|
return c;
|
|
};
|
|
var peg$f24 = function(tok) {
|
|
return options.isOperation(tok);
|
|
};
|
|
var peg$f25 = function(tok) {
|
|
return { type: "operation", content: tok };
|
|
};
|
|
var peg$f26 = function(tok) {
|
|
return options.isChar(tok, "=");
|
|
};
|
|
var peg$f27 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f28 = function(tok) {
|
|
return options.isChar(tok, "[");
|
|
};
|
|
var peg$f29 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f30 = function(tok) {
|
|
return options.isChar(tok, "]");
|
|
};
|
|
var peg$f31 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f32 = function(tok) {
|
|
return options.isChar(tok, "(");
|
|
};
|
|
var peg$f33 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f34 = function(tok) {
|
|
return options.isChar(tok, ")");
|
|
};
|
|
var peg$f35 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f36 = function(tok) {
|
|
return options.isChar(tok, "+");
|
|
};
|
|
var peg$f37 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f38 = function(tok) {
|
|
return options.isChar(tok, "-");
|
|
};
|
|
var peg$f39 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f40 = function(tok) {
|
|
return options.isChar(tok, "|");
|
|
};
|
|
var peg$f41 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f42 = function(tok) {
|
|
return options.isChar(tok, ".");
|
|
};
|
|
var peg$f43 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f44 = function(tok) {
|
|
return options.isChar(tok, "controls");
|
|
};
|
|
var peg$f45 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f46 = function(tok) {
|
|
return options.isChar(tok, "and");
|
|
};
|
|
var peg$f47 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f48 = function(tok) {
|
|
return options.isChar(tok, "svg");
|
|
};
|
|
var peg$f49 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f50 = function(tok) {
|
|
return options.isGroup(tok);
|
|
};
|
|
var peg$f51 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f52 = function(tok) {
|
|
return options.isAnyMacro(tok);
|
|
};
|
|
var peg$f53 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f54 = function(tok) {
|
|
return options.isChar(tok, "foreach");
|
|
};
|
|
var peg$f55 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f56 = function(tok) {
|
|
return options.isMacro(tok, "foreach");
|
|
};
|
|
var peg$f57 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f58 = function(tok) {
|
|
return options.isChar(tok, "in");
|
|
};
|
|
var peg$f59 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$f60 = function(tok) {
|
|
return options.isChar(tok, ":");
|
|
};
|
|
var peg$f61 = function(tok) {
|
|
return tok;
|
|
};
|
|
var peg$currPos = 0;
|
|
var peg$posDetailsCache = [{ line: 1, column: 1 }];
|
|
var peg$maxFailPos = 0;
|
|
var peg$maxFailExpected = [];
|
|
var peg$silentFails = 0;
|
|
var peg$result;
|
|
if ("startRule" in options) {
|
|
if (!(options.startRule in peg$startRuleFunctions)) {
|
|
throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
|
|
}
|
|
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|
}
|
|
function peg$anyExpectation() {
|
|
return { type: "any" };
|
|
}
|
|
function peg$endExpectation() {
|
|
return { type: "end" };
|
|
}
|
|
function peg$otherExpectation(description) {
|
|
return { type: "other", 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, offset2) {
|
|
var startPosDetails = peg$computePosDetails(startPos);
|
|
var endPosDetails = peg$computePosDetails(endPos);
|
|
var res = {
|
|
source: peg$source,
|
|
start: {
|
|
offset: startPos,
|
|
line: startPosDetails.line,
|
|
column: startPosDetails.column
|
|
},
|
|
end: {
|
|
offset: endPos,
|
|
line: endPosDetails.line,
|
|
column: endPosDetails.column
|
|
}
|
|
};
|
|
return res;
|
|
}
|
|
function peg$fail(expected2) {
|
|
if (peg$currPos < peg$maxFailPos) {
|
|
return;
|
|
}
|
|
if (peg$currPos > peg$maxFailPos) {
|
|
peg$maxFailPos = peg$currPos;
|
|
peg$maxFailExpected = [];
|
|
}
|
|
peg$maxFailExpected.push(expected2);
|
|
}
|
|
function peg$buildStructuredError(expected2, found, location2) {
|
|
return new peg$SyntaxError(
|
|
peg$SyntaxError.buildMessage(expected2, found),
|
|
expected2,
|
|
found,
|
|
location2
|
|
);
|
|
}
|
|
function peg$parsepath_spec() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$currPos;
|
|
s3 = peg$parsesquare_brace_group();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsecoordinate();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsecurve_to();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseline_to();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsesvg();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseforeach();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseoperation();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsecomment();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseanimation();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseunknown();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$parse_();
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$parse_();
|
|
}
|
|
s2 = peg$f0(s3);
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$currPos;
|
|
s3 = peg$parsesquare_brace_group();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsecoordinate();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsecurve_to();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseline_to();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsesvg();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseforeach();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseoperation();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parsecomment();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseanimation();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = peg$parseunknown();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = [];
|
|
s5 = peg$parse_();
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$parse_();
|
|
}
|
|
s2 = peg$f0(s3);
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f1(s1);
|
|
}
|
|
s0 = s1;
|
|
return s0;
|
|
}
|
|
function peg$parseanimation() {
|
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsecolon();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parse_comment_();
|
|
s3 = [];
|
|
s4 = peg$currPos;
|
|
s5 = peg$parseoperation();
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parse_comment_();
|
|
s4 = peg$f2(s2, s5, s6);
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
if (s4 !== peg$FAILED) {
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$currPos;
|
|
s5 = peg$parseoperation();
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parse_comment_();
|
|
s4 = peg$f2(s2, s5, s6);
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
}
|
|
} else {
|
|
s3 = peg$FAILED;
|
|
}
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parseequals();
|
|
if (s4 !== peg$FAILED) {
|
|
s5 = peg$parse_comment_();
|
|
s6 = peg$parsegroup();
|
|
if (s6 !== peg$FAILED) {
|
|
s0 = peg$f3(s2, s3, s5, s6);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseforeach() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseforeach_keyword();
|
|
if (s1 === peg$FAILED) {
|
|
s1 = peg$parseforeach_macro();
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseforeach_body();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f4(s1, s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseforeach_body() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parse_comment_();
|
|
s2 = peg$currPos;
|
|
s3 = [];
|
|
s4 = peg$currPos;
|
|
s5 = peg$currPos;
|
|
peg$silentFails++;
|
|
s6 = peg$parsein_keyword();
|
|
if (s6 === peg$FAILED) {
|
|
s6 = peg$parsesquare_brace_group();
|
|
}
|
|
peg$silentFails--;
|
|
if (s6 === peg$FAILED) {
|
|
s5 = void 0;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s5 = [s5, s6];
|
|
s4 = s5;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$currPos;
|
|
s5 = peg$currPos;
|
|
peg$silentFails++;
|
|
s6 = peg$parsein_keyword();
|
|
if (s6 === peg$FAILED) {
|
|
s6 = peg$parsesquare_brace_group();
|
|
}
|
|
peg$silentFails--;
|
|
if (s6 === peg$FAILED) {
|
|
s5 = void 0;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s5 = [s5, s6];
|
|
s4 = s5;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
}
|
|
s2 = input.substring(s2, peg$currPos);
|
|
s3 = peg$parsesquare_brace_group();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s4 = peg$parse_comment_();
|
|
s5 = peg$parsein_keyword();
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parse_comment_();
|
|
s7 = peg$parsegroup();
|
|
if (s7 === peg$FAILED) {
|
|
s7 = peg$parsemacro();
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s8 = peg$parse_comment_();
|
|
s9 = peg$parseforeach();
|
|
if (s9 === peg$FAILED) {
|
|
s9 = peg$parsegroup();
|
|
if (s9 === peg$FAILED) {
|
|
s9 = peg$parsemacro();
|
|
}
|
|
}
|
|
if (s9 !== peg$FAILED) {
|
|
s0 = peg$f5(s1, s2, s3, s4, s6, s7, s8, s9);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesvg() {
|
|
var s0, s1, s2, s3, s4, s5;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsesvg_keyword();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parse_comment_();
|
|
s3 = peg$parsesquare_brace_group();
|
|
if (s3 === peg$FAILED) {
|
|
s3 = null;
|
|
}
|
|
s4 = peg$parse_comment_();
|
|
s5 = peg$parsegroup();
|
|
if (s5 !== peg$FAILED) {
|
|
s0 = peg$f6(s2, s3, s4, s5);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecurve_to() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsedotdot();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parse_comment_();
|
|
s3 = peg$parsecontrols_keyword();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parse_comment_();
|
|
s5 = peg$parsecoordinate();
|
|
if (s5 !== peg$FAILED) {
|
|
s6 = peg$parse_comment_();
|
|
s7 = peg$currPos;
|
|
s8 = peg$parseand_keyword();
|
|
if (s8 !== peg$FAILED) {
|
|
s9 = peg$parse_comment_();
|
|
s10 = peg$parsecoordinate();
|
|
if (s10 !== peg$FAILED) {
|
|
s7 = peg$f7(s2, s4, s5, s6, s9, s10);
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s7;
|
|
s7 = peg$FAILED;
|
|
}
|
|
if (s7 === peg$FAILED) {
|
|
s7 = null;
|
|
}
|
|
s8 = peg$parse_comment_();
|
|
s9 = peg$parsedotdot();
|
|
if (s9 !== peg$FAILED) {
|
|
s0 = peg$f8(s2, s4, s5, s6, s7, s8);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseline_to() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsepipe();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseminus();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f9();
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseminus();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsepipe();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f10();
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
if (s0 === peg$FAILED) {
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseminus();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parseminus();
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f11();
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecoordinate() {
|
|
var s0, s1, s2, s3, s4, s5, s6, s7;
|
|
s0 = peg$currPos;
|
|
s1 = peg$currPos;
|
|
s2 = peg$currPos;
|
|
s3 = peg$parseplus();
|
|
if (s3 !== peg$FAILED) {
|
|
s4 = peg$parseplus();
|
|
if (s4 === peg$FAILED) {
|
|
s4 = null;
|
|
}
|
|
s3 = [s3, s4];
|
|
s2 = s3;
|
|
} else {
|
|
peg$currPos = s2;
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
s1 = input.substring(s1, peg$currPos);
|
|
s2 = peg$parseopen_paren();
|
|
if (s2 !== peg$FAILED) {
|
|
s3 = peg$currPos;
|
|
s4 = [];
|
|
s5 = peg$currPos;
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$parseclose_paren();
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s7 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
while (s5 !== peg$FAILED) {
|
|
s4.push(s5);
|
|
s5 = peg$currPos;
|
|
s6 = peg$currPos;
|
|
peg$silentFails++;
|
|
s7 = peg$parseclose_paren();
|
|
peg$silentFails--;
|
|
if (s7 === peg$FAILED) {
|
|
s6 = void 0;
|
|
} else {
|
|
peg$currPos = s6;
|
|
s6 = peg$FAILED;
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s7 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s7 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s7 !== peg$FAILED) {
|
|
s6 = [s6, s7];
|
|
s5 = s6;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
}
|
|
s3 = input.substring(s3, peg$currPos);
|
|
s4 = peg$parseclose_paren();
|
|
if (s4 !== peg$FAILED) {
|
|
s0 = peg$f12(s1, s3);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesquare_brace_group() {
|
|
var s0, s1, s2, s3, s4, s5, s6;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parseopen_square_brace();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$currPos;
|
|
s3 = [];
|
|
s4 = peg$currPos;
|
|
s5 = peg$currPos;
|
|
peg$silentFails++;
|
|
s6 = peg$parseclose_square_brace();
|
|
peg$silentFails--;
|
|
if (s6 === peg$FAILED) {
|
|
s5 = void 0;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s5 = [s5, s6];
|
|
s4 = s5;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$currPos;
|
|
s5 = peg$currPos;
|
|
peg$silentFails++;
|
|
s6 = peg$parseclose_square_brace();
|
|
peg$silentFails--;
|
|
if (s6 === peg$FAILED) {
|
|
s5 = void 0;
|
|
} else {
|
|
peg$currPos = s5;
|
|
s5 = peg$FAILED;
|
|
}
|
|
if (s5 !== peg$FAILED) {
|
|
if (input.length > peg$currPos) {
|
|
s6 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s6 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s6 !== peg$FAILED) {
|
|
s5 = [s5, s6];
|
|
s4 = s5;
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s4;
|
|
s4 = peg$FAILED;
|
|
}
|
|
}
|
|
s2 = input.substring(s2, peg$currPos);
|
|
s3 = peg$parseclose_square_brace();
|
|
if (s3 !== peg$FAILED) {
|
|
s0 = peg$f13(s2);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedotdot() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
s1 = peg$parsedot();
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$parsedot();
|
|
if (s2 !== peg$FAILED) {
|
|
s1 = [s1, s2];
|
|
s0 = s1;
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseunknown() {
|
|
var s0, s1;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s1 = peg$f14(s1);
|
|
}
|
|
s0 = s1;
|
|
return s0;
|
|
}
|
|
function peg$parsecomment() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f19(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f20(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e3);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parse_() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f21(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f22(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parse_comment_() {
|
|
var s0, s1, s2, s3, s4;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
s1 = [];
|
|
s2 = peg$parse_();
|
|
while (s2 !== peg$FAILED) {
|
|
s1.push(s2);
|
|
s2 = peg$parse_();
|
|
}
|
|
s2 = peg$parsecomment();
|
|
if (s2 === peg$FAILED) {
|
|
s2 = null;
|
|
}
|
|
s3 = [];
|
|
s4 = peg$parse_();
|
|
while (s4 !== peg$FAILED) {
|
|
s3.push(s4);
|
|
s4 = peg$parse_();
|
|
}
|
|
s0 = peg$f23(s2);
|
|
peg$silentFails--;
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e4);
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseoperation() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f24(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f25(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e5);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseequals() {
|
|
var s0, s1, s2;
|
|
peg$silentFails++;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f26(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f27(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
peg$silentFails--;
|
|
if (s0 === peg$FAILED) {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e6);
|
|
}
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseopen_square_brace() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f28(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f29(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseclose_square_brace() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f30(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f31(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseopen_paren() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f32(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f33(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseclose_paren() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f34(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f35(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseplus() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f36(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f37(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseminus() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f38(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f39(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsepipe() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f40(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f41(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsedot() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f42(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f43(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecontrols_keyword() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f44(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f45(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseand_keyword() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f46(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f47(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsesvg_keyword() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f48(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f49(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsegroup() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f50(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f51(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsemacro() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f52(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f53(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseforeach_keyword() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f54(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f55(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parseforeach_macro() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f56(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f57(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsein_keyword() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f58(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f59(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
function peg$parsecolon() {
|
|
var s0, s1, s2;
|
|
s0 = peg$currPos;
|
|
if (input.length > peg$currPos) {
|
|
s1 = input.charAt(peg$currPos);
|
|
peg$currPos++;
|
|
} else {
|
|
s1 = peg$FAILED;
|
|
if (peg$silentFails === 0) {
|
|
peg$fail(peg$e0);
|
|
}
|
|
}
|
|
if (s1 !== peg$FAILED) {
|
|
s2 = peg$f60(s1);
|
|
if (s2) {
|
|
s2 = void 0;
|
|
} else {
|
|
s2 = peg$FAILED;
|
|
}
|
|
if (s2 !== peg$FAILED) {
|
|
s0 = peg$f61(s1);
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
} else {
|
|
peg$currPos = s0;
|
|
s0 = peg$FAILED;
|
|
}
|
|
return s0;
|
|
}
|
|
if (!options.isWhitespace) {
|
|
try {
|
|
Object.assign(options, {
|
|
isChar: (node, char) => node.type === "string" && node.content === char,
|
|
isOperation: (node) => node.type === "string" && node.content.match(/[a-zA-Z]/),
|
|
isWhitespace: (node) => node.type === "whitespace" || node.type === "parbreak",
|
|
isSameLineComment: (node) => node.type === "comment" && node.sameline,
|
|
isOwnLineComment: (node) => node.type === "comment" && !node.sameline,
|
|
isComment: (node) => node.type === "comment",
|
|
isGroup: (node) => node.type === "group",
|
|
isMacro: (node, name) => node.type === "macro" && node.content === name,
|
|
isAnyMacro: (node) => node.type === "macro"
|
|
});
|
|
} catch (e) {
|
|
console.warn("Error when initializing parser", e);
|
|
}
|
|
}
|
|
peg$result = peg$startRuleFunction();
|
|
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|
return peg$result;
|
|
} else {
|
|
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|
peg$fail(peg$endExpectation());
|
|
}
|
|
throw peg$buildStructuredError(
|
|
peg$maxFailExpected,
|
|
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
|
|
peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
|
|
);
|
|
}
|
|
}
|
|
return {
|
|
SyntaxError: peg$SyntaxError,
|
|
parse: peg$parse
|
|
};
|
|
}()
|
|
);
|
|
const LatexPegParser = _LatexPegParser;
|
|
const AlignEnvironmentPegParser = _AlignEnvironmentPegParser;
|
|
const ArgSpecPegParser = _ArgSpecPegParser;
|
|
const PgfkeysPegParser = _PgfkeysPegParser;
|
|
const MacroSubstitutionPegParser = _MacroSubstitutionPegParser;
|
|
const LigaturesPegParser = _LigaturesPegParser;
|
|
const XColorPegParser = _XColorPegParser;
|
|
const TabularPegParser = _TabularPegParser;
|
|
const SystemePegParser = _SystemePegParser;
|
|
const GluePegParser = _GluePegParser;
|
|
const TikzPegParser = _TikzPegParser;
|
|
exports.AlignEnvironmentPegParser = AlignEnvironmentPegParser;
|
|
exports.ArgSpecPegParser = ArgSpecPegParser;
|
|
exports.GluePegParser = GluePegParser;
|
|
exports.LatexPegParser = LatexPegParser;
|
|
exports.LigaturesPegParser = LigaturesPegParser;
|
|
exports.MacroSubstitutionPegParser = MacroSubstitutionPegParser;
|
|
exports.PgfkeysPegParser = PgfkeysPegParser;
|
|
exports.SystemePegParser = SystemePegParser;
|
|
exports.TabularPegParser = TabularPegParser;
|
|
exports.TikzPegParser = TikzPegParser;
|
|
exports.XColorPegParser = XColorPegParser;
|
|
exports.decorateArrayForPegjs = decorateArrayForPegjs;
|
|
exports.splitStringsIntoSingleChars = splitStringsIntoSingleChars;
|
|
//# sourceMappingURL=index.cjs.map
|