UNPKG

@wener/miniquery

Version:

SQL Where like **safe** filter expression for ORM.

1,297 lines (1,296 loc) 94.1 kB
// @generated by Peggy 5.0.5. // // https://peggyjs.org/ /* eslint-disable @typescript-eslint/interface-name-prefix,@typescript-eslint/no-empty-interface,no-case-declarations,no-control-regex,prefer-const */ // ts-nocheck function _array_like_to_array(arr, len) { if (len == null || len > arr.length) len = arr.length; for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i]; return arr2; } function _array_without_holes(arr) { if (Array.isArray(arr)) return _array_like_to_array(arr); } function _assert_this_initialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _call_super(_this, derived, args) { derived = _get_prototype_of(derived); return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args)); } function _class_call_check(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _construct(Parent, args, Class) { if (_is_native_reflect_construct()) { _construct = Reflect.construct; } else { _construct = function construct(Parent, args, Class) { var a = [ null ]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _set_prototype_of(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _defineProperties(target, props) { for(var i = 0; i < props.length; i++){ var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _create_class(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _get_prototype_of(o) { _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _get_prototype_of(o); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _set_prototype_of(subClass, superClass); } function _is_native_function(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } function _iterable_to_array(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _non_iterable_spread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _possible_constructor_return(self, call) { if (call && (_type_of(call) === "object" || typeof call === "function")) { return call; } return _assert_this_initialized(self); } function _set_prototype_of(o, p) { _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _set_prototype_of(o, p); } function _to_consumable_array(arr) { return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread(); } function _type_of(obj) { "@swc/helpers - typeof"; return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } function _unsupported_iterable_to_array(o, minLen) { if (!o) return; if (typeof o === "string") return _array_like_to_array(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen); } function _wrap_native_super(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrap_native_super = function wrapNativeSuper(Class) { if (Class === null || !_is_native_function(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _get_prototype_of(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _set_prototype_of(Wrapper, Class); }; return _wrap_native_super(Class); } function _is_native_reflect_construct() { try { var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})); } catch (_) {} return (_is_native_reflect_construct = function() { return !!result; })(); } var pick = function(obj, keys) { return keys.reduce(function(o, k) { return o[k] = obj[k], o; }, {}); }; // https://mikro-orm.io/docs/query-conditions var OPERATORS = { '>=': '$gte', '<=': '$lte', '>': '$gt', '<': '$lt', // ":":"$eq",// fixme has '=': '$eq', '==': '$eq', '===': '$eq', '<>': '$ne', '!=': '$ne', in: '$in', 'not in': '$nin', '&&': '$and', and: '$and', '||': '$or', or: '$or', nor: '$nor', '!': '$not', '~': '$re', like: '$like', ilike: '$ilike', // https://www.postgresql.org/docs/current/functions-json.html '@>': '$contains', '<@': '$contained', // $overlap && // https://www.postgresql.org/docs/current/functions-textsearch.html // $fulltext between: '$between' }; // https://www.postgresql.org/docs/current/functions-array.html var ARRAY_OPERATORS = Object.assign({ '&&': '$overlap' }, pick(OPERATORS, [ '@>', '<@' ])); var peg$SyntaxError = /*#__PURE__*/ function(SyntaxError1) { "use strict"; _inherits(peg$SyntaxError, SyntaxError1); function peg$SyntaxError(message, expected, found, location) { _class_call_check(this, peg$SyntaxError); var _this; _this = _call_super(this, peg$SyntaxError, [ message ]); _this.expected = expected; _this.found = found; _this.location = location; _this.name = 'SyntaxError'; return _this; } _create_class(peg$SyntaxError, [ { key: "format", value: function format(sources) { var _this = this; var str = 'Error: ' + this.message; if (this.location) { var src = null; var st = sources.find(function(s) { return s.source === _this.location.source; }); if (st) { src = st.text.split(/\r\n|\n|\r/g); } 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 = ''.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 + ' | ' + ''.padEnd(s.column - 1, ' ') + ''.padEnd(hatLen, '^'); } else { str += '\n at ' + loc; } } return str; } } ], [ { key: "buildMessage", value: function buildMessage(expected, found) { function hex(ch) { return ch.codePointAt(0).toString(16).toUpperCase(); } var nonPrintable = Object.prototype.hasOwnProperty.call(RegExp.prototype, 'unicode') ? new RegExp('[\\p{C}\\p{Mn}\\p{Mc}]', 'gu') : null; function unicodeEscape(s) { if (nonPrintable) { return s.replace(nonPrintable, function(ch) { return "\\u{" + hex(ch) + '}'; }); } return s; } function literalEscape(s) { return unicodeEscape(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 unicodeEscape(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); })); } var DESCRIBE_EXPECTATION_FNS = { literal: function literal(expectation) { return '"' + literalEscape(expectation.text) + '"'; }, class: function _class(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('') + ']' + (expectation.unicode ? 'u' : ''); }, any: function any() { return 'any character'; }, end: function end() { return 'end of input'; }, other: function other(expectation) { return expectation.description; } }; function describeExpectation(expectation) { return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); } function describeExpected(expected) { var descriptions = expected.map(describeExpectation); descriptions.sort(); if (descriptions.length > 0) { var j = 1; for(var i = 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.'; } } ]); return peg$SyntaxError; }(_wrap_native_super(SyntaxError)); function peg$parse(input, options) { options = options !== undefined ? options : {}; var peg$FAILED = {}; var peg$source = options.grammarSource; var peg$startRuleFunctions = { Main: peg$parseMain }; var peg$startRuleFunction = peg$parseMain; var peg$c0 = '&&'; var peg$c1 = '||'; var peg$c2 = '('; var peg$c3 = ')'; var peg$c4 = '!'; var peg$c5 = 'between'; var peg$c6 = 'and'; var peg$c7 = '>='; var peg$c8 = '<='; var peg$c9 = '<>'; var peg$c10 = '==='; var peg$c11 = '=='; var peg$c12 = '!='; var peg$c13 = '@>'; var peg$c14 = '<@'; var peg$c15 = '~'; var peg$c16 = ','; var peg$c17 = '['; var peg$c18 = ']'; var peg$c19 = '.'; var peg$c20 = 'in'; var peg$c21 = 'IN'; var peg$c22 = 'is'; var peg$c23 = 'IS'; var peg$c24 = 'like'; var peg$c25 = 'LIKE'; var peg$c26 = 'ilike'; var peg$c27 = 'ILIKE'; var peg$c28 = 'AND'; var peg$c29 = 'not'; var peg$c30 = 'NOT'; var peg$c31 = 'or'; var peg$c32 = 'OR'; var peg$c33 = "'"; var peg$c34 = '"'; var peg$c35 = 'null'; var peg$c36 = 'NULL'; var peg$c37 = 'true'; var peg$c38 = 'false'; var peg$c39 = 'TRUE'; var peg$c40 = 'FALSE'; var peg$c41 = '/*'; var peg$c42 = '*/'; var peg$c43 = '--'; var peg$c44 = '\n'; var peg$r0 = /^[<>]/; var peg$r1 = /^[:=]/; var peg$r2 = /^[a-zA-Z]/; var peg$r3 = /^[_a-zA-Z0-9]/; var peg$r4 = /^[0-9]/; var peg$r5 = /^[^']/; var peg$r6 = /^[^"]/; var peg$r7 = /^[^*]/; var peg$r8 = /^[^\r\n]/; var peg$r9 = /^[ \t\n\r]/; var peg$e0 = peg$literalExpectation('&&', false); var peg$e1 = peg$literalExpectation('||', false); var peg$e2 = peg$literalExpectation('(', false); var peg$e3 = peg$literalExpectation(')', false); var peg$e4 = peg$literalExpectation('!', false); var peg$e5 = peg$literalExpectation('between', false); var peg$e6 = peg$literalExpectation('and', false); var peg$e7 = peg$literalExpectation('>=', false); var peg$e8 = peg$literalExpectation('<=', false); var peg$e9 = peg$literalExpectation('<>', false); var peg$e10 = peg$classExpectation([ '<', '>' ], false, false, false); var peg$e11 = peg$literalExpectation('===', false); var peg$e12 = peg$literalExpectation('==', false); var peg$e13 = peg$literalExpectation('!=', false); var peg$e14 = peg$classExpectation([ ':', '=' ], false, false, false); var peg$e15 = peg$literalExpectation('@>', false); var peg$e16 = peg$literalExpectation('<@', false); var peg$e17 = peg$literalExpectation('~', false); var peg$e18 = peg$literalExpectation(',', false); var peg$e19 = peg$literalExpectation('[', false); var peg$e20 = peg$literalExpectation(']', false); var peg$e21 = peg$literalExpectation('.', false); var peg$e22 = peg$classExpectation([ [ 'a', 'z' ], [ 'A', 'Z' ] ], false, false, false); var peg$e23 = peg$classExpectation([ '_', [ 'a', 'z' ], [ 'A', 'Z' ], [ '0', '9' ] ], false, false, false); var peg$e24 = peg$literalExpectation('in', false); var peg$e25 = peg$literalExpectation('IN', false); var peg$e26 = peg$literalExpectation('is', false); var peg$e27 = peg$literalExpectation('IS', false); var peg$e28 = peg$literalExpectation('like', false); var peg$e29 = peg$literalExpectation('LIKE', false); var peg$e30 = peg$literalExpectation('ilike', false); var peg$e31 = peg$literalExpectation('ILIKE', false); var peg$e32 = peg$literalExpectation('AND', false); var peg$e33 = peg$literalExpectation('not', false); var peg$e34 = peg$literalExpectation('NOT', false); var peg$e35 = peg$literalExpectation('or', false); var peg$e36 = peg$literalExpectation('OR', false); var peg$e37 = peg$classExpectation([ [ '0', '9' ] ], false, false, false); var peg$e38 = peg$literalExpectation("'", false); var peg$e39 = peg$classExpectation([ "'" ], true, false, false); var peg$e40 = peg$literalExpectation('"', false); var peg$e41 = peg$classExpectation([ '"' ], true, false, false); var peg$e42 = peg$literalExpectation('null', false); var peg$e43 = peg$literalExpectation('NULL', false); var peg$e44 = peg$literalExpectation('true', false); var peg$e45 = peg$literalExpectation('false', false); var peg$e46 = peg$literalExpectation('TRUE', false); var peg$e47 = peg$literalExpectation('FALSE', false); var peg$e48 = peg$otherExpectation('whitespace'); var peg$e49 = peg$literalExpectation('/*', false); var peg$e50 = peg$classExpectation([ '*' ], true, false, false); var peg$e51 = peg$literalExpectation('*/', false); var peg$e52 = peg$literalExpectation('--', false); var peg$e53 = peg$classExpectation([ '\r', '\n' ], true, false, false); var peg$e54 = peg$literalExpectation('\n', false); var peg$e55 = peg$classExpectation([ ' ', '\t', '\n', '\r' ], false, false, false); var peg$e56 = peg$anyExpectation(); function peg$f0(next) { return next; } function peg$f1(next) { return next; } function peg$f2(left, op, right) { return { op: op, right: right }; } function peg$f3(left, rest) { return (rest === null || rest === void 0 ? void 0 : rest.right) ? _compound(rest === null || rest === void 0 ? void 0 : rest.op, left, rest === null || rest === void 0 ? void 0 : rest.right) : left; } function peg$f4(next) { return next; } function peg$f5(next) { return { $not: next }; } function peg$f6(field, value1, value2) { return _make(field, '$between', value1, value2); } function peg$f7(field, op, value) { return _make(field, op, value); } function peg$f8(field, op, value) { return _make(field, ARRAY_OPERATORS[op], value); } function peg$f9(field, op, value) { return _make(field, op, value); } function peg$f10(field, op) { return _make(field, '=', null); } function peg$f11(field, op) { return _make(field, '!=', null); } function peg$f12(field, op, value) { return _make(field, op, value); } function peg$f13(field, op, value) { return _make(field, op, value); } function peg$f14(next) { return next || []; } function peg$f15(next) { return next; } function peg$f16(next) { return next; } function peg$f17(a) { return a; } function peg$f18() { return text(); } function peg$f19() { return 'in'; } function peg$f20() { return 'is'; } function peg$f21() { return 'like'; } function peg$f22() { return 'ilike'; } function peg$f23() { return 'and'; } function peg$f24() { return 'not'; } function peg$f25() { return 'or'; } function peg$f26() { return parseInt(text()); } function peg$f27() { return parseFloat(text()); } function peg$f28(v) { return v.join(''); } function peg$f29(v) { return v.join(''); } function peg$f30() { return null; } function peg$f31() { return text().toLowerCase() === 'true'; } function peg$f32() { return ''; } function peg$f33() { return ' '; } var peg$currPos = options.peg$currPos | 0; var peg$savedPos = peg$currPos; var peg$posDetailsCache = [ { line: 1, column: 1 } ]; var peg$maxFailPos = peg$currPos; var peg$maxFailExpected = options.peg$maxFailExpected || []; var peg$silentFails = options.peg$silentFails | 0; var peg$result; if (options.startRule) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error('Can\'t start parsing from rule "' + options.startRule + '".'); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } function offset() { return peg$savedPos; } function range() { return { source: peg$source, start: peg$savedPos, end: peg$currPos }; } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location) { location = location !== undefined ? 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 !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos); throw peg$buildSimpleError(message, location); } function peg$getUnicode() { var pos = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : peg$currPos; var cp = input.codePointAt(pos); if (cp === undefined) { return ''; } return String.fromCodePoint(cp); } function peg$literalExpectation(text, ignoreCase) { return { type: 'literal', text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase, unicode) { return { type: 'class', parts: parts, inverted: inverted, ignoreCase: ignoreCase, unicode: unicode }; } function peg$anyExpectation() { return { type: 'any' }; } function peg$endExpectation() { return { type: 'end' }; } function peg$otherExpectation(description) { return { type: 'other', description: description }; } function peg$computePosDetails(pos) { var details = peg$posDetailsCache[pos]; var p; if (details) { return details; } else { if (pos >= peg$posDetailsCache.length) { p = peg$posDetailsCache.length - 1; } else { p = pos; while(!peg$posDetailsCache[--p]){} } details = peg$posDetailsCache[p]; details = { line: details.line, 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, offset) { 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 } }; if (offset && peg$source && typeof peg$source.offset === 'function') { res.start = peg$source.offset(res.start); res.end = peg$source.offset(res.end); } return res; } function peg$fail(expected) { 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$parseMain() { var s0, s1, s2; s0 = peg$currPos; s1 = peg$parseQueryExpr(); if (s1 !== peg$FAILED) { s2 = peg$parseEOF(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f0(s1); } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseQueryExpr() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse_(); s2 = peg$parseCompoundExpr(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); s0 = s2; } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseExpr() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parse_(); s2 = peg$parseCompoundExpr(); if (s2 !== peg$FAILED) { s3 = peg$parse_(); peg$savedPos = s0; s0 = peg$f1(s2); } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseCompoundExpr() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = peg$parseRelExpr(); if (s1 !== peg$FAILED) { s2 = peg$currPos; s3 = peg$currPos; s4 = peg$parse_(); if (input.substr(peg$currPos, 2) === peg$c0) { s5 = peg$c0; peg$currPos += 2; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e0); } } if (s5 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c1) { s5 = peg$c1; peg$currPos += 2; } else { s5 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e1); } } } if (s5 !== peg$FAILED) { s6 = peg$parse_(); s4 = [ s4, s5, s6 ]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } if (s3 === peg$FAILED) { s3 = peg$currPos; s4 = peg$parse__(); if (s4 !== peg$FAILED) { s5 = peg$parseand(); if (s5 === peg$FAILED) { s5 = peg$parseor(); } if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { s4 = [ s4, s5, s6 ]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } if (s3 !== peg$FAILED) { s4 = peg$parseCompoundExpr(); if (s4 !== peg$FAILED) { peg$savedPos = s2; s2 = peg$f2(s1, s3, s4); } else { peg$currPos = s2; s2 = peg$FAILED; } } else { peg$currPos = s2; s2 = peg$FAILED; } if (s2 === peg$FAILED) { s2 = null; } peg$savedPos = s0; s0 = peg$f3(s1, s2); } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseRelExpr() { var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 40) { s1 = peg$c2; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e2); } } if (s1 !== peg$FAILED) { s2 = peg$parseExpr(); if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s3 = peg$c3; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e3); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f4(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.charCodeAt(peg$currPos) === 33) { s1 = peg$c4; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e4); } } if (s1 !== peg$FAILED) { s2 = peg$parseRelExpr(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f5(s2); } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseField(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { if (input.substr(peg$currPos, 7) === peg$c5) { s3 = peg$c5; peg$currPos += 7; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e5); } } if (s3 !== peg$FAILED) { s4 = peg$parse__(); if (s4 !== peg$FAILED) { s5 = peg$parseliteral(); if (s5 !== peg$FAILED) { s6 = peg$parse__(); if (s6 !== peg$FAILED) { if (input.substr(peg$currPos, 3) === peg$c6) { s7 = peg$c6; peg$currPos += 3; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e6); } } if (s7 !== peg$FAILED) { s8 = peg$parse__(); if (s8 !== peg$FAILED) { s9 = peg$parseliteral(); if (s9 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f6(s1, s5, s9); } 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; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseField(); if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (input.substr(peg$currPos, 2) === peg$c7) { s3 = peg$c7; peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e7); } } if (s3 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c8) { s3 = peg$c8; peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e8); } } if (s3 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c9) { s3 = peg$c9; peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e9); } } if (s3 === peg$FAILED) { s3 = input.charAt(peg$currPos); if (peg$r0.test(s3)) { peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e10); } } if (s3 === peg$FAILED) { if (input.substr(peg$currPos, 3) === peg$c10) { s3 = peg$c10; peg$currPos += 3; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e11); } } if (s3 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c11) { s3 = peg$c11; peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e12); } } if (s3 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c12) { s3 = peg$c12; peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e13); } } if (s3 === peg$FAILED) { s3 = input.charAt(peg$currPos); if (peg$r1.test(s3)) { peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e14); } } } } } } } } } if (s3 !== peg$FAILED) { s4 = peg$parse_(); s5 = peg$parseliteral(); if (s5 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f7(s1, s3, s5); } 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$parseField(); if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (input.substr(peg$currPos, 2) === peg$c13) { s3 = peg$c13; peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e15); } } if (s3 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c14) { s3 = peg$c14; peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e16); } } if (s3 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c0) { s3 = peg$c0; peg$currPos += 2; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e0); } } } } if (s3 !== peg$FAILED) { s4 = peg$parse_(); s5 = peg$parseArray(); if (s5 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f8(s1, s3, s5); } 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$parseField(); if (s1 !== peg$FAILED) { s2 = peg$parse_(); if (input.charCodeAt(peg$currPos) === 126) { s3 = peg$c15; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$e17); } } if (s3 !== peg$FAILED) { s4 = peg$parse_(); s5 = peg$parsestring(); if (s5 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f9(s1, s3, s5); } 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$parseField(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$currPos; s4 = peg$parseis(); if (s4 !== peg$FAILED) { s5 = peg$parse__(); if (s5 !== peg$FAILED) { s6 = peg$parsenull(); if (s6 !== peg$FAILED) { s4 = [ s4, s5, s6 ]; s3 = s4; } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } } else { peg$currPos = s3; s3 = peg$FAILED; } if (s3 !== peg$FAILED) { peg$savedPos = s0; s0 = peg$f10(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$parseField(); if (s1 !== peg$FAILED) { s2 = peg$parse__(); if (s2 !== peg$FAILED) { s3 = peg$currPos; s4 = peg$parseis(); if (s4 !== peg$FAILED) { s5 = peg$parse__(); if (s5 !== peg$FAILED) { s6 = peg$parsenot(); if (s6 !== peg$FAILED) { s7 = peg$parse__(); if (s7 !== peg$FAILED) {