UNPKG

lucene

Version:

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

1,846 lines (1,708 loc) 66.9 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) { var result = { 'term': term, 'quoted': false, 'regex': true, 'termLocation': location() }; return result; }, peg$c20 = 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$c21 = "\\", peg$c22 = peg$literalExpectation("\\", false), peg$c23 = function(sequence) { return '\\' + sequence; }, peg$c24 = ".", peg$c25 = peg$literalExpectation(".", false), peg$c26 = /^[^ \t\r\n\f{}()"\/\^~[\]]/, peg$c27 = peg$classExpectation([" ", "\t", "\r", "\n", "\f", "{", "}", "(", ")", "\"", "/", "^", "~", "[", "]"], true, false), peg$c28 = function(term) { return term.join(''); }, peg$c29 = function(term) { return { label: term.join(''), location: location(), }; }, peg$c30 = /^[^: \t\r\n\f{}()"\/\^~[\]]/, peg$c31 = peg$classExpectation([":", " ", "\t", "\r", "\n", "\f", "{", "}", "(", ")", "\"", "/", "^", "~", "[", "]"], true, false), peg$c32 = "\"", peg$c33 = peg$literalExpectation("\"", false), peg$c34 = function(chars) { return chars.join(''); }, peg$c35 = "/", peg$c36 = peg$literalExpectation("/", false), peg$c37 = function(chars) { return chars.join('') }, peg$c38 = peg$anyExpectation(), peg$c39 = function(char) { return char; }, peg$c40 = "+", peg$c41 = peg$literalExpectation("+", false), peg$c42 = "-", peg$c43 = peg$literalExpectation("-", false), peg$c44 = "!", peg$c45 = peg$literalExpectation("!", false), peg$c46 = "{", peg$c47 = peg$literalExpectation("{", false), peg$c48 = "}", peg$c49 = peg$literalExpectation("}", false), peg$c50 = "[", peg$c51 = peg$literalExpectation("[", false), peg$c52 = "]", peg$c53 = peg$literalExpectation("]", false), peg$c54 = "^", peg$c55 = peg$literalExpectation("^", false), peg$c56 = "?", peg$c57 = peg$literalExpectation("?", false), peg$c58 = ":", peg$c59 = peg$literalExpectation(":", false), peg$c60 = "&", peg$c61 = peg$literalExpectation("&", false), peg$c62 = "|", peg$c63 = peg$literalExpectation("|", false), peg$c64 = "'", peg$c65 = peg$literalExpectation("'", false), peg$c66 = "~", peg$c67 = peg$literalExpectation("~", false), peg$c68 = "*", peg$c69 = peg$literalExpectation("*", false), peg$c70 = " ", peg$c71 = peg$literalExpectation(" ", false), peg$c72 = function(proximity) { return proximity; }, peg$c73 = function(boost) { return boost; }, peg$c74 = function(fuzziness) { return fuzziness == '' || fuzziness == null ? 0.5 : fuzziness; }, peg$c75 = "0.", peg$c76 = peg$literalExpectation("0.", false), peg$c77 = /^[0-9]/, peg$c78 = peg$classExpectation([["0", "9"]], false, false), peg$c79 = function(val) { return parseFloat("0." + val.join('')); }, peg$c80 = function(val) { return parseInt(val.join('')); }, peg$c81 = "TO", peg$c82 = peg$literalExpectation("TO", false), peg$c83 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': 'both' }; }, peg$c84 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': 'none' }; }, peg$c85 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': 'left' }; }, peg$c86 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, 'inclusive': 'right' }; }, peg$c87 = function(operator) { return operator; }, peg$c88 = "OR NOT", peg$c89 = peg$literalExpectation("OR NOT", false), peg$c90 = "AND NOT", peg$c91 = peg$literalExpectation("AND NOT", false), peg$c92 = "OR", peg$c93 = peg$literalExpectation("OR", false), peg$c94 = "AND", peg$c95 = peg$literalExpectation("AND", false), peg$c96 = "NOT", peg$c97 = peg$literalExpectation("NOT", false), peg$c98 = "||", peg$c99 = peg$literalExpectation("||", false), peg$c100 = "&&", peg$c101 = peg$literalExpectation("&&", false), peg$c102 = peg$otherExpectation("whitespace"), peg$c103 = /^[ \t\r\n\f]/, peg$c104 = 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$parseregex_term(); 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$c19(s1, s2); s0 = s1; } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } } else { peg$currPos = s0; s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$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$c20(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$c21; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c22); } } if (s1 !== peg$FAILED) { s2 = peg$parseEscapeSequence(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c23(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$c24; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s0 === peg$FAILED) { if (peg$c26.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c27); } } } } 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$c28(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$c29(s1); } s0 = s1; return s0; } function peg$parseterm_char() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { s1 = peg$c21; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c22); } } if (s1 !== peg$FAILED) { s2 = peg$parseEscapeSequence(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c23(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$c24; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s0 === peg$FAILED) { if (peg$c30.test(input.charAt(peg$currPos))) { s0 = input.charAt(peg$currPos); peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c31); } } } } return s0; } function peg$parsequoted_term() { var s0, s1, s2, s3; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { s1 = peg$c32; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c33); } } 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$c32; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c33); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c34(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$c35; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c36); } } 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$c35; peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c36); } } if (s3 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c37(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$c32; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c33); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { s2 = peg$c21; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c22); } } } 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$c38); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c39(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$c21; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c22); } } if (s1 !== peg$FAILED) { s2 = peg$parseEscapeSequence(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c23(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$c35; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c36); } } if (s2 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { s2 = peg$c21; peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c22); } } } 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$c38); } } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c39(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$c21; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c22); } } if (s1 !== peg$FAILED) { s2 = peg$parseEscapeSequence(); if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c23(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$c40; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c41); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { s0 = peg$c42; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c43); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 33) { s0 = peg$c44; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c45); } } 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$c46; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c47); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { s0 = peg$c48; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c49); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 91) { s0 = peg$c50; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c51); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { s0 = peg$c52; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c53); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 94) { s0 = peg$c54; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c55); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { s0 = peg$c32; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c33); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 63) { s0 = peg$c56; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c57); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 58) { s0 = peg$c58; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c59); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 92) { s0 = peg$c21; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c22); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 38) { s0 = peg$c60; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 124) { s0 = peg$c62; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c63); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 39) { s0 = peg$c64; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c65); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { s0 = peg$c35; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c36); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 126) { s0 = peg$c66; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c67); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 42) { s0 = peg$c68; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c69); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 32) { s0 = peg$c70; peg$currPos++; } else { s0 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c71); } } } } } } } } } } } } } } } } } } } } } } return s0; } function peg$parseproximity_modifier() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 126) { s1 = peg$c66; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c67); } } if (s1 !== peg$FAILED) { s2 = peg$parseint_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$parseboost_modifier() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 94) { s1 = peg$c54; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c55); } } if (s1 !== peg$FAILED) { s2 = peg$parsedecimal_or_int_exp(); 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$parsefuzzy_modifier() { var s0, s1, s2; s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 126) { s1 = peg$c66; peg$currPos++; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c67); } } if (s1 !== peg$FAILED) { s2 = peg$parsedecimal_exp(); if (s2 === peg$FAILED) { s2 = null; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c74(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$c75) { s1 = peg$c75; peg$currPos += 2; } else { s1 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c76); } } if (s1 !== peg$FAILED) { s2 = []; if (peg$c77.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c78); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); if (peg$c77.test(input.charAt(peg$currPos))) { s3 = input.charAt(peg$currPos); peg$currPos++; } else { s3 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c78); } } } } else { s2 = peg$FAILED; } if (s2 !== peg$FAILED) { peg$savedPos = s0; s1 = peg$c79(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$c77.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED; if (peg$silentFails === 0) { peg$fail(peg$c78); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); if (peg$c77.test(input.charAt(peg$currPos))) { s2 = input.charAt(peg$currPos); peg$currPos++; } else { s2 = peg$FAILED;