diff options
Diffstat (limited to 'tools/eslint/node_modules/esquery/parser.js')
-rw-r--r-- | tools/eslint/node_modules/esquery/parser.js | 296 |
1 files changed, 148 insertions, 148 deletions
diff --git a/tools/eslint/node_modules/esquery/parser.js b/tools/eslint/node_modules/esquery/parser.js index 1dbe58ddd8..2ce8134592 100644 --- a/tools/eslint/node_modules/esquery/parser.js +++ b/tools/eslint/node_modules/esquery/parser.js @@ -4,7 +4,7 @@ var result = (function(){ * * http://pegjs.majda.cz/ */ - + function quote(s) { /* * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a @@ -27,7 +27,7 @@ var result = (function(){ .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) + '"'; } - + var result = { /* * Parses the input with a generated parser. If the parsing is successfull, @@ -66,7 +66,7 @@ var result = (function(){ "nthLastChild": parse_nthLastChild, "class": parse_class }; - + if (startRule !== undefined) { if (parseFunctions[startRule] === undefined) { throw new Error("Invalid rule name: " + quote(startRule) + "."); @@ -74,29 +74,29 @@ var result = (function(){ } else { startRule = "start"; } - + var pos = 0; var reportFailures = 0; var rightmostFailuresPos = 0; var rightmostFailuresExpected = []; var cache = {}; - + function padLeft(input, padding, length) { var result = input; - + var padLength = length - input.length; for (var i = 0; i < padLength; i++) { result = padding + result; } - + return result; } - + function escape(ch) { var charCode = ch.charCodeAt(0); var escapeChar; var length; - + if (charCode <= 0xFF) { escapeChar = 'x'; length = 2; @@ -104,23 +104,23 @@ var result = (function(){ escapeChar = 'u'; length = 4; } - + return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length); } - + function matchFailed(failure) { if (pos < rightmostFailuresPos) { return; } - + if (pos > rightmostFailuresPos) { rightmostFailuresPos = pos; rightmostFailuresExpected = []; } - + rightmostFailuresExpected.push(failure); } - + function parse_start() { var cacheKey = "start@" + pos; var cachedResult = cache[cacheKey]; @@ -128,10 +128,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2; var pos0, pos1; - + pos0 = pos; pos1 = pos; result0 = parse__(); @@ -169,14 +169,14 @@ var result = (function(){ pos = pos0; } } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse__() { var cacheKey = "_@" + pos; var cachedResult = cache[cacheKey]; @@ -184,9 +184,9 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1; - + result0 = []; if (input.charCodeAt(pos) === 32) { result1 = " "; @@ -209,14 +209,14 @@ var result = (function(){ } } } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_identifierName() { var cacheKey = "identifierName@" + pos; var cachedResult = cache[cacheKey]; @@ -224,10 +224,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1; var pos0; - + pos0 = pos; if (/^[^ [\],():#!=><~+.]/.test(input.charAt(pos))) { result1 = input.charAt(pos); @@ -261,14 +261,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_binaryOp() { var cacheKey = "binaryOp@" + pos; var cachedResult = cache[cacheKey]; @@ -276,10 +276,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2; var pos0, pos1; - + pos0 = pos; pos1 = pos; result0 = parse__(); @@ -420,14 +420,14 @@ var result = (function(){ } } } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_selectors() { var cacheKey = "selectors@" + pos; var cachedResult = cache[cacheKey]; @@ -435,10 +435,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3, result4, result5; var pos0, pos1, pos2; - + pos0 = pos; pos1 = pos; result0 = parse_selector(); @@ -533,14 +533,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_selector() { var cacheKey = "selector@" + pos; var cachedResult = cache[cacheKey]; @@ -548,10 +548,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3; var pos0, pos1, pos2; - + pos0 = pos; pos1 = pos; result0 = parse_sequence(); @@ -608,14 +608,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_sequence() { var cacheKey = "sequence@" + pos; var cachedResult = cache[cacheKey]; @@ -623,10 +623,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.charCodeAt(pos) === 33) { @@ -670,14 +670,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_atom() { var cacheKey = "atom@" + pos; var cachedResult = cache[cacheKey]; @@ -685,9 +685,9 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0; - + result0 = parse_wildcard(); if (result0 === null) { result0 = parse_identifier(); @@ -719,14 +719,14 @@ var result = (function(){ } } } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_wildcard() { var cacheKey = "wildcard@" + pos; var cachedResult = cache[cacheKey]; @@ -734,10 +734,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0; var pos0; - + pos0 = pos; if (input.charCodeAt(pos) === 42) { result0 = "*"; @@ -754,14 +754,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_identifier() { var cacheKey = "identifier@" + pos; var cachedResult = cache[cacheKey]; @@ -769,10 +769,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.charCodeAt(pos) === 35) { @@ -803,14 +803,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_attr() { var cacheKey = "attr@" + pos; var cachedResult = cache[cacheKey]; @@ -818,10 +818,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3, result4; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.charCodeAt(pos) === 91) { @@ -877,14 +877,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_attrOps() { var cacheKey = "attrOps@" + pos; var cachedResult = cache[cacheKey]; @@ -892,10 +892,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (/^[><!]/.test(input.charAt(pos))) { @@ -945,14 +945,14 @@ var result = (function(){ } } } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_attrEqOps() { var cacheKey = "attrEqOps@" + pos; var cachedResult = cache[cacheKey]; @@ -960,10 +960,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.charCodeAt(pos) === 33) { @@ -1002,14 +1002,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_attrName() { var cacheKey = "attrName@" + pos; var cachedResult = cache[cacheKey]; @@ -1017,10 +1017,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1; var pos0; - + pos0 = pos; result1 = parse_identifierName(); if (result1 === null) { @@ -1060,14 +1060,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_attrValue() { var cacheKey = "attrValue@" + pos; var cachedResult = cache[cacheKey]; @@ -1075,10 +1075,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3, result4; var pos0, pos1; - + pos0 = pos; pos1 = pos; result0 = parse_attrName(); @@ -1182,14 +1182,14 @@ var result = (function(){ } } } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_string() { var cacheKey = "string@" + pos; var cachedResult = cache[cacheKey]; @@ -1197,10 +1197,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3; var pos0, pos1, pos2, pos3; - + pos0 = pos; pos1 = pos; if (input.charCodeAt(pos) === 34) { @@ -1491,14 +1491,14 @@ var result = (function(){ pos = pos0; } } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_number() { var cacheKey = "number@" + pos; var cachedResult = cache[cacheKey]; @@ -1506,10 +1506,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2; var pos0, pos1, pos2; - + pos0 = pos; pos1 = pos; pos2 = pos; @@ -1601,14 +1601,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_path() { var cacheKey = "path@" + pos; var cachedResult = cache[cacheKey]; @@ -1616,10 +1616,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0; var pos0; - + pos0 = pos; result0 = parse_identifierName(); if (result0 !== null) { @@ -1628,14 +1628,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_type() { var cacheKey = "type@" + pos; var cachedResult = cache[cacheKey]; @@ -1643,10 +1643,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3, result4; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.substr(pos, 5) === "type(") { @@ -1727,14 +1727,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_regex() { var cacheKey = "regex@" + pos; var cachedResult = cache[cacheKey]; @@ -1742,10 +1742,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.charCodeAt(pos) === 47) { @@ -1814,14 +1814,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_field() { var cacheKey = "field@" + pos; var cachedResult = cache[cacheKey]; @@ -1829,10 +1829,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3, result4; var pos0, pos1, pos2; - + pos0 = pos; pos1 = pos; if (input.charCodeAt(pos) === 46) { @@ -1917,14 +1917,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_negation() { var cacheKey = "negation@" + pos; var cachedResult = cache[cacheKey]; @@ -1932,10 +1932,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3, result4; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.substr(pos, 5) === ":not(") { @@ -1991,14 +1991,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_matches() { var cacheKey = "matches@" + pos; var cachedResult = cache[cacheKey]; @@ -2006,10 +2006,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3, result4; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.substr(pos, 9) === ":matches(") { @@ -2065,14 +2065,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_firstChild() { var cacheKey = "firstChild@" + pos; var cachedResult = cache[cacheKey]; @@ -2080,10 +2080,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0; var pos0; - + pos0 = pos; if (input.substr(pos, 12) === ":first-child") { result0 = ":first-child"; @@ -2100,14 +2100,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_lastChild() { var cacheKey = "lastChild@" + pos; var cachedResult = cache[cacheKey]; @@ -2115,10 +2115,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0; var pos0; - + pos0 = pos; if (input.substr(pos, 11) === ":last-child") { result0 = ":last-child"; @@ -2135,14 +2135,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_nthChild() { var cacheKey = "nthChild@" + pos; var cachedResult = cache[cacheKey]; @@ -2150,10 +2150,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3, result4; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.substr(pos, 11) === ":nth-child(") { @@ -2234,14 +2234,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_nthLastChild() { var cacheKey = "nthLastChild@" + pos; var cachedResult = cache[cacheKey]; @@ -2249,10 +2249,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1, result2, result3, result4; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.substr(pos, 16) === ":nth-last-child(") { @@ -2333,14 +2333,14 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - + function parse_class() { var cacheKey = "class@" + pos; var cachedResult = cache[cacheKey]; @@ -2348,10 +2348,10 @@ var result = (function(){ pos = cachedResult.nextPos; return cachedResult.result; } - + var result0, result1; var pos0, pos1; - + pos0 = pos; pos1 = pos; if (input.charCodeAt(pos) === 58) { @@ -2435,18 +2435,18 @@ var result = (function(){ if (result0 === null) { pos = pos0; } - + cache[cacheKey] = { nextPos: pos, result: result0 }; return result0; } - - + + function cleanupExpected(expected) { expected.sort(); - + var lastExpected = null; var cleanExpected = []; for (var i = 0; i < expected.length; i++) { @@ -2457,7 +2457,7 @@ var result = (function(){ } return cleanExpected; } - + function computeErrorPosition() { /* * The first idea was to use |String.split| to break the input up to the @@ -2465,11 +2465,11 @@ var result = (function(){ * there. However IE's |split| implementation is so broken that it was * enough to prevent it. */ - + var line = 1; var column = 1; var seenCR = false; - + for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) { var ch = input.charAt(i); if (ch === "\n") { @@ -2485,11 +2485,11 @@ var result = (function(){ seenCR = false; } } - + return { line: line, column: column }; } - - + + function nth(n) { return { type: 'nth-child', index: { type: 'literal', value: n } }; } function nthLast(n) { return { type: 'nth-last-child', index: { type: 'literal', value: n } }; } function strUnescape(s) { @@ -2506,10 +2506,10 @@ var result = (function(){ } }); } - - + + var result = parseFunctions[startRule](); - + /* * The parser is now in one of the following three states: * @@ -2538,7 +2538,7 @@ var result = (function(){ var offset = Math.max(pos, rightmostFailuresPos); var found = offset < input.length ? input.charAt(offset) : null; var errorPosition = computeErrorPosition(); - + throw new this.SyntaxError( cleanupExpected(rightmostFailuresExpected), found, @@ -2547,20 +2547,20 @@ var result = (function(){ errorPosition.column ); } - + return result; }, - + /* Returns the parser source code. */ toSource: function() { return this._source; } }; - + /* Thrown when a parser encounters a syntax error. */ - + result.SyntaxError = function(expected, found, offset, line, column) { function buildMessage(expected, found) { var expectedHumanized, foundHumanized; - + switch (expected.length) { case 0: expectedHumanized = "end of input"; @@ -2573,12 +2573,12 @@ var result = (function(){ + " or " + expected[expected.length - 1]; } - + foundHumanized = found ? quote(found) : "end of input"; - + return "Expected " + expectedHumanized + " but " + foundHumanized + " found."; } - + this.name = "SyntaxError"; this.expected = expected; this.found = found; @@ -2587,9 +2587,9 @@ var result = (function(){ this.line = line; this.column = column; }; - + result.SyntaxError.prototype = Error.prototype; - + return result; })(); if (typeof define === "function" && define.amd) { define(function(){ return result; }); } else if (typeof module !== "undefined" && module.exports) { module.exports = result; } else { this.esquery = result; } |