Skip to content

Instantly share code, notes, and snippets.

@PhDP
Created March 1, 2018 19:57
Show Gist options
  • Save PhDP/3d5b7f7c24966690c57d10b8ea27a719 to your computer and use it in GitHub Desktop.
Save PhDP/3d5b7f7c24966690c57d10b8ea27a719 to your computer and use it in GitHub Desktop.
fol.js
// tslint:disable
/*
* Generated by PEG.js 0.10.0.
*
* http://pegjs.org/
*/
"use strict";
function peg$subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function peg$SyntaxError(message, expected, found, location) {
this.message = message;
this.expected = expected;
this.found = found;
this.location = location;
this.name = "SyntaxError";
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, peg$SyntaxError);
}
}
peg$subclass(peg$SyntaxError, Error);
peg$SyntaxError.buildMessage = function(expected, found) {
const DESCRIBE_EXPECTATION_FNS = {
literal: function (expectation) {
return "\"" + literalEscape(expectation.text) + "\"";
},
"class": function (expectation) {
let escapedParts = "",
i;
for (i = 0; i < expectation.parts.length; i++) {
escapedParts += expectation.parts[i] instanceof Array
? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
: classEscape(expectation.parts[i]);
}
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
},
any: function (expectation) {
return "any character";
},
end: function (expectation) {
return "end of input";
},
other: function (expectation) {
return expectation.description;
}
};
function hex(ch) {
return ch.charCodeAt(0).toString(16).toUpperCase();
}
function literalEscape(s) {
return s
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\0/g, '\\0')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
}
function classEscape(s) {
return s
.replace(/\\/g, '\\\\')
.replace(/\]/g, '\\]')
.replace(/\^/g, '\\^')
.replace(/-/g, '\\-')
.replace(/\0/g, '\\0')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r')
.replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
}
function describeExpectation(expectation) {
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
}
function describeExpected(expected) {
let descriptions = new Array(expected.length),
i, j;
for (i = 0; i < expected.length; i++) {
descriptions[i] = describeExpectation(expected[i]);
}
descriptions.sort();
if (descriptions.length > 0) {
for (i = 1, j = 1; i < descriptions.length; i++) {
if (descriptions[i - 1] !== descriptions[i]) {
descriptions[j] = descriptions[i];
j++;
}
}
descriptions.length = j;
}
switch (descriptions.length) {
case 1:
return descriptions[0];
case 2:
return descriptions[0] + " or " + descriptions[1];
default:
return descriptions.slice(0, -1).join(", ")
+ ", or "
+ descriptions[descriptions.length - 1];
}
}
function describeFound(found) {
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
}
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
};
function peg$parse(input, options) {
options = options !== void 0 ? options : {};
let peg$FAILED = {},
peg$startRuleFunctions = { start: peg$parsestart },
peg$startRuleFunction = peg$parsestart,
peg$c0 = "not",
peg$c1 = peg$literalExpectation("not", true),
peg$c2 = "!",
peg$c3 = peg$literalExpectation("!", false),
peg$c4 = "~",
peg$c5 = peg$literalExpectation("~", false),
peg$c6 = "\xAC",
peg$c7 = peg$literalExpectation("\xAC", false),
peg$c8 = "A.",
peg$c9 = peg$literalExpectation("A.", false),
peg$c10 = "forall",
peg$c11 = peg$literalExpectation("forall", true),
peg$c12 = "\u2200",
peg$c13 = peg$literalExpectation("\u2200", false),
peg$c14 = "exists",
peg$c15 = peg$literalExpectation("exists", true),
peg$c16 = "E.",
peg$c17 = peg$literalExpectation("E.", false),
peg$c18 = "\u2203",
peg$c19 = peg$literalExpectation("\u2203", false),
peg$c20 = "iff",
peg$c21 = peg$literalExpectation("iff", true),
peg$c22 = "<=>",
peg$c23 = peg$literalExpectation("<=>", false),
peg$c24 = "\u21D4",
peg$c25 = peg$literalExpectation("\u21D4", false),
peg$c26 = "xor",
peg$c27 = peg$literalExpectation("xor", true),
peg$c28 = "\u2295",
peg$c29 = peg$literalExpectation("\u2295", false),
peg$c30 = "\u22BB",
peg$c31 = peg$literalExpectation("\u22BB", false),
peg$c32 = "implies",
peg$c33 = peg$literalExpectation("implies", true),
peg$c34 = "=>",
peg$c35 = peg$literalExpectation("=>", false),
peg$c36 = "\u21D2",
peg$c37 = peg$literalExpectation("\u21D2", false),
peg$c38 = "or",
peg$c39 = peg$literalExpectation("or", true),
peg$c40 = "v",
peg$c41 = peg$literalExpectation("v", false),
peg$c42 = "\u2228",
peg$c43 = peg$literalExpectation("\u2228", false),
peg$c44 = "and",
peg$c45 = peg$literalExpectation("and", true),
peg$c46 = "\u2227",
peg$c47 = peg$literalExpectation("\u2227", false),
peg$c48 = ";",
peg$c49 = peg$literalExpectation(";", false),
peg$c50 = /^[0-9.]/,
peg$c51 = peg$classExpectation([["0", "9"], "."], false, false),
peg$c52 = function(fm, weight) {
return { formula: fm, weight: Number(weight.join("")) };
},
peg$c53 = function(fm) { return { formula: fm }; },
peg$c54 = function(x) { return { not: x }; },
peg$c55 = ",",
peg$c56 = peg$literalExpectation(",", false),
peg$c57 = ":",
peg$c58 = peg$literalExpectation(":", false),
peg$c59 = function(q, v, vs, fm) {
return { qualifier: { kind: getQual(q), variables: getTerms(v, vs), formula: fm } };
},
peg$c60 = function(x, y) { return { binop: { kind: "iff", left: x, right: y } }; },
peg$c61 = function(x, y) { return { binop: { kind: "xor", left: x, right: y } }; },
peg$c62 = function(x, y) { return { binop: { kind: "implies", left: x, right: y } }; },
peg$c63 = function(x, y) { return { binop: { kind: "or", left: x, right: y } }; },
peg$c64 = function(x, y) { return { binop: { kind: "and", left: x, right: y } }; },
peg$c65 = "\u22A4",
peg$c66 = peg$literalExpectation("\u22A4", false),
peg$c67 = function() { return { predicate: { name: "true" } }; },
peg$c68 = "\u22A5",
peg$c69 = peg$literalExpectation("\u22A5", false),
peg$c70 = function() { return { predicate: { name: "false" } }; },
peg$c71 = "(",
peg$c72 = peg$literalExpectation("(", false),
peg$c73 = ")",
peg$c74 = peg$literalExpectation(")", false),
peg$c75 = function(expr) { return expr; },
peg$c76 = "[",
peg$c77 = peg$literalExpectation("[", false),
peg$c78 = "]",
peg$c79 = peg$literalExpectation("]", false),
peg$c80 = "==",
peg$c81 = peg$literalExpectation("==", false),
peg$c82 = "=",
peg$c83 = peg$literalExpectation("=", false),
peg$c84 = "!=",
peg$c85 = peg$literalExpectation("!=", false),
peg$c86 = "/=",
peg$c87 = peg$literalExpectation("/=", false),
peg$c88 = "<=",
peg$c89 = peg$literalExpectation("<=", false),
peg$c90 = ">=",
peg$c91 = peg$literalExpectation(">=", false),
peg$c92 = "<",
peg$c93 = peg$literalExpectation("<", false),
peg$c94 = ">",
peg$c95 = peg$literalExpectation(">", false),
peg$c96 = function(t0, s, t1) {
let f = { predicate: { args: [t0, t1] } };
switch (s) {
case "<": f.predicate.name = "lt"; break;
case "<=": f.predicate.name = "leq"; break;
case ">": f.predicate.name = "gt"; break;
case ">=": f.predicate.name = "geq"; break;
default: f.predicate.name = "eq";
}
return s == "!=" || s == "/="? { not: f } : f;
},
peg$c97 = /^[_a-zA-Z]/,
peg$c98 = peg$classExpectation(["_", ["a", "z"], ["A", "Z"]], false, false),
peg$c99 = /^[_a-zA-Z0-9]/,
peg$c100 = peg$classExpectation(["_", ["a", "z"], ["A", "Z"], ["0", "9"]], false, false),
peg$c101 = function(fst, txt, ts) {
return { predicate: { name: (fst + txt.join("")), args: (ts? ts : undefined) } };
},
peg$c102 = function(t, ts) { return getTerms(t, ts); },
peg$c103 = "+",
peg$c104 = peg$literalExpectation("+", false),
peg$c105 = "-",
peg$c106 = peg$literalExpectation("-", false),
peg$c107 = function(x, o, y) { return { kind: "function", name: (o=="+"?"add":"substact"), args: [x, y] }; },
peg$c108 = "*",
peg$c109 = peg$literalExpectation("*", false),
peg$c110 = "/",
peg$c111 = peg$literalExpectation("/", false),
peg$c112 = function(x, o, y) { return { kind: "function", name: (o=="*"?"multiply":"divide"), args: [x, y] }; },
peg$c113 = "^",
peg$c114 = peg$literalExpectation("^", false),
peg$c115 = function(x, y) { return { kind: "function", name: "power", args: [x, y] }; },
peg$c116 = function(x) { return { negative: x}; },
peg$c117 = function(fst, txt, t, ts) {
return { kind: "function", name: buildName(fst, txt), args: getTerms(t, ts) };
},
peg$c118 = /^[a-z]/,
peg$c119 = peg$classExpectation([["a", "z"]], false, false),
peg$c120 = function(fst, txt) { return { kind: "variable", name: buildName(fst, txt) }; },
peg$c121 = function(txt) { return { kind: "constant", name: txt.join("") }; },
peg$c122 = function(t) { return t; },
peg$c123 = /^[ \t\r\n]/,
peg$c124 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false),
peg$currPos = 0,
peg$savedPos = 0,
peg$posDetailsCache = [{ line: 1, column: 1 }],
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$result;
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
}
function text() {
return input.substring(peg$savedPos, peg$currPos);
}
function location() {
return peg$computeLocation(peg$savedPos, peg$currPos);
}
function expected(description, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
throw peg$buildStructuredError(
[peg$otherExpectation(description)],
input.substring(peg$savedPos, peg$currPos),
location
);
}
function error(message, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos);
throw peg$buildSimpleError(message, location);
}
function peg$literalExpectation(text, ignoreCase) {
return { type: "literal", text: text, ignoreCase: ignoreCase };
}
function peg$classExpectation(parts, inverted, ignoreCase) {
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
}
function peg$anyExpectation() {
return { type: "any" };
}
function peg$endExpectation() {
return { type: "end" };
}
function peg$otherExpectation(description) {
return { type: "other", description: description };
}
function peg$computePosDetails(pos) {
let details = peg$posDetailsCache[pos], 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) {
let startPosDetails = peg$computePosDetails(startPos),
endPosDetails = peg$computePosDetails(endPos);
return {
start: {
offset: startPos,
line: startPosDetails.line,
column: startPosDetails.column
},
end: {
offset: endPos,
line: endPosDetails.line,
column: endPosDetails.column
}
};
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) { return; }
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
peg$maxFailExpected = [];
}
peg$maxFailExpected.push(expected);
}
function peg$buildSimpleError(message, location) {
return new peg$SyntaxError(message, null, null, location);
}
function peg$buildStructuredError(expected, found, location) {
return new peg$SyntaxError(
peg$SyntaxError.buildMessage(expected, found),
expected,
found,
location
);
}
function peg$parsestart() {
let s0;
s0 = peg$parseformula();
return s0;
}
function peg$parsematchNeg() {
let s0;
if (input.substr(peg$currPos, 3).toLowerCase() === peg$c0) {
s0 = input.substr(peg$currPos, 3);
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c1); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 33) {
s0 = peg$c2;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c3); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 126) {
s0 = peg$c4;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 172) {
s0 = peg$c6;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c7); }
}
}
}
}
return s0;
}
function peg$parsematchQual() {
let s0;
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$c9); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 6).toLowerCase() === peg$c10) {
s0 = input.substr(peg$currPos, 6);
peg$currPos += 6;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c11); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8704) {
s0 = peg$c12;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c13); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 6).toLowerCase() === peg$c14) {
s0 = input.substr(peg$currPos, 6);
peg$currPos += 6;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c15); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c16) {
s0 = peg$c16;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c17); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8707) {
s0 = peg$c18;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c19); }
}
}
}
}
}
}
return s0;
}
function peg$parsematchIff() {
let s0;
if (input.substr(peg$currPos, 3).toLowerCase() === peg$c20) {
s0 = input.substr(peg$currPos, 3);
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c21); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 3) === peg$c22) {
s0 = peg$c22;
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c23); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8660) {
s0 = peg$c24;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c25); }
}
}
}
return s0;
}
function peg$parsematchXor() {
let s0;
if (input.substr(peg$currPos, 3).toLowerCase() === peg$c26) {
s0 = input.substr(peg$currPos, 3);
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c27); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8853) {
s0 = peg$c28;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c29); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8891) {
s0 = peg$c30;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c31); }
}
}
}
return s0;
}
function peg$parsematchImp() {
let s0;
if (input.substr(peg$currPos, 7).toLowerCase() === peg$c32) {
s0 = input.substr(peg$currPos, 7);
peg$currPos += 7;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c33); }
}
if (s0 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c34) {
s0 = peg$c34;
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c35); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8658) {
s0 = peg$c36;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c37); }
}
}
}
return s0;
}
function peg$parsematchOr() {
let s0;
if (input.substr(peg$currPos, 2).toLowerCase() === peg$c38) {
s0 = input.substr(peg$currPos, 2);
peg$currPos += 2;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c39); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 118) {
s0 = peg$c40;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8744) {
s0 = peg$c42;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c43); }
}
}
}
return s0;
}
function peg$parsematchAnd() {
let s0;
if (input.substr(peg$currPos, 3).toLowerCase() === peg$c44) {
s0 = input.substr(peg$currPos, 3);
peg$currPos += 3;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c45); }
}
if (s0 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 8743) {
s0 = peg$c46;
peg$currPos++;
} else {
s0 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c47); }
}
}
return s0;
}
function peg$parseformula() {
let s0;
s0 = peg$parsewformula();
if (s0 === peg$FAILED) {
s0 = peg$parseuformula();
}
return s0;
}
function peg$parsewformula() {
let s0, s1, s2, s3, s4, s5, s6;
s0 = peg$currPos;
s1 = peg$parsenegq();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 59) {
s3 = peg$c48;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c49); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = [];
if (peg$c50.test(input.charAt(peg$currPos))) {
s6 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
if (s6 !== peg$FAILED) {
while (s6 !== peg$FAILED) {
s5.push(s6);
if (peg$c50.test(input.charAt(peg$currPos))) {
s6 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
}
} else {
s5 = peg$FAILED;
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c52(s1, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseuformula() {
let s0, s1;
s0 = peg$currPos;
s1 = peg$parsenegq();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c53(s1);
}
s0 = s1;
return s0;
}
function peg$parsenegq() {
let s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parsematchNeg();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parsenegq();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c54(s3);
s0 = s1;
} 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$parsequal();
}
return s0;
}
function peg$parsequal() {
let s0, s1, s2, s3, s4, s5, s6, s7, s8;
s0 = peg$currPos;
s1 = peg$parsematchQual();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parsevariable();
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s6 = peg$c55;
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c56); }
}
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
s8 = peg$parsevariable();
if (s8 !== peg$FAILED) {
s6 = [s6, s7, s8];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s6 = peg$c55;
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c56); }
}
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
s8 = peg$parsevariable();
if (s8 !== peg$FAILED) {
s6 = [s6, s7, s8];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
}
if (s4 !== peg$FAILED) {
s5 = peg$parse_();
if (s5 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 58) {
s6 = peg$c57;
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c58); }
}
if (s6 === peg$FAILED) {
s6 = null;
}
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
s8 = peg$parsenegq();
if (s8 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c59(s1, s3, s4, s8);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parseiff();
}
return s0;
}
function peg$parseiff() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parsexor();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parsematchIff();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parseiff();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c60(s1, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parsexor();
}
return s0;
}
function peg$parsexor() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseimp();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parsematchXor();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parsexor();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c61(s1, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parseimp();
}
return s0;
}
function peg$parseimp() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseor();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parsematchImp();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parseimp();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c62(s1, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parseor();
}
return s0;
}
function peg$parseor() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseand();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parsematchOr();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parseor();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c63(s1, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parseand();
}
return s0;
}
function peg$parseand() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseneg();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parsematchAnd();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parseand();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c64(s1, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parseneg();
}
return s0;
}
function peg$parseneg() {
let s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parsematchNeg();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parseneg();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c54(s3);
s0 = s1;
} 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$parseatomic();
}
return s0;
}
function peg$parseatomic() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$parseidentity();
if (s0 === peg$FAILED) {
s0 = peg$parsepred();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 8868) {
s1 = peg$c65;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c66); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c67();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 8869) {
s1 = peg$c68;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c69); }
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c70();
}
s0 = s1;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 40) {
s1 = peg$c71;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c72); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parsenegq();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s5 = peg$c73;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c74); }
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c75(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 91) {
s1 = peg$c76;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c77); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parsenegq();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 93) {
s5 = peg$c78;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c79); }
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c75(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
}
}
}
}
}
return s0;
}
function peg$parseidentity() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseterm();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c80) {
s3 = peg$c80;
peg$currPos += 2;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c81); }
}
if (s3 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 61) {
s3 = peg$c82;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c83); }
}
if (s3 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c84) {
s3 = peg$c84;
peg$currPos += 2;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c85); }
}
if (s3 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c86) {
s3 = peg$c86;
peg$currPos += 2;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c87); }
}
if (s3 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c88) {
s3 = peg$c88;
peg$currPos += 2;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c89); }
}
if (s3 === peg$FAILED) {
if (input.substr(peg$currPos, 2) === peg$c90) {
s3 = peg$c90;
peg$currPos += 2;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c91); }
}
if (s3 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 60) {
s3 = peg$c92;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c93); }
}
if (s3 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 62) {
s3 = peg$c94;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c95); }
}
}
}
}
}
}
}
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parseterm();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c96(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parsepred() {
let s0, s1, s2, s3;
s0 = peg$currPos;
if (peg$c97.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c98); }
}
if (s1 !== peg$FAILED) {
s2 = [];
if (peg$c99.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c100); }
}
while (s3 !== peg$FAILED) {
s2.push(s3);
if (peg$c99.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c100); }
}
}
if (s2 !== peg$FAILED) {
s3 = peg$parseterms();
if (s3 === peg$FAILED) {
s3 = null;
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c101(s1, s2, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseterms() {
let s0, s1, s2, s3, s4, s5, s6, s7, s8;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 40) {
s1 = peg$c71;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c72); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parseterm();
if (s3 === peg$FAILED) {
s3 = null;
}
if (s3 !== peg$FAILED) {
s4 = [];
s5 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s6 = peg$c55;
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c56); }
}
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
s8 = peg$parseterm();
if (s8 !== peg$FAILED) {
s6 = [s6, s7, s8];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
while (s5 !== peg$FAILED) {
s4.push(s5);
s5 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s6 = peg$c55;
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c56); }
}
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
s8 = peg$parseterm();
if (s8 !== peg$FAILED) {
s6 = [s6, s7, s8];
s5 = s6;
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
} else {
peg$currPos = s5;
s5 = peg$FAILED;
}
}
if (s4 !== peg$FAILED) {
s5 = peg$parse_();
if (s5 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s6 = peg$c73;
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c74); }
}
if (s6 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c102(s3, s4);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseterm() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parsemulfun();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 43) {
s3 = peg$c103;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c104); }
}
if (s3 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 45) {
s3 = peg$c105;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c106); }
}
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parseterm();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c107(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parsemulfun();
}
return s0;
}
function peg$parsemulfun() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseexpfun();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 42) {
s3 = peg$c108;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c109); }
}
if (s3 === peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 47) {
s3 = peg$c110;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c111); }
}
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parsemulfun();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c112(s1, s3, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parseexpfun();
}
return s0;
}
function peg$parseexpfun() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$currPos;
s1 = peg$parseminfun();
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 94) {
s3 = peg$c113;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c114); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parseexpfun();
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c115(s1, s5);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parseminfun();
}
return s0;
}
function peg$parseminfun() {
let s0, s1, s2;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 45) {
s1 = peg$c105;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c106); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parseminfun();
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c116(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parsetatomic();
}
return s0;
}
function peg$parsefuncterm() {
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10;
s0 = peg$currPos;
if (peg$c97.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c98); }
}
if (s1 !== peg$FAILED) {
s2 = [];
if (peg$c99.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c100); }
}
while (s3 !== peg$FAILED) {
s2.push(s3);
if (peg$c99.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c100); }
}
}
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 40) {
s3 = peg$c71;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c72); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
s5 = peg$parseterm();
if (s5 === peg$FAILED) {
s5 = null;
}
if (s5 !== peg$FAILED) {
s6 = [];
s7 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s8 = peg$c55;
peg$currPos++;
} else {
s8 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c56); }
}
if (s8 !== peg$FAILED) {
s9 = peg$parse_();
if (s9 !== peg$FAILED) {
s10 = peg$parseterm();
if (s10 !== peg$FAILED) {
s8 = [s8, s9, s10];
s7 = s8;
} else {
peg$currPos = s7;
s7 = peg$FAILED;
}
} else {
peg$currPos = s7;
s7 = peg$FAILED;
}
} else {
peg$currPos = s7;
s7 = peg$FAILED;
}
while (s7 !== peg$FAILED) {
s6.push(s7);
s7 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 44) {
s8 = peg$c55;
peg$currPos++;
} else {
s8 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c56); }
}
if (s8 !== peg$FAILED) {
s9 = peg$parse_();
if (s9 !== peg$FAILED) {
s10 = peg$parseterm();
if (s10 !== peg$FAILED) {
s8 = [s8, s9, s10];
s7 = s8;
} else {
peg$currPos = s7;
s7 = peg$FAILED;
}
} else {
peg$currPos = s7;
s7 = peg$FAILED;
}
} else {
peg$currPos = s7;
s7 = peg$FAILED;
}
}
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s8 = peg$c73;
peg$currPos++;
} else {
s8 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c74); }
}
if (s8 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c117(s1, s2, s5, s6);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} 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$parsevariable() {
let s0, s1, s2, s3;
s0 = peg$currPos;
if (peg$c118.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c119); }
}
if (s1 !== peg$FAILED) {
s2 = [];
if (peg$c99.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c100); }
}
while (s3 !== peg$FAILED) {
s2.push(s3);
if (peg$c99.test(input.charAt(peg$currPos))) {
s3 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c100); }
}
}
if (s2 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c120(s1, s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
return s0;
}
function peg$parseconstant() {
let s0, s1, s2;
s0 = peg$currPos;
s1 = [];
if (peg$c99.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c100); }
}
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c99.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c100); }
}
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c121(s1);
}
s0 = s1;
return s0;
}
function peg$parsetatomic() {
let s0, s1, s2, s3, s4, s5;
s0 = peg$parsefuncterm();
if (s0 === peg$FAILED) {
s0 = peg$parsevariable();
if (s0 === peg$FAILED) {
s0 = peg$parseconstant();
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 40) {
s1 = peg$c71;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c72); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parseterm();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s5 = peg$c73;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c74); }
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c122(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 91) {
s1 = peg$c76;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c77); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parse_();
if (s2 !== peg$FAILED) {
s3 = peg$parseterm();
if (s3 !== peg$FAILED) {
s4 = peg$parse_();
if (s4 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 93) {
s5 = peg$c78;
peg$currPos++;
} else {
s5 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c79); }
}
if (s5 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c122(s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
}
}
}
}
return s0;
}
function peg$parse_() {
let s0, s1;
s0 = [];
if (peg$c123.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c124); }
}
while (s1 !== peg$FAILED) {
s0.push(s1);
if (peg$c123.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c124); }
}
}
return s0;
}
function peg$parse__() {
let s0, s1;
s0 = [];
if (peg$c123.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c124);
}
}
if (s1 !== peg$FAILED) {
while (s1 !== peg$FAILED) {
s0.push(s1);
if (peg$c123.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c124);
}
}
}
} else {
s0 = peg$FAILED;
}
return s0;
}
function getTerms(t, ts) {
if (t) {
let arr = [];
for (let i = 0; i < ts.length; ++i) {
arr.push(ts[i][2]);
}
return [t].concat(arr);
}
return [];
}
function buildName(fst, rest) {
return fst + rest.join("");
}
function getQual(q) {
return q == "A." || q.toLowerCase() == "forall" || q == "∀"? "forall" : "exists";
}
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)
);
}
}
export const fol = {
SyntaxError: peg$SyntaxError,
parse: peg$parse
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment