UNPKG

lucene-query-parser

Version:

Lucene Query Parser for JavaScript created using PEG.js

1,775 lines (1,649 loc) 57.7 kB
/* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ (function(root, factory) { if (typeof define === "function" && define.amd) { define([], factory); } else if (typeof module === "object" && module.exports) { module.exports = factory(); } else { root.lucenequeryparser = factory(); } })(this, function() { "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) { var DESCRIBE_EXPECTATION_FNS = { literal: function(expectation) { return "\"" + literalEscape(expectation.text) + "\""; }, "class": function(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(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) { 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 = { start: peg$parsestart }, peg$startRuleFunction = peg$parsestart, peg$c0 = function(node) { return node[0]; }, peg$c1 = function() { return {}; }, peg$c2 = function(operator) { return { 'operator': operator }; }, peg$c3 = function(operator, right) { return right; }, peg$c4 = function(left, operator, right) { var node= { 'left':left }; var right = right.length == 0 ? null : right[0]['right'] == null ? right[0]['left'] : right[0]; if (right != null) { node['operator'] = operator=='' || operator==undefined ? '<implicit>' : operator[0]; node['right'] = right; } return node; }, peg$c5 = function(field_exp) { return field_exp; }, peg$c6 = "(", peg$c7 = peg$literalExpectation("(", false), peg$c8 = ")", peg$c9 = peg$literalExpectation(")", false), peg$c10 = function(fieldname, range) { range['field'] = fieldname == '' || fieldname == undefined ? "<implicit>" : fieldname; return range; }, peg$c11 = function(fieldname, node) { node['field']= fieldname; return node; }, peg$c12 = function(fieldname, term) { var fieldexp = { 'field': fieldname == '' || fieldname == undefined ? "<implicit>" : fieldname }; for(var key in term) fieldexp[key] = term[key]; return fieldexp; }, peg$c13 = /^[:]/, peg$c14 = peg$classExpectation([":"], false, false), peg$c15 = function(fieldname) { return fieldname; }, peg$c16 = function(op, term, proximity, boost) { var result = { 'term': term }; if('' != proximity) { result['proximity'] = proximity; } if('' != boost) { result['boost'] = boost; } if('' != op) { result['prefix'] = op; } return result; }, peg$c17 = function(op, term, similarity, boost) { var result = { 'term': term }; if('' != similarity) { result['similarity'] = similarity; } if('' != boost) { result['boost'] = boost; } if('' != op) { result['prefix'] = op; } return result; }, peg$c18 = function(op, term, boost) { var result = { 'term': term, 'regexpr': true }; if('' != boost) { result['boost'] = boost; } if('' != op) { result['prefix'] = op; } return result; }, peg$c19 = function(term_start, term) { var res = term_start + term.join(''); if (/^(?:AND|OR|NOT|\|\||&&)$/.test(res)) { var e = new Error('Term can not be AND, OR, NOT, ||, &&') e.name = 'SyntaxError' e.column = location throw e } return res }, peg$c20 = ".", peg$c21 = peg$literalExpectation(".", false), peg$c22 = /^[^: \t\r\n\f{}()"+-\/\^~[\]]/, peg$c23 = peg$classExpectation([":", " ", "\t", "\r", "\n", "\f", "{", "}", "(", ")", "\"", ["+", "/"], "^", "~", "[", "]"], true, false), peg$c24 = "\\", peg$c25 = peg$literalExpectation("\\", false), peg$c26 = /^[: \t\r\n\f{}()"\/\^~[\]]/, peg$c27 = peg$classExpectation([":", " ", "\t", "\r", "\n", "\f", "{", "}", "(", ")", "\"", "/", "^", "~", "[", "]"], false, false), peg$c28 = function(escaping_char) { return '\\' + escaping_char; }, peg$c29 = "+", peg$c30 = peg$literalExpectation("+", false), peg$c31 = "-", peg$c32 = peg$literalExpectation("-", false), peg$c33 = "/", peg$c34 = peg$literalExpectation("/", false), peg$c35 = function(term) { return term.join('').replace('\\/', '/'); }, peg$c36 = "\\/", peg$c37 = peg$literalExpectation("\\/", false), peg$c38 = /^[^\/]/, peg$c39 = peg$classExpectation(["/"], true, false), peg$c40 = "\"", peg$c41 = peg$literalExpectation("\"", false), peg$c42 = /^[^"]/, peg$c43 = peg$classExpectation(["\""], true, false), peg$c44 = function(term) { return term.join(''); }, peg$c45 = "~", peg$c46 = peg$literalExpectation("~", false), peg$c47 = function(proximity) { return proximity; }, peg$c48 = "^", peg$c49 = peg$literalExpectation("^", false), peg$c50 = function(boost) { return boost; }, peg$c51 = function(fuzziness) { return fuzziness == '' || fuzziness == undefined ? 0.5 : fuzziness; }, peg$c52 = "0.", peg$c53 = peg$literalExpectation("0.", false), peg$c54 = /^[0-9]/, peg$c55 = peg$classExpectation([["0", "9"]], false, false), peg$c56 = function(val) { return parseFloat("0." + val.join('')); }, peg$c57 = function(val) { return parseInt(val.join('')); }, peg$c58 = "[", peg$c59 = peg$literalExpectation("[", false), peg$c60 = "TO", peg$c61 = peg$literalExpectation("TO", false), peg$c62 = "]", peg$c63 = peg$literalExpectation("]", false), peg$c64 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': true, 'inclusive_min': true, 'inclusive_max': true }; }, peg$c65 = "{", peg$c66 = peg$literalExpectation("{", false), peg$c67 = "}", peg$c68 = peg$literalExpectation("}", false), peg$c69 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': false, 'inclusive_min': false, 'inclusive_max': false }; }, peg$c70 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': false, 'inclusive_min': false, 'inclusive_max': true }; }, peg$c71 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': false, 'inclusive_min': true, 'inclusive_max': false }; }, peg$c72 = function(operator) { return operator; }, peg$c73 = "OR", peg$c74 = peg$literalExpectation("OR", false), peg$c75 = "AND", peg$c76 = peg$literalExpectation("AND", false), peg$c77 = "NOT", peg$c78 = peg$literalExpectation("NOT", false), peg$c79 = "||", peg$c80 = peg$literalExpectation("||", false), peg$c81 = function() { return 'OR'; }, peg$c82 = "&&", peg$c83 = peg$literalExpectation("&&", false), peg$c84 = function() { return 'AND'; }, peg$c85 = "!", peg$c86 = peg$literalExpectation("!", false), peg$c87 = function() { return 'NOT'}, peg$c88 = peg$otherExpectation("whitespace"), peg$c89 = /^[ \t\r\n\f]/, peg$c90 = peg$classExpectation([" ", "\t", "\r", "\n", "\f"], false, false), peg$c91 = peg$anyExpectation(), 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) { 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$parsestart() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = []; s2 = peg$parse_(); while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parse_(); } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsenode(); if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsenode(); } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c0(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = []; s2 = peg$parse_(); while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parse_(); } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c1(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseEOF(); if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c1(); } s0 = s1; } } return s0; } function peg$parsenode() { var s0, s1, s2, s3, s4; s0 = peg$currPos; s1 = peg$parseoperator_exp(); if (s1 !== peg$FAILED) { s2 = peg$parseEOF(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c2(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseoperator_exp(); if (s1 !== peg$FAILED) { s2 = peg$parsenode(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c3(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsegroup_exp(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parseoperator_exp(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parseoperator_exp(); } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parsenode(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsenode(); } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c4(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$parsegroup_exp() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parsefield_exp(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parse_(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parse_(); } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c5(s1); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$parseparen_exp(); } return s0; } function peg$parseparen_exp() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 40) { s1 = peg$c6; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c7); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parsenode(); if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parsenode(); } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s3 = peg$c8; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c9); } } if (s3 !== peg$FAILED) { s4 = []; s5 = peg$parse_(); while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$parse_(); } if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c0(s2); 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; } return s0; } function peg$parsefield_exp() { var s0, s1, s2; s0 = peg$currPos; s1 = peg$parsefieldname(); if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parserange_operator_exp(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c10(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsefieldname(); if (s1 !== peg$FAILED) { s2 = peg$parseparen_exp(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c11(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsefieldname(); if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parseterm(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c12(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } } return s0; } function peg$parsefieldname() { var s0, s1, s2, s3, s4, s5; s0 = peg$currPos; s1 = peg$parseunquoted_term(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parse_(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parse_(); } if (s2 !== peg$FAILED) { if (peg$c13.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c14); } } if (s3 !== peg$FAILED) { s4 = []; s5 = peg$parse_(); while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$parse_(); } if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c15(s1); 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; } return s0; } function peg$parseterm() { var s0, s1, s2, s3, s4, s5, s6; s0 = peg$currPos; s1 = peg$parseprefix_operator_exp(); if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parsequoted_term(); if (s2 !== peg$FAILED) { s3 = peg$parseproximity_modifier(); if (s3 === peg$FAILED) { s3 = null; } if (s3 !== peg$FAILED) { s4 = peg$parseboost_modifier(); if (s4 === peg$FAILED) { s4 = null; } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parse_(); while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parse_(); } if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c16(s1, s2, 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; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseprefix_operator_exp(); if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); if (s2 !== peg$FAILED) { s3 = peg$parsefuzzy_modifier(); if (s3 === peg$FAILED) { s3 = null; } if (s3 !== peg$FAILED) { s4 = peg$parseboost_modifier(); if (s4 === peg$FAILED) { s4 = null; } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parse_(); while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parse_(); } if (s5 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c17(s1, s2, 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; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseprefix_operator_exp(); if (s1 === peg$FAILED) { s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parseregexpr_term(); if (s2 !== peg$FAILED) { s3 = peg$parseboost_modifier(); if (s3 === peg$FAILED) { s3 = null; } if (s3 !== peg$FAILED) { s4 = []; s5 = peg$parse_(); while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$parse_(); } if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c18(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; } } else { peg$currPos = s0; s0 = peg$FAILED; } } } return s0; } function peg$parseunquoted_term() { var s0, s1, s2, s3; s0 = peg$currPos; s1 = peg$parseterm_start_char(); if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parseterm_char(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parseterm_char(); } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c19(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseterm_start_char() { var s0; if (input.charCodeAt(peg$currPos) === 46) { s0 = peg$c20; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s0 === peg$FAILED) { s0 = peg$parseterm_escaping_char(); if (s0 === peg$FAILED) { if (peg$c22.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c23); } } } } return s0; } function peg$parseterm_escaping_char() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { s1 = peg$c24; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s1 !== peg$FAILED) { if (peg$c26.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c28(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseterm_char() { var s0; if (input.charCodeAt(peg$currPos) === 43) { s0 = peg$c29; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c30); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { s0 = peg$c31; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c32); } } if (s0 === peg$FAILED) { s0 = peg$parseterm_escaping_char(); if (s0 === peg$FAILED) { s0 = peg$parseterm_start_char(); } } } return s0; } function peg$parseregexpr_term() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 47) { s1 = peg$c33; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parseregexpr_char(); if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parseregexpr_char(); } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { s3 = peg$c33; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c35(s2); 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$parseregexpr_char() { var s0; if (input.charCodeAt(peg$currPos) === 46) { s0 = peg$c20; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s0 === peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c36) { s0 = peg$c36; peg$currPos += 2; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c37); } } if (s0 === peg$FAILED) { if (peg$c38.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c39); } } } } return s0; } function peg$parsequoted_term() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { s1 = peg$c40; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c41); } } if (s1 !== peg$FAILED) { s2 = []; if (peg$c42.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); if (peg$c42.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { s3 = peg$c40; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c41); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c44(s2); 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$parseproximity_modifier() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 126) { s1 = peg$c45; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c46); } } if (s1 !== peg$FAILED) { s2 = peg$parseint_exp(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c47(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseboost_modifier() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 94) { s1 = peg$c48; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c49); } } if (s1 !== peg$FAILED) { s2 = peg$parsedecimal_or_int_exp(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c50(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsefuzzy_modifier() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 126) { s1 = peg$c45; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c46); } } if (s1 !== peg$FAILED) { s2 = peg$parsedecimal_exp(); if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c51(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parsedecimal_or_int_exp() { var s0; s0 = peg$parsedecimal_exp(); if (s0 === peg$FAILED) { s0 = peg$parseint_exp(); } return s0; } function peg$parsedecimal_exp() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.substr(peg$currPos, 2) === peg$c52) { s1 = peg$c52; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c53); } } if (s1 !== peg$FAILED) { s2 = []; if (peg$c54.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c55); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); if (peg$c54.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c55); } } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c56(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$parseint_exp() { var s0, s1, s2; s0 = peg$currPos; s1 = []; if (peg$c54.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c55); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); if (peg$c54.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c55); } } } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c57(s1); } s0 = s1; return s0; } function peg$parserange_operator_exp() { var s0, s1, s2, s3, s4, s5, s6, s7; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 91) { s1 = peg$c58; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c59); } } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parse_(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parse_(); } if (s3 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c60) { s4 = peg$c60; peg$currPos += 2; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parse_(); if (s6 !== peg$FAILED) { while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parse_(); } } else { s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s6 = peg$parseunquoted_term(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { s7 = peg$c62; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c63); } } if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c64(s2, 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; } if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { s1 = peg$c65; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c66); } } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parse_(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parse_(); } if (s3 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c60) { s4 = peg$c60; peg$currPos += 2; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parse_(); if (s6 !== peg$FAILED) { while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parse_(); } } else { s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s6 = peg$parseunquoted_term(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s7 = peg$c67; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c68); } } if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c69(s2, 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; } if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { s1 = peg$c65; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c66); } } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parse_(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parse_(); } if (s3 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c60) { s4 = peg$c60; peg$currPos += 2; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parse_(); if (s6 !== peg$FAILED) { while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parse_(); } } else { s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s6 = peg$parseunquoted_term(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { s7 = peg$c62; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c63); } } if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c70(s2, 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; } if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 91) { s1 = peg$c58; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c59); } } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parse_(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parse_(); } if (s3 !== peg$FAILED) { if (input.substr(peg$currPos, 2) === peg$c60) { s4 = peg$c60; peg$currPos += 2; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parse_(); if (s6 !== peg$FAILED) { while (s6 !== peg$FAILED) { s5.push(s6); s6 = peg$parse_(); } } else { s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s6 = peg$parseunquoted_term(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s7 = peg$c67; peg$currPos++; } else { s7 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c68); } } if (s7 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c71(s2, s6); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$F