elastic-muto
Version:
Easy expressive search queries for Elasticsearch
1,728 lines (1,592 loc) • 142 kB
JavaScript
/*
* Generated by PEG.js 0.10.0.
*
* http://pegjs.org/
*/
"use strict";
var BoolQuery = require("elastic-builder/lib/queries/compound-queries/bool-query");
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) {
var DESCRIBE_EXPECTATION_FNS = {
literal: function literal(expectation) {
return "\"" + literalEscape(expectation.text) + "\"";
},
"class": function _class(expectation) {
var escapedParts = "",
i;
for (i = 0; i < expectation.parts.length; i++) {
escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]);
}
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
},
any: function any(expectation) {
return "any character";
},
end: function end(expectation) {
return "end of input";
},
other: function other(expectation) {
return expectation.description;
}
};
function hex(ch) {
return ch.charCodeAt(0).toString(16).toUpperCase();
}
function literalEscape(s) {
return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {
return '\\x0' + hex(ch);
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return '\\x' + hex(ch);
});
}
function classEscape(s) {
return s.replace(/\\/g, '\\\\').replace(/\]/g, '\\]').replace(/\^/g, '\\^').replace(/-/g, '\\-').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {
return '\\x0' + hex(ch);
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
return '\\x' + hex(ch);
});
}
function describeExpectation(expectation) {
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
}
function describeExpected(expected) {
var descriptions = 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 : {};
var peg$FAILED = {},
peg$startRuleFunctions = { ExprWrapper: peg$parseExprWrapper },
peg$startRuleFunction = peg$parseExprWrapper,
peg$c0 = peg$otherExpectation("Expression Wrapper"),
peg$c1 = function peg$c1(expr) {
return expr instanceof BoolQuery ? expr : new BoolQuery().must(expr);
},
peg$c2 = peg$otherExpectation("Where Expression"),
peg$c3 = "(",
peg$c4 = peg$literalExpectation("(", false),
peg$c5 = function peg$c5(head, expr) {
return expr;
},
peg$c6 = ")",
peg$c7 = peg$literalExpectation(")", false),
peg$c8 = function peg$c8(head, tail) {
var conditions = tail;
conditions.unshift(head);
return new BoolQuery().must(conditions);
},
peg$c9 = function peg$c9(head, tail) {
var conditions = tail;
conditions.unshift(head);
return new BoolQuery().should(conditions);
},
peg$c10 = function peg$c10(expr) {
return expr;
},
peg$c11 = function peg$c11(head, cond) {
return cond;
},
peg$c12 = function peg$c12(head, torso, expr) {
return expr;
},
peg$c13 = function peg$c13(head, torso, tail) {
var conditions = torso.concat(tail);
conditions.unshift(head);
return new BoolQuery().must(conditions);
},
peg$c14 = function peg$c14(head, torso, tail) {
var conditions = torso.concat(tail);
conditions.unshift(head);
return new BoolQuery().should(conditions);
},
peg$c15 = peg$otherExpectation("Property Condition"),
peg$c16 = function peg$c16(cond) {
return cond;
},
peg$c17 = peg$otherExpectation("Number property less than or equal to condition"),
peg$c18 = function peg$c18(key, value) {
return options.numLte(key, value);
},
peg$c19 = peg$otherExpectation("Number property greater than or equal to condition"),
peg$c20 = function peg$c20(key, value) {
return options.numGte(key, value);
},
peg$c21 = peg$otherExpectation("Number property less than condition"),
peg$c22 = function peg$c22(key, value) {
return options.numLt(key, value);
},
peg$c23 = peg$otherExpectation("Number property greater than condition"),
peg$c24 = function peg$c24(key, value) {
return options.numGt(key, value);
},
peg$c25 = peg$otherExpectation("Number property equality condition"),
peg$c26 = function peg$c26(key, value) {
return options.numEq(key, value);
},
peg$c27 = peg$otherExpectation("Number property inequality condition"),
peg$c28 = function peg$c28(key, value) {
return options.numNe(key, value);
},
peg$c29 = peg$otherExpectation("Date property less than or equal to condition"),
peg$c30 = function peg$c30(key, value) {
return options.dateLte(key, value);
},
peg$c31 = peg$otherExpectation("Date property greater than or equal to condition"),
peg$c32 = function peg$c32(key, value) {
return options.dateGte(key, value);
},
peg$c33 = peg$otherExpectation("Date property less than condition"),
peg$c34 = function peg$c34(key, value) {
return options.dateLt(key, value);
},
peg$c35 = peg$otherExpectation("Date property greater than condition"),
peg$c36 = function peg$c36(key, value) {
return options.dateGt(key, value);
},
peg$c37 = peg$otherExpectation("Date property equality condition"),
peg$c38 = function peg$c38(key, value) {
return options.dateEq(key, value);
},
peg$c39 = peg$otherExpectation("String property contains condition"),
peg$c40 = function peg$c40(key, value) {
return options.strContains(key, value);
},
peg$c41 = peg$otherExpectation("String property does not contain condition"),
peg$c42 = function peg$c42(key, value) {
return options.strNotContains(key, value);
},
peg$c43 = peg$otherExpectation("String property equality condition"),
peg$c44 = function peg$c44(key, value) {
return options.strEq(key, value, options.notAnalysedFields);
},
peg$c45 = peg$otherExpectation("String property inequality condition"),
peg$c46 = function peg$c46(key, value) {
return options.strNe(key, value, options.notAnalysedFields);
},
peg$c47 = peg$otherExpectation("Property Exists"),
peg$c48 = function peg$c48(key) {
return options.exists(key);
},
peg$c49 = peg$otherExpectation("Property does not exist"),
peg$c50 = function peg$c50(key) {
return options.missing(key);
},
peg$c51 = peg$otherExpectation("Boolean condition"),
peg$c52 = function peg$c52(key, value) {
return options.bool(key, value);
},
peg$c53 = peg$otherExpectation("Property key"),
peg$c54 = function peg$c54(chars) {
return options.propertyKey(chars);
},
peg$c55 = peg$otherExpectation("Equal operator"),
peg$c56 = "==",
peg$c57 = peg$literalExpectation("==", false),
peg$c58 = peg$otherExpectation("Not equal operator"),
peg$c59 = "!=",
peg$c60 = peg$literalExpectation("!=", false),
peg$c61 = peg$otherExpectation("Less than operator"),
peg$c62 = "<",
peg$c63 = peg$literalExpectation("<", false),
peg$c64 = peg$otherExpectation("Greater than operator"),
peg$c65 = ">",
peg$c66 = peg$literalExpectation(">", false),
peg$c67 = peg$otherExpectation("Less than or equal to operator"),
peg$c68 = "<=",
peg$c69 = peg$literalExpectation("<=", false),
peg$c70 = peg$otherExpectation("Greater than or equal to operator"),
peg$c71 = ">=",
peg$c72 = peg$literalExpectation(">=", false),
peg$c73 = peg$otherExpectation("Contains operator"),
peg$c74 = "contains",
peg$c75 = peg$literalExpectation("contains", true),
peg$c76 = "!contains",
peg$c77 = peg$literalExpectation("!contains", true),
peg$c78 = peg$otherExpectation("Exists operator"),
peg$c79 = "exists",
peg$c80 = peg$literalExpectation("exists", true),
peg$c81 = peg$otherExpectation("Missing operator"),
peg$c82 = "missing",
peg$c83 = peg$literalExpectation("missing", true),
peg$c84 = peg$otherExpectation("Boolean(is) operator"),
peg$c85 = "is",
peg$c86 = peg$literalExpectation("is", true),
peg$c87 = peg$otherExpectation("Numeric Value"),
peg$c88 = function peg$c88(val) {
return val;
},
peg$c89 = function peg$c89() {
return parseFloat(text());
},
peg$c90 = peg$otherExpectation("Date Value"),
peg$c91 = function peg$c91() {
return new Date(text().trim());
},
peg$c92 = peg$otherExpectation("String value"),
peg$c93 = function peg$c93(chars) {
return chars.join("");
},
peg$c94 = peg$otherExpectation("Boolean Value"),
peg$c95 = "true",
peg$c96 = peg$literalExpectation("true", false),
peg$c97 = "false",
peg$c98 = peg$literalExpectation("false", false),
peg$c99 = function peg$c99(val) {
return val === 'true';
},
peg$c100 = peg$otherExpectation("or condition"),
peg$c101 = "or",
peg$c102 = peg$literalExpectation("or", true),
peg$c103 = peg$otherExpectation("and condition"),
peg$c104 = "and",
peg$c105 = peg$literalExpectation("and", true),
peg$c106 = "[\"",
peg$c107 = peg$literalExpectation("[\"", false),
peg$c108 = "\"]",
peg$c109 = peg$literalExpectation("\"]", false),
peg$c110 = ".",
peg$c111 = peg$literalExpectation(".", false),
peg$c112 = /^[1-9]/,
peg$c113 = peg$classExpectation([["1", "9"]], false, false),
peg$c114 = /^[eE]/,
peg$c115 = peg$classExpectation(["e", "E"], false, false),
peg$c116 = "-",
peg$c117 = peg$literalExpectation("-", false),
peg$c118 = "+",
peg$c119 = peg$literalExpectation("+", false),
peg$c120 = "0",
peg$c121 = peg$literalExpectation("0", false),
peg$c122 = "\"",
peg$c123 = peg$literalExpectation("\"", false),
peg$c124 = "\\",
peg$c125 = peg$literalExpectation("\\", false),
peg$c126 = "/",
peg$c127 = peg$literalExpectation("/", false),
peg$c128 = "b",
peg$c129 = peg$literalExpectation("b", false),
peg$c130 = function peg$c130() {
return "\b";
},
peg$c131 = "f",
peg$c132 = peg$literalExpectation("f", false),
peg$c133 = function peg$c133() {
return "\f";
},
peg$c134 = "n",
peg$c135 = peg$literalExpectation("n", false),
peg$c136 = function peg$c136() {
return "\n";
},
peg$c137 = "r",
peg$c138 = peg$literalExpectation("r", false),
peg$c139 = function peg$c139() {
return "\r";
},
peg$c140 = "t",
peg$c141 = peg$literalExpectation("t", false),
peg$c142 = function peg$c142() {
return "\t";
},
peg$c143 = "u",
peg$c144 = peg$literalExpectation("u", false),
peg$c145 = function peg$c145(digits) {
return String.fromCharCode(parseInt(digits, 16));
},
peg$c146 = function peg$c146(sequence) {
return sequence;
},
peg$c147 = /^[^\0-\x1F"\\]/,
peg$c148 = peg$classExpectation([["\0", "\x1F"], "\"", "\\"], true, false),
peg$c149 = /^[0-9]/,
peg$c150 = peg$classExpectation([["0", "9"]], false, false),
peg$c151 = /^[0-9a-f]/i,
peg$c152 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true),
peg$c153 = "T",
peg$c154 = peg$literalExpectation("T", false),
peg$c155 = function peg$c155() {
return text();
},
peg$c156 = "--",
peg$c157 = peg$literalExpectation("--", false),
peg$c158 = "W",
peg$c159 = peg$literalExpectation("W", false),
peg$c160 = "---",
peg$c161 = peg$literalExpectation("---", false),
peg$c162 = ",",
peg$c163 = peg$literalExpectation(",", false),
peg$c164 = ":",
peg$c165 = peg$literalExpectation(":", false),
peg$c166 = "Z",
peg$c167 = peg$literalExpectation("Z", false),
peg$c168 = peg$otherExpectation("whitespace"),
peg$c169 = /^[ \t\n\r]/,
peg$c170 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false),
peg$currPos = 0,
peg$savedPos = 0,
peg$posDetailsCache = [{ line: 1, column: 1 }],
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$resultsCache = {},
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) {
var 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) {
var 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$parseExprWrapper() {
var s0, s1;
var key = peg$currPos * 97 + 0,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parseExpression();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c1(s1);
}
s0 = s1;
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c0);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseExpression() {
var s0, s1, s2, s3, s4, s5, s6;
var key = peg$currPos * 97 + 1,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 40) {
s1 = peg$c3;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c4);
}
}
if (s1 !== peg$FAILED) {
s2 = peg$parseExpression();
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$currPos;
s5 = peg$parseAnd();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c5(s2, 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$currPos;
s5 = peg$parseAnd();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c5(s2, 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) {
if (input.charCodeAt(peg$currPos) === 41) {
s4 = peg$c6;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c7);
}
}
if (s4 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8(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;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 40) {
s1 = peg$c3;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c4);
}
}
if (s1 !== peg$FAILED) {
s2 = peg$parseExpression();
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$currPos;
s5 = peg$parseOr();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c5(s2, 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$currPos;
s5 = peg$parseOr();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c5(s2, 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) {
if (input.charCodeAt(peg$currPos) === 41) {
s4 = peg$c6;
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c7);
}
}
if (s4 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c9(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;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 40) {
s1 = peg$c3;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c4);
}
}
if (s1 !== peg$FAILED) {
s2 = peg$parseExpression();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s3 = peg$c6;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c7);
}
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c10(s2);
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$currPos;
s1 = peg$parsePropertyCondition();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$parseAnd();
if (s4 !== peg$FAILED) {
s5 = peg$parsePropertyCondition();
if (s5 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c11(s1, 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$parseAnd();
if (s4 !== peg$FAILED) {
s5 = peg$parsePropertyCondition();
if (s5 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c11(s1, 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) {
s3 = [];
s4 = peg$currPos;
s5 = peg$parseAnd();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c12(s1, s2, 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$parseAnd();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c12(s1, s2, s6);
s4 = s5;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
}
} else {
peg$currPos = s4;
s4 = peg$FAILED;
}
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c13(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;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsePropertyCondition();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$parseAnd();
if (s4 !== peg$FAILED) {
s5 = peg$parsePropertyCondition();
if (s5 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c11(s1, s5);
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
s4 = peg$parseAnd();
if (s4 !== peg$FAILED) {
s5 = peg$parsePropertyCondition();
if (s5 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c11(s1, s5);
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$currPos;
s5 = peg$parseAnd();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c12(s1, s2, 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$currPos;
s5 = peg$parseAnd();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c12(s1, s2, 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) {
peg$savedPos = s0;
s1 = peg$c13(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;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsePropertyCondition();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$parseOr();
if (s4 !== peg$FAILED) {
s5 = peg$parsePropertyCondition();
if (s5 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c11(s1, 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$parseOr();
if (s4 !== peg$FAILED) {
s5 = peg$parsePropertyCondition();
if (s5 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c11(s1, 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) {
s3 = [];
s4 = peg$currPos;
s5 = peg$parseOr();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c12(s1, s2, 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$parseOr();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c12(s1, s2, s6);
s4 = s5;
} else {
peg$currPos = s4;
s4 = peg$FAILED;
}
} else {
peg$currPos = s4;
s4 = peg$FAILED;
}
}
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c14(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;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsePropertyCondition();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$currPos;
s4 = peg$parseOr();
if (s4 !== peg$FAILED) {
s5 = peg$parsePropertyCondition();
if (s5 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c11(s1, s5);
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$currPos;
s4 = peg$parseOr();
if (s4 !== peg$FAILED) {
s5 = peg$parsePropertyCondition();
if (s5 !== peg$FAILED) {
peg$savedPos = s3;
s4 = peg$c11(s1, s5);
s3 = s4;
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
} else {
peg$currPos = s3;
s3 = peg$FAILED;
}
}
if (s2 !== peg$FAILED) {
s3 = [];
s4 = peg$currPos;
s5 = peg$parseOr();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c12(s1, s2, 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$currPos;
s5 = peg$parseOr();
if (s5 !== peg$FAILED) {
s6 = peg$parseExpression();
if (s6 !== peg$FAILED) {
peg$savedPos = s4;
s5 = peg$c12(s1, s2, 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) {
peg$savedPos = s0;
s1 = peg$c14(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;
}
if (s0 === peg$FAILED) {
s0 = peg$parsePropertyCondition();
}
}
}
}
}
}
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c2);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parsePropertyCondition() {
var s0, s1, s2, s3, s4, s5, s6, s7;
var key = peg$currPos * 97 + 2,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parse_();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 40) {
s2 = peg$c3;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c4);
}
}
if (s2 !== peg$FAILED) {
s3 = peg$parse_();
if (s3 !== peg$FAILED) {
s4 = peg$parsePropertyCondition();
if (s4 !== peg$FAILED) {
s5 = peg$parse_();
if (s5 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 41) {
s6 = peg$c6;
peg$currPos++;
} else {
s6 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c7);
}
}
if (s6 !== peg$FAILED) {
s7 = peg$parse_();
if (s7 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c16(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;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$parseNumLtCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseNumGtCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseNumLteCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseNumGteCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseNumEqCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseNumNeCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseDateLtCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseDateGtCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseDateLteCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseDateGteCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseDateEqCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseStrContainsCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseStrNotContainsCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseStrEqCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseStrNeCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseExistsCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseMissingCondition();
if (s0 === peg$FAILED) {
s0 = peg$parseBooleanCondition();
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c15);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseNumLteCondition() {
var s0, s1, s2, s3;
var key = peg$currPos * 97 + 3,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parsePropertyKey();
if (s1 !== peg$FAILED) {
s2 = peg$parseLteOperator();
if (s2 !== peg$FAILED) {
s3 = peg$parseNumericValue();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c18(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c17);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseNumGteCondition() {
var s0, s1, s2, s3;
var key = peg$currPos * 97 + 4,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parsePropertyKey();
if (s1 !== peg$FAILED) {
s2 = peg$parseGteOperator();
if (s2 !== peg$FAILED) {
s3 = peg$parseNumericValue();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c20(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c19);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseNumLtCondition() {
var s0, s1, s2, s3;
var key = peg$currPos * 97 + 5,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parsePropertyKey();
if (s1 !== peg$FAILED) {
s2 = peg$parseLtOperator();
if (s2 !== peg$FAILED) {
s3 = peg$parseNumericValue();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c22(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c21);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseNumGtCondition() {
var s0, s1, s2, s3;
var key = peg$currPos * 97 + 6,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parsePropertyKey();
if (s1 !== peg$FAILED) {
s2 = peg$parseGtOperator();
if (s2 !== peg$FAILED) {
s3 = peg$parseNumericValue();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c24(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c23);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseNumEqCondition() {
var s0, s1, s2, s3;
var key = peg$currPos * 97 + 7,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parsePropertyKey();
if (s1 !== peg$FAILED) {
s2 = peg$parseEqOperator();
if (s2 !== peg$FAILED) {
s3 = peg$parseNumericValue();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c26(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c25);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseNumNeCondition() {
var s0, s1, s2, s3;
var key = peg$currPos * 97 + 8,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parsePropertyKey();
if (s1 !== peg$FAILED) {
s2 = peg$parseNeOperator();
if (s2 !== peg$FAILED) {
s3 = peg$parseNumericValue();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c28(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c27);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseDateLteCondition() {
var s0, s1, s2, s3;
var key = peg$currPos * 97 + 9,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parsePropertyKey();
if (s1 !== peg$FAILED) {
s2 = peg$parseLteOperator();
if (s2 !== peg$FAILED) {
s3 = peg$parseDateValue();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c30(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c29);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseDateGteCondition() {
var s0, s1, s2, s3;
var key = peg$currPos * 97 + 10,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parsePropertyKey();
if (s1 !== peg$FAILED) {
s2 = peg$parseGteOperator();
if (s2 !== peg$FAILED) {
s3 = peg$parseDateValue();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c32(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c31);
}
}
peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
return s0;
}
function peg$parseDateLtCondition() {
var s0, s1, s2, s3;
var key = peg$currPos * 97 + 11,
cached = peg$resultsCache[key];
if (cached) {
peg$currPos = cached.nextPos;
return cached.result;
}
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parsePropertyKey