From e088085a9c8f62e04afcb8ac2dbaa812db916ba0 Mon Sep 17 00:00:00 2001 From: Troy Howard Date: Tue, 26 Sep 2017 00:43:32 -0700 Subject: [PATCH] upgrade pegjs to 0.10.0, jasmine to 2.8.0, use umd --- examples/browser/index.html | 26 +- examples/browser/require-example.html | 47 + lib/lucene-query-parser.js | 1133 +++++++++++++------------ lib/lucene-query.grammar | 2 +- package.json | 13 +- spec/SpecRunner.html | 23 +- spec/lucene-query-parser.spec.js | 8 +- spec/specRunner.js | 7 + 8 files changed, 688 insertions(+), 571 deletions(-) create mode 100644 examples/browser/require-example.html create mode 100644 spec/specRunner.js diff --git a/examples/browser/index.html b/examples/browser/index.html index feca538..4324122 100644 --- a/examples/browser/index.html +++ b/examples/browser/index.html @@ -1,8 +1,8 @@ - - + +

Query Text

@@ -23,22 +23,18 @@

Parser Output

+ + +

Query Text

+ + +

Parser Output

+
+

+ + +

+ + + + \ No newline at end of file diff --git a/lib/lucene-query-parser.js b/lib/lucene-query-parser.js index 242228d..fbf8afe 100644 --- a/lib/lucene-query-parser.js +++ b/lib/lucene-query-parser.js @@ -1,13 +1,18 @@ -if (typeof define !== 'function') { var define = require('amdefine')(module) }; - -define([], function() { -var module = {}; -module.exports = (function() { - /* - * Generated by PEG.js 0.8.0. - * - * http://pegjs.majda.cz/ - */ +/* + * 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; } @@ -15,44 +20,150 @@ module.exports = (function() { child.prototype = new ctor(); } - function SyntaxError(message, expected, found, offset, line, column) { + function peg$SyntaxError(message, expected, found, location) { this.message = message; this.expected = expected; this.found = found; - this.offset = offset; - this.line = line; - this.column = column; - + this.location = location; this.name = "SyntaxError"; + + if (typeof Error.captureStackTrace === "function") { + Error.captureStackTrace(this, peg$SyntaxError); + } } - peg$subclass(SyntaxError, Error); + 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"; + } - function parse(input) { - var options = arguments.length > 1 ? arguments[1] : {}, + return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; + }; - peg$FAILED = {}, + function peg$parse(input, options) { + options = options !== void 0 ? options : {}; + + var peg$FAILED = {}, peg$startRuleFunctions = { start: peg$parsestart }, peg$startRuleFunction = peg$parsestart, - peg$c0 = peg$FAILED, - peg$c1 = [], - peg$c2 = function(node) { + peg$c0 = function(node) { return node[0]; }, - peg$c3 = function() { + peg$c1 = function() { return {}; }, - peg$c4 = function(operator) { + peg$c2 = function(operator) { return { 'operator': operator }; }, - peg$c5 = function(operator, right) { + peg$c3 = function(operator, right) { return right; }, - peg$c6 = function(left, operator, right) { + peg$c4 = function(left, operator, right) { var node= { 'left':left }; @@ -72,15 +183,14 @@ module.exports = (function() { return node; }, - peg$c7 = function(field_exp) { + peg$c5 = function(field_exp) { return field_exp; }, - peg$c8 = "(", - peg$c9 = { type: "literal", value: "(", description: "\"(\"" }, - peg$c10 = ")", - peg$c11 = { type: "literal", value: ")", description: "\")\"" }, - peg$c12 = null, - peg$c13 = function(fieldname, range) { + peg$c6 = "(", + peg$c7 = peg$literalExpectation("(", false), + peg$c8 = ")", + peg$c9 = peg$literalExpectation(")", false), + peg$c10 = function(fieldname, range) { range['field'] = fieldname == '' || fieldname == undefined ? "" @@ -88,11 +198,11 @@ module.exports = (function() { return range; }, - peg$c14 = function(fieldname, node) { + peg$c11 = function(fieldname, node) { node['field']= fieldname; return node; }, - peg$c15 = function(fieldname, term) { + peg$c12 = function(fieldname, term) { var fieldexp = { 'field': fieldname == '' || fieldname == undefined @@ -105,12 +215,12 @@ module.exports = (function() { return fieldexp; }, - peg$c16 = /^[:]/, - peg$c17 = { type: "class", value: "[:]", description: "[:]" }, - peg$c18 = function(fieldname) { + peg$c13 = /^[:]/, + peg$c14 = peg$classExpectation([":"], false, false), + peg$c15 = function(fieldname) { return fieldname; }, - peg$c19 = function(op, term, proximity, boost) { + peg$c16 = function(op, term, proximity, boost) { var result = { 'term': term }; if('' != proximity) @@ -128,7 +238,7 @@ module.exports = (function() { return result; }, - peg$c20 = function(op, term, similarity, boost) { + peg$c17 = function(op, term, similarity, boost) { var result = { 'term': term }; if('' != similarity) { @@ -144,7 +254,7 @@ module.exports = (function() { } return result; }, - peg$c21 = function(op, term, boost) { + peg$c18 = function(op, term, boost) { var result = { 'term': term, 'regexpr': true }; if('' != boost) { @@ -156,77 +266,77 @@ module.exports = (function() { } return result; }, - peg$c22 = function(term_start, term) { + 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 = offset + e.column = location throw e } return res }, - peg$c23 = ".", - peg$c24 = { type: "literal", value: ".", description: "\".\"" }, - peg$c25 = /^[^: \t\r\n\f{}()"+-\/\^~[\]]/, - peg$c26 = { type: "class", value: "[^: \\t\\r\\n\\f{}()\"+-\\/\\^~[\\]]", description: "[^: \\t\\r\\n\\f{}()\"+-\\/\\^~[\\]]" }, - peg$c27 = "\\", - peg$c28 = { type: "literal", value: "\\", description: "\"\\\\\"" }, - peg$c29 = /^[: \t\r\n\f{}()"\/\^~[\]]/, - peg$c30 = { type: "class", value: "[: \\t\\r\\n\\f{}()\"\\/\\^~[\\]]", description: "[: \\t\\r\\n\\f{}()\"\\/\\^~[\\]]" }, - peg$c31 = function(escaping_char) { + 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$c32 = "+", - peg$c33 = { type: "literal", value: "+", description: "\"+\"" }, - peg$c34 = "-", - peg$c35 = { type: "literal", value: "-", description: "\"-\"" }, - peg$c36 = "/", - peg$c37 = { type: "literal", value: "/", description: "\"/\"" }, - peg$c38 = function(term) { + 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$c39 = "\\/", - peg$c40 = { type: "literal", value: "\\/", description: "\"\\\\/\"" }, - peg$c41 = /^[^\/]/, - peg$c42 = { type: "class", value: "[^\\/]", description: "[^\\/]" }, - peg$c43 = "\"", - peg$c44 = { type: "literal", value: "\"", description: "\"\\\"\"" }, - peg$c45 = /^[^"]/, - peg$c46 = { type: "class", value: "[^\"]", description: "[^\"]" }, - peg$c47 = function(term) { + 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$c48 = "~", - peg$c49 = { type: "literal", value: "~", description: "\"~\"" }, - peg$c50 = function(proximity) { + peg$c45 = "~", + peg$c46 = peg$literalExpectation("~", false), + peg$c47 = function(proximity) { return proximity; }, - peg$c51 = "^", - peg$c52 = { type: "literal", value: "^", description: "\"^\"" }, - peg$c53 = function(boost) { + peg$c48 = "^", + peg$c49 = peg$literalExpectation("^", false), + peg$c50 = function(boost) { return boost; }, - peg$c54 = function(fuzziness) { + peg$c51 = function(fuzziness) { return fuzziness == '' || fuzziness == undefined ? 0.5 : fuzziness; }, - peg$c55 = "0.", - peg$c56 = { type: "literal", value: "0.", description: "\"0.\"" }, - peg$c57 = /^[0-9]/, - peg$c58 = { type: "class", value: "[0-9]", description: "[0-9]" }, - peg$c59 = function(val) { + 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$c60 = function(val) { + peg$c57 = function(val) { return parseInt(val.join('')); }, - peg$c61 = "[", - peg$c62 = { type: "literal", value: "[", description: "\"[\"" }, - peg$c63 = "TO", - peg$c64 = { type: "literal", value: "TO", description: "\"TO\"" }, - peg$c65 = "]", - peg$c66 = { type: "literal", value: "]", description: "\"]\"" }, - peg$c67 = function(term_min, term_max) { + 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, @@ -235,11 +345,11 @@ module.exports = (function() { 'inclusive_max': true }; }, - peg$c68 = "{", - peg$c69 = { type: "literal", value: "{", description: "\"{\"" }, - peg$c70 = "}", - peg$c71 = { type: "literal", value: "}", description: "\"}\"" }, - peg$c72 = function(term_min, term_max) { + 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, @@ -248,7 +358,7 @@ module.exports = (function() { 'inclusive_max': false }; }, - peg$c73 = function(term_min, term_max) { + peg$c70 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, @@ -257,7 +367,7 @@ module.exports = (function() { 'inclusive_max': true }; }, - peg$c74 = function(term_min, term_max) { + peg$c71 = function(term_min, term_max) { return { 'term_min': term_min, 'term_max': term_max, @@ -266,34 +376,32 @@ module.exports = (function() { 'inclusive_max': false }; }, - peg$c75 = function(operator) { + peg$c72 = function(operator) { return operator; }, - peg$c76 = "OR", - peg$c77 = { type: "literal", value: "OR", description: "\"OR\"" }, - peg$c78 = "AND", - peg$c79 = { type: "literal", value: "AND", description: "\"AND\"" }, - peg$c80 = "NOT", - peg$c81 = { type: "literal", value: "NOT", description: "\"NOT\"" }, - peg$c82 = "||", - peg$c83 = { type: "literal", value: "||", description: "\"||\"" }, - peg$c84 = function() { return 'OR'; }, - peg$c85 = "&&", - peg$c86 = { type: "literal", value: "&&", description: "\"&&\"" }, - peg$c87 = function() { return 'AND'; }, - peg$c88 = "!", - peg$c89 = { type: "literal", value: "!", description: "\"!\"" }, - peg$c90 = function() { return 'NOT'}, - peg$c91 = { type: "other", description: "whitespace" }, - peg$c92 = /^[ \t\r\n\f]/, - peg$c93 = { type: "class", value: "[ \\t\\r\\n\\f]", description: "[ \\t\\r\\n\\f]" }, - peg$c94 = void 0, - peg$c95 = { type: "any", description: "any character" }, + 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$reportedPos = 0, - peg$cachedPos = 0, - peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }, + peg$savedPos = 0, + peg$posDetailsCache = [{ line: 1, column: 1 }], peg$maxFailPos = 0, peg$maxFailExpected = [], peg$silentFails = 0, @@ -309,64 +417,98 @@ module.exports = (function() { } function text() { - return input.substring(peg$reportedPos, peg$currPos); + return input.substring(peg$savedPos, peg$currPos); } - function offset() { - return peg$reportedPos; + function location() { + return peg$computeLocation(peg$savedPos, peg$currPos); } - function line() { - return peg$computePosDetails(peg$reportedPos).line; + 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 column() { - return peg$computePosDetails(peg$reportedPos).column; + function error(message, location) { + location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos) + + throw peg$buildSimpleError(message, location); } - function expected(description) { - throw peg$buildException( - null, - [{ type: "other", description: description }], - peg$reportedPos - ); + 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 error(message) { - throw peg$buildException(message, null, peg$reportedPos); + 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) { - function advance(details, startPos, endPos) { - var p, ch; + var details = peg$posDetailsCache[pos], p; - for (p = startPos; p < endPos; p++) { - ch = input.charAt(p); - if (ch === "\n") { - if (!details.seenCR) { details.line++; } - details.column = 1; - details.seenCR = false; - } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { + 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; - details.seenCR = true; } else { details.column++; - details.seenCR = false; } - } - } - if (peg$cachedPos !== pos) { - if (peg$cachedPos > pos) { - peg$cachedPos = 0; - peg$cachedPosDetails = { line: 1, column: 1, seenCR: false }; + p++; } - advance(peg$cachedPosDetails, peg$cachedPos, pos); - peg$cachedPos = pos; + + peg$posDetailsCache[pos] = details; + return details; } + } - return peg$cachedPosDetails; + 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) { @@ -380,79 +522,16 @@ module.exports = (function() { peg$maxFailExpected.push(expected); } - function peg$buildException(message, expected, pos) { - function cleanupExpected(expected) { - var i = 1; - - expected.sort(function(a, b) { - if (a.description < b.description) { - return -1; - } else if (a.description > b.description) { - return 1; - } else { - return 0; - } - }); - - while (i < expected.length) { - if (expected[i - 1] === expected[i]) { - expected.splice(i, 1); - } else { - i++; - } - } - } - - function buildMessage(expected, found) { - function stringEscape(s) { - function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); } - - return s - .replace(/\\/g, '\\\\') - .replace(/"/g, '\\"') - .replace(/\x08/g, '\\b') - .replace(/\t/g, '\\t') - .replace(/\n/g, '\\n') - .replace(/\f/g, '\\f') - .replace(/\r/g, '\\r') - .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); }) - .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); }) - .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); }) - .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); }); - } - - var expectedDescs = new Array(expected.length), - expectedDesc, foundDesc, i; - - for (i = 0; i < expected.length; i++) { - expectedDescs[i] = expected[i].description; - } - - expectedDesc = expected.length > 1 - ? expectedDescs.slice(0, -1).join(", ") - + " or " - + expectedDescs[expected.length - 1] - : expectedDescs[0]; - - foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input"; - - return "Expected " + expectedDesc + " but " + foundDesc + " found."; - } - - var posDetails = peg$computePosDetails(pos), - found = pos < input.length ? input.charAt(pos) : null; - - if (expected !== null) { - cleanupExpected(expected); - } + function peg$buildSimpleError(message, location) { + return new peg$SyntaxError(message, null, null, location); + } - return new SyntaxError( - message !== null ? message : buildMessage(expected, found), + function peg$buildStructuredError(expected, found, location) { + return new peg$SyntaxError( + peg$SyntaxError.buildMessage(expected, found), expected, found, - pos, - posDetails.line, - posDetails.column + location ); } @@ -475,19 +554,19 @@ module.exports = (function() { s3 = peg$parsenode(); } } else { - s2 = peg$c0; + s2 = peg$FAILED; } if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c2(s2); + peg$savedPos = s0; + s1 = peg$c0(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -498,16 +577,16 @@ module.exports = (function() { s2 = peg$parse_(); } if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c3(); + peg$savedPos = s0; + s1 = peg$c1(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseEOF(); if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c3(); + peg$savedPos = s0; + s1 = peg$c1(); } s0 = s1; } @@ -524,16 +603,16 @@ module.exports = (function() { if (s1 !== peg$FAILED) { s2 = peg$parseEOF(); if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c4(s1); + peg$savedPos = s0; + s1 = peg$c2(s1); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -541,16 +620,16 @@ module.exports = (function() { if (s1 !== peg$FAILED) { s2 = peg$parsenode(); if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c5(s1, s2); + peg$savedPos = s0; + s1 = peg$c3(s1, s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -570,20 +649,20 @@ module.exports = (function() { s4 = peg$parsenode(); } if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c6(s1, s2, s3); + peg$savedPos = s0; + s1 = peg$c4(s1, s2, s3); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } } @@ -604,16 +683,16 @@ module.exports = (function() { s3 = peg$parse_(); } if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c7(s1); + peg$savedPos = s0; + s1 = peg$c5(s1); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$parseparen_exp(); @@ -627,11 +706,11 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 40) { - s1 = peg$c8; + s1 = peg$c6; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c9); } + if (peg$silentFails === 0) { peg$fail(peg$c7); } } if (s1 !== peg$FAILED) { s2 = []; @@ -642,15 +721,15 @@ module.exports = (function() { s3 = peg$parsenode(); } } else { - s2 = peg$c0; + s2 = peg$FAILED; } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 41) { - s3 = peg$c10; + s3 = peg$c8; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c11); } + if (peg$silentFails === 0) { peg$fail(peg$c9); } } if (s3 !== peg$FAILED) { s4 = []; @@ -660,24 +739,24 @@ module.exports = (function() { s5 = peg$parse_(); } if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c2(s2); + peg$savedPos = s0; + s1 = peg$c0(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -689,21 +768,21 @@ module.exports = (function() { s0 = peg$currPos; s1 = peg$parsefieldname(); if (s1 === peg$FAILED) { - s1 = peg$c12; + s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parserange_operator_exp(); if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c13(s1, s2); + peg$savedPos = s0; + s1 = peg$c10(s1, s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -711,36 +790,36 @@ module.exports = (function() { if (s1 !== peg$FAILED) { s2 = peg$parseparen_exp(); if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c14(s1, s2); + peg$savedPos = s0; + s1 = peg$c11(s1, s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parsefieldname(); if (s1 === peg$FAILED) { - s1 = peg$c12; + s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parseterm(); if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c15(s1, s2); + peg$savedPos = s0; + s1 = peg$c12(s1, s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } } @@ -761,12 +840,12 @@ module.exports = (function() { s3 = peg$parse_(); } if (s2 !== peg$FAILED) { - if (peg$c16.test(input.charAt(peg$currPos))) { + 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$c17); } + if (peg$silentFails === 0) { peg$fail(peg$c14); } } if (s3 !== peg$FAILED) { s4 = []; @@ -776,24 +855,24 @@ module.exports = (function() { s5 = peg$parse_(); } if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c18(s1); + peg$savedPos = s0; + s1 = peg$c15(s1); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -805,19 +884,19 @@ module.exports = (function() { s0 = peg$currPos; s1 = peg$parseprefix_operator_exp(); if (s1 === peg$FAILED) { - s1 = peg$c12; + s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parsequoted_term(); if (s2 !== peg$FAILED) { s3 = peg$parseproximity_modifier(); if (s3 === peg$FAILED) { - s3 = peg$c12; + s3 = null; } if (s3 !== peg$FAILED) { s4 = peg$parseboost_modifier(); if (s4 === peg$FAILED) { - s4 = peg$c12; + s4 = null; } if (s4 !== peg$FAILED) { s5 = []; @@ -827,46 +906,46 @@ module.exports = (function() { s6 = peg$parse_(); } if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c19(s1, s2, s3, s4); + peg$savedPos = s0; + s1 = peg$c16(s1, s2, s3, s4); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseprefix_operator_exp(); if (s1 === peg$FAILED) { - s1 = peg$c12; + s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); if (s2 !== peg$FAILED) { s3 = peg$parsefuzzy_modifier(); if (s3 === peg$FAILED) { - s3 = peg$c12; + s3 = null; } if (s3 !== peg$FAILED) { s4 = peg$parseboost_modifier(); if (s4 === peg$FAILED) { - s4 = peg$c12; + s4 = null; } if (s4 !== peg$FAILED) { s5 = []; @@ -876,41 +955,41 @@ module.exports = (function() { s6 = peg$parse_(); } if (s5 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c20(s1, s2, s3, s4); + peg$savedPos = s0; + s1 = peg$c17(s1, s2, s3, s4); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; s1 = peg$parseprefix_operator_exp(); if (s1 === peg$FAILED) { - s1 = peg$c12; + s1 = null; } if (s1 !== peg$FAILED) { s2 = peg$parseregexpr_term(); if (s2 !== peg$FAILED) { s3 = peg$parseboost_modifier(); if (s3 === peg$FAILED) { - s3 = peg$c12; + s3 = null; } if (s3 !== peg$FAILED) { s4 = []; @@ -920,24 +999,24 @@ module.exports = (function() { s5 = peg$parse_(); } if (s4 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c21(s1, s2, s3); + peg$savedPos = s0; + s1 = peg$c18(s1, s2, s3); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } } @@ -958,16 +1037,16 @@ module.exports = (function() { s3 = peg$parseterm_char(); } if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c22(s1, s2); + peg$savedPos = s0; + s1 = peg$c19(s1, s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -977,21 +1056,21 @@ module.exports = (function() { var s0; if (input.charCodeAt(peg$currPos) === 46) { - s0 = peg$c23; + s0 = peg$c20; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c24); } + if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s0 === peg$FAILED) { s0 = peg$parseterm_escaping_char(); if (s0 === peg$FAILED) { - if (peg$c25.test(input.charAt(peg$currPos))) { + 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$c26); } + if (peg$silentFails === 0) { peg$fail(peg$c23); } } } } @@ -1004,31 +1083,31 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c27; + s1 = peg$c24; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (peg$silentFails === 0) { peg$fail(peg$c25); } } if (s1 !== peg$FAILED) { - if (peg$c29.test(input.charAt(peg$currPos))) { + 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$c30); } + if (peg$silentFails === 0) { peg$fail(peg$c27); } } if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c31(s2); + peg$savedPos = s0; + s1 = peg$c28(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -1038,19 +1117,19 @@ module.exports = (function() { var s0; if (input.charCodeAt(peg$currPos) === 43) { - s0 = peg$c32; + s0 = peg$c29; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { peg$fail(peg$c30); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { - s0 = peg$c34; + s0 = peg$c31; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } + if (peg$silentFails === 0) { peg$fail(peg$c32); } } if (s0 === peg$FAILED) { s0 = peg$parseterm_escaping_char(); @@ -1068,11 +1147,11 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 47) { - s1 = peg$c36; + s1 = peg$c33; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c37); } + if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s1 !== peg$FAILED) { s2 = []; @@ -1083,31 +1162,31 @@ module.exports = (function() { s3 = peg$parseregexpr_char(); } } else { - s2 = peg$c0; + s2 = peg$FAILED; } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 47) { - s3 = peg$c36; + s3 = peg$c33; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c37); } + if (peg$silentFails === 0) { peg$fail(peg$c34); } } if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c38(s2); + peg$savedPos = s0; + s1 = peg$c35(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -1117,27 +1196,27 @@ module.exports = (function() { var s0; if (input.charCodeAt(peg$currPos) === 46) { - s0 = peg$c23; + s0 = peg$c20; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c24); } + if (peg$silentFails === 0) { peg$fail(peg$c21); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c39) { - s0 = peg$c39; + 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$c40); } + if (peg$silentFails === 0) { peg$fail(peg$c37); } } if (s0 === peg$FAILED) { - if (peg$c41.test(input.charAt(peg$currPos))) { + 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$c42); } + if (peg$silentFails === 0) { peg$fail(peg$c39); } } } } @@ -1150,58 +1229,58 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c43; + s1 = peg$c40; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c44); } + if (peg$silentFails === 0) { peg$fail(peg$c41); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c45.test(input.charAt(peg$currPos))) { + 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$c46); } + if (peg$silentFails === 0) { peg$fail(peg$c43); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c45.test(input.charAt(peg$currPos))) { + 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$c46); } + if (peg$silentFails === 0) { peg$fail(peg$c43); } } } } else { - s2 = peg$c0; + s2 = peg$FAILED; } if (s2 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c43; + s3 = peg$c40; peg$currPos++; } else { s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c44); } + if (peg$silentFails === 0) { peg$fail(peg$c41); } } if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c47(s2); + peg$savedPos = s0; + s1 = peg$c44(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -1212,25 +1291,25 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 126) { - s1 = peg$c48; + s1 = peg$c45; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c49); } + if (peg$silentFails === 0) { peg$fail(peg$c46); } } if (s1 !== peg$FAILED) { s2 = peg$parseint_exp(); if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c50(s2); + peg$savedPos = s0; + s1 = peg$c47(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -1241,25 +1320,25 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 94) { - s1 = peg$c51; + s1 = peg$c48; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c52); } + if (peg$silentFails === 0) { peg$fail(peg$c49); } } if (s1 !== peg$FAILED) { s2 = peg$parsedecimal_or_int_exp(); if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c53(s2); + peg$savedPos = s0; + s1 = peg$c50(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -1270,28 +1349,28 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 126) { - s1 = peg$c48; + s1 = peg$c45; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c49); } + if (peg$silentFails === 0) { peg$fail(peg$c46); } } if (s1 !== peg$FAILED) { s2 = peg$parsedecimal_exp(); if (s2 === peg$FAILED) { - s2 = peg$c12; + s2 = null; } if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c54(s2); + peg$savedPos = s0; + s1 = peg$c51(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -1312,47 +1391,47 @@ module.exports = (function() { var s0, s1, s2, s3; s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c55) { - s1 = peg$c55; + 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$c56); } + if (peg$silentFails === 0) { peg$fail(peg$c53); } } if (s1 !== peg$FAILED) { s2 = []; - if (peg$c57.test(input.charAt(peg$currPos))) { + 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$c58); } + if (peg$silentFails === 0) { peg$fail(peg$c55); } } if (s3 !== peg$FAILED) { while (s3 !== peg$FAILED) { s2.push(s3); - if (peg$c57.test(input.charAt(peg$currPos))) { + 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$c58); } + if (peg$silentFails === 0) { peg$fail(peg$c55); } } } } else { - s2 = peg$c0; + s2 = peg$FAILED; } if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c59(s2); + peg$savedPos = s0; + s1 = peg$c56(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -1363,30 +1442,30 @@ module.exports = (function() { s0 = peg$currPos; s1 = []; - if (peg$c57.test(input.charAt(peg$currPos))) { + 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$c58); } + if (peg$silentFails === 0) { peg$fail(peg$c55); } } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); - if (peg$c57.test(input.charAt(peg$currPos))) { + 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$c58); } + if (peg$silentFails === 0) { peg$fail(peg$c55); } } } } else { - s1 = peg$c0; + s1 = peg$FAILED; } if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c60(s1); + peg$savedPos = s0; + s1 = peg$c57(s1); } s0 = s1; @@ -1398,11 +1477,11 @@ module.exports = (function() { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c61; + s1 = peg$c58; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c62); } + if (peg$silentFails === 0) { peg$fail(peg$c59); } } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); @@ -1414,12 +1493,12 @@ module.exports = (function() { s4 = peg$parse_(); } if (s3 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c63) { - s4 = peg$c63; + 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$c64); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { s5 = []; @@ -1430,58 +1509,58 @@ module.exports = (function() { s6 = peg$parse_(); } } else { - s5 = peg$c0; + s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s6 = peg$parseunquoted_term(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { - s7 = peg$c65; + s7 = peg$c62; peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c66); } + if (peg$silentFails === 0) { peg$fail(peg$c63); } } if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c67(s2, s6); + peg$savedPos = s0; + s1 = peg$c64(s2, s6); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c68; + s1 = peg$c65; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c69); } + if (peg$silentFails === 0) { peg$fail(peg$c66); } } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); @@ -1493,12 +1572,12 @@ module.exports = (function() { s4 = peg$parse_(); } if (s3 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c63) { - s4 = peg$c63; + 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$c64); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { s5 = []; @@ -1509,58 +1588,58 @@ module.exports = (function() { s6 = peg$parse_(); } } else { - s5 = peg$c0; + s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s6 = peg$parseunquoted_term(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { - s7 = peg$c70; + s7 = peg$c67; peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c71); } + if (peg$silentFails === 0) { peg$fail(peg$c68); } } if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c72(s2, s6); + peg$savedPos = s0; + s1 = peg$c69(s2, s6); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 123) { - s1 = peg$c68; + s1 = peg$c65; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c69); } + if (peg$silentFails === 0) { peg$fail(peg$c66); } } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); @@ -1572,12 +1651,12 @@ module.exports = (function() { s4 = peg$parse_(); } if (s3 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c63) { - s4 = peg$c63; + 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$c64); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { s5 = []; @@ -1588,58 +1667,58 @@ module.exports = (function() { s6 = peg$parse_(); } } else { - s5 = peg$c0; + s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s6 = peg$parseunquoted_term(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 93) { - s7 = peg$c65; + s7 = peg$c62; peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c66); } + if (peg$silentFails === 0) { peg$fail(peg$c63); } } if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c73(s2, s6); + peg$savedPos = s0; + s1 = peg$c70(s2, s6); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 91) { - s1 = peg$c61; + s1 = peg$c58; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c62); } + if (peg$silentFails === 0) { peg$fail(peg$c59); } } if (s1 !== peg$FAILED) { s2 = peg$parseunquoted_term(); @@ -1651,12 +1730,12 @@ module.exports = (function() { s4 = peg$parse_(); } if (s3 !== peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c63) { - s4 = peg$c63; + 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$c64); } + if (peg$silentFails === 0) { peg$fail(peg$c61); } } if (s4 !== peg$FAILED) { s5 = []; @@ -1667,49 +1746,49 @@ module.exports = (function() { s6 = peg$parse_(); } } else { - s5 = peg$c0; + s5 = peg$FAILED; } if (s5 !== peg$FAILED) { s6 = peg$parseunquoted_term(); if (s6 !== peg$FAILED) { if (input.charCodeAt(peg$currPos) === 125) { - s7 = peg$c70; + s7 = peg$c67; peg$currPos++; } else { s7 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c71); } + if (peg$silentFails === 0) { peg$fail(peg$c68); } } if (s7 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c74(s2, s6); + peg$savedPos = s0; + s1 = peg$c71(s2, s6); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } } @@ -1739,23 +1818,23 @@ module.exports = (function() { s4 = peg$parse_(); } } else { - s3 = peg$c0; + s3 = peg$FAILED; } if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c75(s2); + peg$savedPos = s0; + s1 = peg$c72(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } if (s0 === peg$FAILED) { s0 = peg$currPos; @@ -1770,20 +1849,20 @@ module.exports = (function() { if (s2 !== peg$FAILED) { s3 = peg$parseEOF(); if (s3 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c75(s2); + peg$savedPos = s0; + s1 = peg$c72(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } @@ -1793,69 +1872,69 @@ module.exports = (function() { function peg$parseoperator() { var s0, s1; - if (input.substr(peg$currPos, 2) === peg$c76) { - s0 = peg$c76; + if (input.substr(peg$currPos, 2) === peg$c73) { + s0 = peg$c73; peg$currPos += 2; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c77); } + if (peg$silentFails === 0) { peg$fail(peg$c74); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c78) { - s0 = peg$c78; + if (input.substr(peg$currPos, 3) === peg$c75) { + s0 = peg$c75; peg$currPos += 3; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c79); } + if (peg$silentFails === 0) { peg$fail(peg$c76); } } if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 3) === peg$c80) { - s0 = peg$c80; + if (input.substr(peg$currPos, 3) === peg$c77) { + s0 = peg$c77; peg$currPos += 3; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c81); } + if (peg$silentFails === 0) { peg$fail(peg$c78); } } if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c82) { - s1 = peg$c82; + if (input.substr(peg$currPos, 2) === peg$c79) { + s1 = peg$c79; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c83); } + if (peg$silentFails === 0) { peg$fail(peg$c80); } } if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c84(); + peg$savedPos = s0; + s1 = peg$c81(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c85) { - s1 = peg$c85; + if (input.substr(peg$currPos, 2) === peg$c82) { + s1 = peg$c82; peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c86); } + if (peg$silentFails === 0) { peg$fail(peg$c83); } } if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c87(); + peg$savedPos = s0; + s1 = peg$c84(); } s0 = s1; if (s0 === peg$FAILED) { s0 = peg$currPos; if (input.charCodeAt(peg$currPos) === 33) { - s1 = peg$c88; + s1 = peg$c85; peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c89); } + if (peg$silentFails === 0) { peg$fail(peg$c86); } } if (s1 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c90(); + peg$savedPos = s0; + s1 = peg$c87(); } s0 = s1; } @@ -1880,16 +1959,16 @@ module.exports = (function() { if (s1 !== peg$FAILED) { s2 = peg$parseprefix_operator(); if (s2 !== peg$FAILED) { - peg$reportedPos = s0; - s1 = peg$c75(s2); + peg$savedPos = s0; + s1 = peg$c72(s2); s0 = s1; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -1899,19 +1978,19 @@ module.exports = (function() { var s0; if (input.charCodeAt(peg$currPos) === 43) { - s0 = peg$c32; + s0 = peg$c29; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c33); } + if (peg$silentFails === 0) { peg$fail(peg$c30); } } if (s0 === peg$FAILED) { if (input.charCodeAt(peg$currPos) === 45) { - s0 = peg$c34; + s0 = peg$c31; peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } + if (peg$silentFails === 0) { peg$fail(peg$c32); } } } @@ -1923,31 +2002,31 @@ module.exports = (function() { peg$silentFails++; s0 = []; - if (peg$c92.test(input.charAt(peg$currPos))) { + if (peg$c89.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c93); } + if (peg$silentFails === 0) { peg$fail(peg$c90); } } if (s1 !== peg$FAILED) { while (s1 !== peg$FAILED) { s0.push(s1); - if (peg$c92.test(input.charAt(peg$currPos))) { + if (peg$c89.test(input.charAt(peg$currPos))) { s1 = input.charAt(peg$currPos); peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c93); } + if (peg$silentFails === 0) { peg$fail(peg$c90); } } } } else { - s0 = peg$c0; + s0 = peg$FAILED; } peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c91); } + if (peg$silentFails === 0) { peg$fail(peg$c88); } } return s0; @@ -1963,14 +2042,14 @@ module.exports = (function() { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c95); } + if (peg$silentFails === 0) { peg$fail(peg$c91); } } peg$silentFails--; if (s1 === peg$FAILED) { - s0 = peg$c94; + s0 = void 0; } else { peg$currPos = s0; - s0 = peg$c0; + s0 = peg$FAILED; } return s0; @@ -1982,17 +2061,21 @@ module.exports = (function() { return peg$result; } else { if (peg$result !== peg$FAILED && peg$currPos < input.length) { - peg$fail({ type: "end", description: "end of input" }); + peg$fail(peg$endExpectation()); } - throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos); + throw peg$buildStructuredError( + peg$maxFailExpected, + peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, + peg$maxFailPos < input.length + ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) + : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) + ); } } return { - SyntaxError: SyntaxError, - parse: parse + SyntaxError: peg$SyntaxError, + parse: peg$parse }; -})(); -return module.exports; }); diff --git a/lib/lucene-query.grammar b/lib/lucene-query.grammar index 67e7579..9455307 100644 --- a/lib/lucene-query.grammar +++ b/lib/lucene-query.grammar @@ -227,7 +227,7 @@ unquoted_term if (/^(?:AND|OR|NOT|\|\||&&)$/.test(res)) { var e = new Error('Term can not be AND, OR, NOT, ||, &&') e.name = 'SyntaxError' - e.column = offset + e.column = location throw e } return res diff --git a/package.json b/package.json index a170817..79e4bd2 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "Lucene Query Parser for JavaScript created using PEG.js", "main": "lib/lucene-query-parser.js", "scripts": { - "build": "PEG_OUT=`cat lib/lucene-query.grammar | node_modules/pegjs/bin/pegjs` && printf \"if (typeof define !== 'function') { var define = require('amdefine')(module) };\n\ndefine([], function() { \nvar module = {};\n%s\nreturn module.exports;\n});\n\" \"$PEG_OUT\" > ./lib/lucene-query-parser.js", - "test": "./node_modules/.bin/jasmine-node ./spec/ --verbose", + "build": "node_modules/pegjs/bin/pegjs --format umd --export-var lucenequeryparser -o lib/lucene-query-parser.js lib/lucene-query.grammar", + "test": "jasmine spec/lucene-query-parser.spec.js", "prepublish": "npm run-script build && npm test" }, "repository": { @@ -36,11 +36,10 @@ "bugs": { "url": "https://github.com/thoward/lucene-query-parser.js/issues" }, - "dependencies": { - "amdefine": ">=0.0.2" - }, "devDependencies": { - "jasmine-node": "1.10.x", - "pegjs": "0.8.x" + "amdefine": ">=0.0.2", + "jasmine": "~2.8.0", + "jasmine-core": "~2.8.0", + "pegjs": "0.10.x" } } diff --git a/spec/SpecRunner.html b/spec/SpecRunner.html index c22a98c..585a355 100644 --- a/spec/SpecRunner.html +++ b/spec/SpecRunner.html @@ -4,27 +4,14 @@ Jasmine Test Runner - - - + + + + - - + - - \ No newline at end of file diff --git a/spec/lucene-query-parser.spec.js b/spec/lucene-query-parser.spec.js index 8d6f22a..ac7f411 100644 --- a/spec/lucene-query-parser.spec.js +++ b/spec/lucene-query-parser.spec.js @@ -30,10 +30,8 @@ define(["../lib/lucene-query-parser.js"], function(lucenequeryparser) { expect(results['left']['term']).toBe('Foo'); }); - function isEmpty(arr) - { - for(var i in arr) - { + function isEmpty(arr) { + for(var i in arr) { return false; } return true; @@ -77,7 +75,7 @@ describe("lucenequeryparser: term parsing", function() { it("handles empty term with operator", function() { expect(function () { lucenequeryparser.parse('device_model: AND x:y'); - }).toThrow('Term can not be AND, OR, NOT, ||, &&'); + }).toThrow(new SyntaxError('Term can not be AND, OR, NOT, ||, &&')); }); it("parses terms with +", function() { diff --git a/spec/specRunner.js b/spec/specRunner.js new file mode 100644 index 0000000..95347ac --- /dev/null +++ b/spec/specRunner.js @@ -0,0 +1,7 @@ +require.config({ + paths: { + 'jasmine': '../node_modules/jasmine/lib/jasmine', + }, +}); + +require(['./lucene-query-parser.spec.js']); \ No newline at end of file