UNPKG

@hyperdx/lucene

Version:

Lucene query parser and formatter for JavaScript created using PEG.js

1,850 lines (1,711 loc) 65.8 kB
/* * Generated by PEG.js 0.10.0. * * http://pegjs.org/ */ "use strict"; function peg$subclass(child, parent) { function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); } function peg$SyntaxError(message, expected, found, location) { this.message = message; this.expected = expected; this.found = found; this.location = location; this.name = "SyntaxError"; if (typeof Error.captureStackTrace === "function") { Error.captureStackTrace(this, peg$SyntaxError); } } peg$subclass(peg$SyntaxError, Error); peg$SyntaxError.buildMessage = function(expected, found) { 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(start, left, operator, right) { var node = { 'start': start, 'left': left, }; var right = right.length == 0 ? null : right[0]['right'] == null ? right[0]['left'] : right[0]; if (right != null) { node['operator'] = operator == '' ? '<implicit>' : operator[0]; node['right'] = right; } return node; }, peg$c4 = function(operator, right) { return right; }, peg$c5 = 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 == '' ? '<implicit>' : operator[0]; node['right'] = right; } return node; }, peg$c6 = function(field_exp) { return field_exp; }, peg$c7 = "(", peg$c8 = peg$literalExpectation("(", false), peg$c9 = ")", peg$c10 = peg$literalExpectation(")", false), peg$c11 = function(node) { node[0]['parenthesized'] = true; return node[0]; }, peg$c12 = function(fieldname, range) { range['field'] = fieldname == null || fieldname.label == '' ? "<implicit>" : fieldname.label; range['fieldLocation'] = fieldname == null || fieldname.label == '' ? null : fieldname.location; return range; }, peg$c13 = function(fieldname, node) { node['field']= fieldname.label; node['fieldLocation'] = fieldname.location; return node; }, peg$c14 = function(fieldname, term) { var fieldexp = { 'field': fieldname == null || fieldname.label == '' ? "<implicit>" : fieldname.label, 'fieldLocation': fieldname == null || fieldname.label == '' ? null : fieldname.location, }; for(var key in term) fieldexp[key] = term[key]; return fieldexp; }, peg$c15 = /^[:]/, peg$c16 = peg$classExpectation([":"], false, false), peg$c17 = function(fieldname) { return { label: fieldname.label, location: fieldname.location } }, peg$c18 = function(op, term, proximity, boost) { var result = { 'term': term, 'quoted': true, 'regex' : false, 'termLocation': location() }; if('' != proximity) { result['proximity'] = proximity; } if('' != boost) { result['boost'] = boost; } if('' != op) { result['prefix'] = op; } return result; }, peg$c19 = function(op, term, similarity, boost) { var result = { 'term': term.label, 'quoted': false, 'regex': false, 'termLocation': location() }; if('' != similarity) { result['similarity'] = similarity; } if('' != boost) { result['boost'] = boost; } if('' != op) { result['prefix'] = op; } return result; }, peg$c20 = "\\", peg$c21 = peg$literalExpectation("\\", false), peg$c22 = function(sequence) { return '\\' + sequence; }, peg$c23 = ".", peg$c24 = peg$literalExpectation(".", false), peg$c25 = /^[^ \t\r\n\f{}()"\/\^~[\]]/, peg$c26 = peg$classExpectation([" ", "\t", "\r", "\n", "\f", "{", "}", "(", ")", "\"", "/", "^", "~", "[", "]"], true, false), peg$c27 = function(term) { return term.join(''); }, peg$c28 = function(term) { return { label: term.join(''), location: location(), }; }, peg$c29 = /^[^: \t\r\n\f{}()"\^~[\]]/, peg$c30 = peg$classExpectation([":", " ", "\t", "\r", "\n", "\f", "{", "}", "(", ")", "\"", "^", "~", "[", "]"], true, false), peg$c31 = "\"", peg$c32 = peg$literalExpectation("\"", false), peg$c33 = function(chars) { return chars.join(''); }, peg$c34 = "/", peg$c35 = peg$literalExpectation("/", false), peg$c36 = function(chars) { return chars.join('') }, peg$c37 = peg$anyExpectation(), peg$c38 = function(char) { return char; }, peg$c39 = "+", peg$c40 = peg$literalExpectation("+", false), peg$c41 = "-", peg$c42 = peg$literalExpectation("-", false), peg$c43 = "!", peg$c44 = peg$literalExpectation("!", false), peg$c45 = "{", peg$c46 = peg$literalExpectation("{", false), peg$c47 = "}", peg$c48 = peg$literalExpectation("}", false), peg$c49 = "[", peg$c50 = peg$literalExpectation("[", false), peg$c51 = "]", peg$c52 = peg$literalExpectation("]", false), peg$c53 = "^", peg$c54 = peg$literalExpectation("^", false), peg$c55 = "?", peg$c56 = peg$literalExpectation("?", false), peg$c57 = ":", peg$c58 = peg$literalExpectation(":", false), peg$c59 = "&", peg$c60 = peg$literalExpectation("&", false), peg$c61 = "|", peg$c62 = peg$literalExpectation("|", false), peg$c63 = "'", peg$c64 = peg$literalExpectation("'", false), peg$c65 = "~", peg$c66 = peg$literalExpectation("~", false), peg$c67 = "*", peg$c68 = peg$literalExpectation("*", false), peg$c69 = " ", peg$c70 = peg$literalExpectation(" ", false), peg$c71 = function(proximity) { return proximity; }, peg$c72 = function(boost) { return boost; }, peg$c73 = function(fuzziness) { return fuzziness == '' || fuzziness == null ? 0.5 : fuzziness; }, peg$c74 = "0.", peg$c75 = peg$literalExpectation("0.", false), peg$c76 = /^[0-9]/, peg$c77 = peg$classExpectation([["0", "9"]], false, false), peg$c78 = function(val) { return parseFloat("0." + val.join('')); }, peg$c79 = function(val) { return parseInt(val.join('')); }, peg$c80 = "TO", peg$c81 = peg$literalExpectation("TO", false), peg$c82 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': 'both' }; }, peg$c83 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': 'none' }; }, peg$c84 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': 'left' }; }, peg$c85 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': 'right' }; }, peg$c86 = function(operator) { return operator; }, peg$c87 = "OR NOT", peg$c88 = peg$literalExpectation("OR NOT", false), peg$c89 = "AND NOT", peg$c90 = peg$literalExpectation("AND NOT", false), peg$c91 = "OR", peg$c92 = peg$literalExpectation("OR", false), peg$c93 = "AND", peg$c94 = peg$literalExpectation("AND", false), peg$c95 = "NOT", peg$c96 = peg$literalExpectation("NOT", false), peg$c97 = "||", peg$c98 = peg$literalExpectation("||", false), peg$c99 = "&&", peg$c100 = peg$literalExpectation("&&", false), peg$c101 = peg$otherExpectation("whitespace"), peg$c102 = /^[ \t\r\n\f]/, peg$c103 = peg$classExpectation([" ", "\t", "\r", "\n", "\f"], false, false), peg$currPos = 0, peg$savedPos = 0, peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, peg$result; if ("startRule" in options) { if (!(options.startRule in peg$startRuleFunctions)) { throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); } peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } function text() { return input.substring(peg$savedPos, peg$currPos); } function location() { return peg$computeLocation(peg$savedPos, peg$currPos); } function expected(description, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildStructuredError( [peg$otherExpectation(description)], input.substring(peg$savedPos, peg$currPos), location ); } function error(message, location) { location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) throw peg$buildSimpleError(message, location); } function peg$literalExpectation(text, ignoreCase) { return { type: "literal", text: text, ignoreCase: ignoreCase }; } function peg$classExpectation(parts, inverted, ignoreCase) { return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; } function peg$anyExpectation() { return { type: "any" }; } function peg$endExpectation() { return { type: "end" }; } function peg$otherExpectation(description) { return { type: "other", description: description }; } function peg$computePosDetails(pos) { 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, s5; 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$parsegroup_exp(); if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parseoperator_exp(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parseoperator_exp(); } if (s3 !== peg$FAILED) { s4 = []; s5 = peg$parsenode(); while (s5 !== peg$FAILED) { s4.push(s5); s5 = peg$parsenode(); } if (s4 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c3(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; } 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$c4(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$c5(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$c6(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, s6; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 40) { s1 = peg$c7; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c8); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parse_(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parse_(); } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parsenode(); if (s4 !== peg$FAILED) { while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parsenode(); } } else { s3 = peg$FAILED; } if (s3 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s4 = peg$c9; peg$currPos++; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } } 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$c11(s3); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } return s0; } function peg$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$c12(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$c13(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$c14(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; s0 = peg$currPos; s1 = peg$parseunquoted_term(); if (s1 !== peg$FAILED) { if (peg$c15.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c16); } } if (s2 !== peg$FAILED) { s3 = []; s4 = peg$parse_(); while (s4 !== peg$FAILED) { s3.push(s4); s4 = peg$parse_(); } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c17(s1); 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$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$c18(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$c19(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; } } return s0; } function peg$parserterm_char() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { s1 = peg$c20; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s1 !== peg$FAILED) { s2 = peg$parseEscapeSequence(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c22(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 46) { s0 = peg$c23; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c24); } } if (s0 === peg$FAILED) { if (peg$c25.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c26); } } } } return s0; } function peg$parseranged_term() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parserterm_char(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parserterm_char(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c27(s1); } s0 = s1; return s0; } function peg$parseunquoted_term() { var s0, s1, s2; s0 = peg$currPos; s1 = []; s2 = peg$parseterm_char(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parseterm_char(); } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c28(s1); } s0 = s1; return s0; } function peg$parseterm_char() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { s1 = peg$c20; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s1 !== peg$FAILED) { s2 = peg$parseEscapeSequence(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c22(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 46) { s0 = peg$c23; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c24); } } if (s0 === peg$FAILED) { if (peg$c29.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c30); } } } } return s0; } function peg$parsequoted_term() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { s1 = peg$c31; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c32); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parseDoubleStringCharacter(); while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parseDoubleStringCharacter(); } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { s3 = peg$c31; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c32); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c33(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$parseregex_term() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 47) { s1 = peg$c34; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c35); } } if (s1 !== peg$FAILED) { s2 = []; s3 = peg$parseRegexCharacter(); if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); s3 = peg$parseRegexCharacter(); } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { s3 = peg$c34; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c35); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c36(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$parseDoubleStringCharacter() { var s0, s1, s2; s0 = peg$currPos; s1 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 34) { s2 = peg$c31; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c32); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { s2 = peg$c20; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } } peg$silentFails--; if (s2 === peg$FAILED) { s1 = void 0; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { if (input.length > peg$currPos) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c37); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c38(s2); s0 = s1; } 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) === 92) { s1 = peg$c20; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s1 !== peg$FAILED) { s2 = peg$parseEscapeSequence(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c22(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } return s0; } function peg$parseRegexCharacter() { var s0, s1, s2; s0 = peg$currPos; s1 = peg$currPos; peg$silentFails++; if (input.charCodeAt(peg$currPos) === 47) { s2 = peg$c34; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c35); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { s2 = peg$c20; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } } peg$silentFails--; if (s2 === peg$FAILED) { s1 = void 0; } else { peg$currPos = s1; s1 = peg$FAILED; } if (s1 !== peg$FAILED) { if (input.length > peg$currPos) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c37); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c38(s2); s0 = s1; } 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) === 92) { s1 = peg$c20; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s1 !== peg$FAILED) { s2 = peg$parseEscapeSequence(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c22(s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } return s0; } function peg$parseEscapeSequence() { var s0; if (input.charCodeAt(peg$currPos) === 43) { s0 = peg$c39; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c40); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { s0 = peg$c41; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c42); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 33) { s0 = peg$c43; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c44); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 40) { s0 = peg$c7; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c8); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { s0 = peg$c9; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c10); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 123) { s0 = peg$c45; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c46); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s0 = peg$c47; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c48); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 91) { s0 = peg$c49; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c50); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { s0 = peg$c51; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c52); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 94) { s0 = peg$c53; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c54); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { s0 = peg$c31; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c32); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 63) { s0 = peg$c55; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c56); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { s0 = peg$c57; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c58); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { s0 = peg$c20; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 38) { s0 = peg$c59; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c60); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 124) { s0 = peg$c61; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c62); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { s0 = peg$c63; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c64); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { s0 = peg$c34; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c35); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 126) { s0 = peg$c65; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c66); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 42) { s0 = peg$c67; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c68); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 32) { s0 = peg$c69; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c70); } } } } } } } } } } } } } } } } } } } } } } return s0; } function peg$parseproximity_modifier() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 126) { s1 = peg$c65; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c66); } } if (s1 !== peg$FAILED) { s2 = peg$parseint_exp(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c71(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$c53; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c54); } } if (s1 !== peg$FAILED) { s2 = peg$parsedecimal_or_int_exp(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c72(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$c65; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c66); } } if (s1 !== peg$FAILED) { s2 = peg$parsedecimal_exp(); if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c73(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$c74) { s1 = peg$c74; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c75); } } if (s1 !== peg$FAILED) { s2 = []; if (peg$c76.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c77); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); if (peg$c76.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c77); } } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c78(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$c76.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c77); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); if (peg$c76.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c77); } } } } else { s1 = peg$FAILED; } if (s1 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c79(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$c49; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c50); } } if (s1 !== peg$FAILED) { s2 = peg$parseranged_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$c80) { s4 = peg$c80; peg$currPos += 2; } else { s4 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c81); } } if (s4 !== peg$FAILED) { s5 = []; s6 = peg$parse_(); if (s6 !== peg$FAILED