diff --git a/tools/node_modules/eslint/node_modules/eslint-utils/README.md b/tools/node_modules/eslint/node_modules/eslint-utils/README.md
index 03583806246467..0b917591b0220b 100644
--- a/tools/node_modules/eslint/node_modules/eslint-utils/README.md
+++ b/tools/node_modules/eslint/node_modules/eslint-utils/README.md
@@ -13,7 +13,6 @@ This package provides utility functions and classes for make ESLint custom rules
For examples:
- [getStaticValue](https://eslint-utils.mysticatea.dev/api/ast-utils.html#getstaticvalue) evaluates static value on AST.
-- [PatternMatcher](https://eslint-utils.mysticatea.dev/api/ast-utils.html#patternmatcher-class) finds a regular expression pattern as handling escape sequences.
- [ReferenceTracker](https://eslint-utils.mysticatea.dev/api/scope-utils.html#referencetracker-class) checks the members of modules/globals as handling assignments and destructuring.
## 📖 Usage
diff --git a/tools/node_modules/eslint/node_modules/eslint-utils/index.js b/tools/node_modules/eslint/node_modules/eslint-utils/index.js
index f5d3f3e6097d2f..b61c8741abdf7a 100644
--- a/tools/node_modules/eslint/node_modules/eslint-utils/index.js
+++ b/tools/node_modules/eslint/node_modules/eslint-utils/index.js
@@ -1352,13 +1352,13 @@ class ReferenceTracker {
* @param {Scope} globalScope The global scope.
* @param {object} [options] The options.
* @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
- * @param {string[]} [options.globalObjectNames=["global","self","window"]] The variable names for Global Object.
+ * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
*/
constructor(
globalScope,
{
mode = "strict",
- globalObjectNames = ["global", "self", "window"],
+ globalObjectNames = ["global", "globalThis", "self", "window"],
} = {}
) {
this.variableStack = [];
diff --git a/tools/node_modules/eslint/node_modules/eslint-utils/index.mjs b/tools/node_modules/eslint/node_modules/eslint-utils/index.mjs
index 4b2a20edf5f077..c6fab531e1fe6f 100644
--- a/tools/node_modules/eslint/node_modules/eslint-utils/index.mjs
+++ b/tools/node_modules/eslint/node_modules/eslint-utils/index.mjs
@@ -1346,13 +1346,13 @@ class ReferenceTracker {
* @param {Scope} globalScope The global scope.
* @param {object} [options] The options.
* @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
- * @param {string[]} [options.globalObjectNames=["global","self","window"]] The variable names for Global Object.
+ * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
*/
constructor(
globalScope,
{
mode = "strict",
- globalObjectNames = ["global", "self", "window"],
+ globalObjectNames = ["global", "globalThis", "self", "window"],
} = {}
) {
this.variableStack = [];
diff --git a/tools/node_modules/eslint/node_modules/eslint-utils/package.json b/tools/node_modules/eslint/node_modules/eslint-utils/package.json
index 5b9b668f293690..81da6fd3701e75 100644
--- a/tools/node_modules/eslint/node_modules/eslint-utils/package.json
+++ b/tools/node_modules/eslint/node_modules/eslint-utils/package.json
@@ -63,5 +63,5 @@
"watch": "warun \"{src,test}/**/*.js\" -- npm run -s test:mocha"
},
"sideEffects": false,
- "version": "1.4.3"
+ "version": "2.0.0"
}
\ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/espree/espree.js b/tools/node_modules/eslint/node_modules/espree/espree.js
index ce277c1867b44c..d8069528b16946 100644
--- a/tools/node_modules/eslint/node_modules/espree/espree.js
+++ b/tools/node_modules/eslint/node_modules/espree/espree.js
@@ -62,6 +62,7 @@ const acorn = require("acorn");
const jsx = require("acorn-jsx");
const astNodeTypes = require("./lib/ast-node-types");
const espree = require("./lib/espree");
+const { getLatestEcmaVersion, getSupportedEcmaVersions } = require("./lib/options");
// To initialize lazily.
const parsers = {
@@ -170,3 +171,7 @@ exports.Syntax = (function() {
exports.VisitorKeys = (function() {
return require("eslint-visitor-keys").KEYS;
}());
+
+exports.latestEcmaVersion = getLatestEcmaVersion();
+
+exports.supportedEcmaVersions = getSupportedEcmaVersions();
diff --git a/tools/node_modules/eslint/node_modules/espree/lib/espree.js b/tools/node_modules/eslint/node_modules/espree/lib/espree.js
index 9fd035ebe8f968..50ca6e42f250f6 100644
--- a/tools/node_modules/eslint/node_modules/espree/lib/espree.js
+++ b/tools/node_modules/eslint/node_modules/espree/lib/espree.js
@@ -2,77 +2,11 @@
/* eslint-disable no-param-reassign*/
const TokenTranslator = require("./token-translator");
+const { normalizeOptions } = require("./options");
-const DEFAULT_ECMA_VERSION = 5;
const STATE = Symbol("espree's internal state");
const ESPRIMA_FINISH_NODE = Symbol("espree's esprimaFinishNode");
-/**
- * Normalize ECMAScript version from the initial config
- * @param {number} ecmaVersion ECMAScript version from the initial config
- * @throws {Error} throws an error if the ecmaVersion is invalid.
- * @returns {number} normalized ECMAScript version
- */
-function normalizeEcmaVersion(ecmaVersion = DEFAULT_ECMA_VERSION) {
- if (typeof ecmaVersion !== "number") {
- throw new Error(`ecmaVersion must be a number. Received value of type ${typeof ecmaVersion} instead.`);
- }
-
- let version = ecmaVersion;
-
- // Calculate ECMAScript edition number from official year version starting with
- // ES2015, which corresponds with ES6 (or a difference of 2009).
- if (version >= 2015) {
- version -= 2009;
- }
-
- switch (version) {
- case 3:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- return version;
-
- // no default
- }
-
- throw new Error("Invalid ecmaVersion.");
-}
-
-/**
- * Normalize sourceType from the initial config
- * @param {string} sourceType to normalize
- * @throws {Error} throw an error if sourceType is invalid
- * @returns {string} normalized sourceType
- */
-function normalizeSourceType(sourceType = "script") {
- if (sourceType === "script" || sourceType === "module") {
- return sourceType;
- }
- throw new Error("Invalid sourceType.");
-}
-
-/**
- * Normalize parserOptions
- * @param {Object} options the parser options to normalize
- * @throws {Error} throw an error if found invalid option.
- * @returns {Object} normalized options
- */
-function normalizeOptions(options) {
- const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);
- const sourceType = normalizeSourceType(options.sourceType);
- const ranges = options.range === true;
- const locations = options.loc === true;
-
- if (sourceType === "module" && ecmaVersion < 6) {
- throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.");
- }
- return Object.assign({}, options, { ecmaVersion, sourceType, ranges, locations });
-}
/**
* Converts an Acorn comment to a Esprima comment.
diff --git a/tools/node_modules/eslint/node_modules/espree/lib/options.js b/tools/node_modules/eslint/node_modules/espree/lib/options.js
new file mode 100644
index 00000000000000..ccebbea477855b
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/espree/lib/options.js
@@ -0,0 +1,105 @@
+/**
+ * @fileoverview A collection of methods for processing Espree's options.
+ * @author Kai Cataldo
+ */
+
+"use strict";
+
+//------------------------------------------------------------------------------
+// Helpers
+//------------------------------------------------------------------------------
+
+const DEFAULT_ECMA_VERSION = 5;
+const SUPPORTED_VERSIONS = [
+ 3,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11
+];
+
+/**
+ * Normalize ECMAScript version from the initial config
+ * @param {number} ecmaVersion ECMAScript version from the initial config
+ * @throws {Error} throws an error if the ecmaVersion is invalid.
+ * @returns {number} normalized ECMAScript version
+ */
+function normalizeEcmaVersion(ecmaVersion = DEFAULT_ECMA_VERSION) {
+ if (typeof ecmaVersion !== "number") {
+ throw new Error(`ecmaVersion must be a number. Received value of type ${typeof ecmaVersion} instead.`);
+ }
+
+ let version = ecmaVersion;
+
+ // Calculate ECMAScript edition number from official year version starting with
+ // ES2015, which corresponds with ES6 (or a difference of 2009).
+ if (version >= 2015) {
+ version -= 2009;
+ }
+
+ if (!SUPPORTED_VERSIONS.includes(version)) {
+ throw new Error("Invalid ecmaVersion.");
+ }
+
+ return version;
+}
+
+/**
+ * Normalize sourceType from the initial config
+ * @param {string} sourceType to normalize
+ * @throws {Error} throw an error if sourceType is invalid
+ * @returns {string} normalized sourceType
+ */
+function normalizeSourceType(sourceType = "script") {
+ if (sourceType === "script" || sourceType === "module") {
+ return sourceType;
+ }
+ throw new Error("Invalid sourceType.");
+}
+
+/**
+ * Normalize parserOptions
+ * @param {Object} options the parser options to normalize
+ * @throws {Error} throw an error if found invalid option.
+ * @returns {Object} normalized options
+ */
+function normalizeOptions(options) {
+ const ecmaVersion = normalizeEcmaVersion(options.ecmaVersion);
+ const sourceType = normalizeSourceType(options.sourceType);
+ const ranges = options.range === true;
+ const locations = options.loc === true;
+
+ if (sourceType === "module" && ecmaVersion < 6) {
+ throw new Error("sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options.");
+ }
+ return Object.assign({}, options, { ecmaVersion, sourceType, ranges, locations });
+}
+
+/**
+ * Get the latest ECMAScript version supported by Espree.
+ * @returns {number} The latest ECMAScript version.
+ */
+function getLatestEcmaVersion() {
+ return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1];
+}
+
+/**
+ * Get the list of ECMAScript versions supported by Espree.
+ * @returns {number[]} An array containing the supported ECMAScript versions.
+ */
+function getSupportedEcmaVersions() {
+ return [...SUPPORTED_VERSIONS];
+}
+
+//------------------------------------------------------------------------------
+// Public
+//------------------------------------------------------------------------------
+
+module.exports = {
+ normalizeOptions,
+ getLatestEcmaVersion,
+ getSupportedEcmaVersions
+};
diff --git a/tools/node_modules/eslint/node_modules/espree/package.json b/tools/node_modules/eslint/node_modules/espree/package.json
index 17d49f6e22af56..d22f11891bdd84 100644
--- a/tools/node_modules/eslint/node_modules/espree/package.json
+++ b/tools/node_modules/eslint/node_modules/espree/package.json
@@ -8,8 +8,8 @@
},
"bundleDependencies": false,
"dependencies": {
- "acorn": "^7.1.0",
- "acorn-jsx": "^5.1.0",
+ "acorn": "^7.1.1",
+ "acorn-jsx": "^5.2.0",
"eslint-visitor-keys": "^1.1.0"
},
"deprecated": false,
@@ -66,5 +66,5 @@
"publish-release": "eslint-publish-release",
"test": "npm run-script lint && node Makefile.js test"
},
- "version": "6.1.2"
+ "version": "6.2.1"
}
\ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/esquery/README.md b/tools/node_modules/eslint/node_modules/esquery/README.md
index 3e51cdb04ece13..8264efcb90db96 100644
--- a/tools/node_modules/eslint/node_modules/esquery/README.md
+++ b/tools/node_modules/eslint/node_modules/esquery/README.md
@@ -7,7 +7,7 @@ The following selectors are supported:
* [wildcard](http://dev.w3.org/csswg/selectors4/#universal-selector): `*`
* [attribute existence](http://dev.w3.org/csswg/selectors4/#attribute-selectors): `[attr]`
* [attribute value](http://dev.w3.org/csswg/selectors4/#attribute-selectors): `[attr="foo"]` or `[attr=123]`
-* attribute regex: `[attr=/foo.*/]`
+* attribute regex: `[attr=/foo.*/]` or (with flags) `[attr=/foo.*/is]`
* attribute conditions: `[attr!="foo"]`, `[attr>2]`, `[attr<3]`, `[attr>=2]`, or `[attr<=3]`
* nested attribute: `[attr.level2="foo"]`
* field: `FunctionDeclaration > Identifier.id`
diff --git a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.js b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.js
new file mode 100644
index 00000000000000..bfb6bbee93e54c
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.js
@@ -0,0 +1,3682 @@
+var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
+
+function createCommonjsModule(fn, module) {
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
+}
+
+var estraverse = createCommonjsModule(function (module, exports) {
+/*
+ Copyright (C) 2012-2013 Yusuke Suzuki
+ Copyright (C) 2012 Ariya Hidayat
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*jslint vars:false, bitwise:true*/
+/*jshint indent:4*/
+/*global exports:true*/
+(function clone(exports) {
+
+ var Syntax,
+ VisitorOption,
+ VisitorKeys,
+ BREAK,
+ SKIP,
+ REMOVE;
+
+ function deepCopy(obj) {
+ var ret = {}, key, val;
+ for (key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ val = obj[key];
+ if (typeof val === 'object' && val !== null) {
+ ret[key] = deepCopy(val);
+ } else {
+ ret[key] = val;
+ }
+ }
+ }
+ return ret;
+ }
+
+ // based on LLVM libc++ upper_bound / lower_bound
+ // MIT License
+
+ function upperBound(array, func) {
+ var diff, len, i, current;
+
+ len = array.length;
+ i = 0;
+
+ while (len) {
+ diff = len >>> 1;
+ current = i + diff;
+ if (func(array[current])) {
+ len = diff;
+ } else {
+ i = current + 1;
+ len -= diff + 1;
+ }
+ }
+ return i;
+ }
+
+ Syntax = {
+ AssignmentExpression: 'AssignmentExpression',
+ AssignmentPattern: 'AssignmentPattern',
+ ArrayExpression: 'ArrayExpression',
+ ArrayPattern: 'ArrayPattern',
+ ArrowFunctionExpression: 'ArrowFunctionExpression',
+ AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
+ BlockStatement: 'BlockStatement',
+ BinaryExpression: 'BinaryExpression',
+ BreakStatement: 'BreakStatement',
+ CallExpression: 'CallExpression',
+ CatchClause: 'CatchClause',
+ ClassBody: 'ClassBody',
+ ClassDeclaration: 'ClassDeclaration',
+ ClassExpression: 'ClassExpression',
+ ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
+ ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
+ ConditionalExpression: 'ConditionalExpression',
+ ContinueStatement: 'ContinueStatement',
+ DebuggerStatement: 'DebuggerStatement',
+ DirectiveStatement: 'DirectiveStatement',
+ DoWhileStatement: 'DoWhileStatement',
+ EmptyStatement: 'EmptyStatement',
+ ExportAllDeclaration: 'ExportAllDeclaration',
+ ExportDefaultDeclaration: 'ExportDefaultDeclaration',
+ ExportNamedDeclaration: 'ExportNamedDeclaration',
+ ExportSpecifier: 'ExportSpecifier',
+ ExpressionStatement: 'ExpressionStatement',
+ ForStatement: 'ForStatement',
+ ForInStatement: 'ForInStatement',
+ ForOfStatement: 'ForOfStatement',
+ FunctionDeclaration: 'FunctionDeclaration',
+ FunctionExpression: 'FunctionExpression',
+ GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
+ Identifier: 'Identifier',
+ IfStatement: 'IfStatement',
+ ImportExpression: 'ImportExpression',
+ ImportDeclaration: 'ImportDeclaration',
+ ImportDefaultSpecifier: 'ImportDefaultSpecifier',
+ ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
+ ImportSpecifier: 'ImportSpecifier',
+ Literal: 'Literal',
+ LabeledStatement: 'LabeledStatement',
+ LogicalExpression: 'LogicalExpression',
+ MemberExpression: 'MemberExpression',
+ MetaProperty: 'MetaProperty',
+ MethodDefinition: 'MethodDefinition',
+ ModuleSpecifier: 'ModuleSpecifier',
+ NewExpression: 'NewExpression',
+ ObjectExpression: 'ObjectExpression',
+ ObjectPattern: 'ObjectPattern',
+ Program: 'Program',
+ Property: 'Property',
+ RestElement: 'RestElement',
+ ReturnStatement: 'ReturnStatement',
+ SequenceExpression: 'SequenceExpression',
+ SpreadElement: 'SpreadElement',
+ Super: 'Super',
+ SwitchStatement: 'SwitchStatement',
+ SwitchCase: 'SwitchCase',
+ TaggedTemplateExpression: 'TaggedTemplateExpression',
+ TemplateElement: 'TemplateElement',
+ TemplateLiteral: 'TemplateLiteral',
+ ThisExpression: 'ThisExpression',
+ ThrowStatement: 'ThrowStatement',
+ TryStatement: 'TryStatement',
+ UnaryExpression: 'UnaryExpression',
+ UpdateExpression: 'UpdateExpression',
+ VariableDeclaration: 'VariableDeclaration',
+ VariableDeclarator: 'VariableDeclarator',
+ WhileStatement: 'WhileStatement',
+ WithStatement: 'WithStatement',
+ YieldExpression: 'YieldExpression'
+ };
+
+ VisitorKeys = {
+ AssignmentExpression: ['left', 'right'],
+ AssignmentPattern: ['left', 'right'],
+ ArrayExpression: ['elements'],
+ ArrayPattern: ['elements'],
+ ArrowFunctionExpression: ['params', 'body'],
+ AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
+ BlockStatement: ['body'],
+ BinaryExpression: ['left', 'right'],
+ BreakStatement: ['label'],
+ CallExpression: ['callee', 'arguments'],
+ CatchClause: ['param', 'body'],
+ ClassBody: ['body'],
+ ClassDeclaration: ['id', 'superClass', 'body'],
+ ClassExpression: ['id', 'superClass', 'body'],
+ ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
+ ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
+ ConditionalExpression: ['test', 'consequent', 'alternate'],
+ ContinueStatement: ['label'],
+ DebuggerStatement: [],
+ DirectiveStatement: [],
+ DoWhileStatement: ['body', 'test'],
+ EmptyStatement: [],
+ ExportAllDeclaration: ['source'],
+ ExportDefaultDeclaration: ['declaration'],
+ ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
+ ExportSpecifier: ['exported', 'local'],
+ ExpressionStatement: ['expression'],
+ ForStatement: ['init', 'test', 'update', 'body'],
+ ForInStatement: ['left', 'right', 'body'],
+ ForOfStatement: ['left', 'right', 'body'],
+ FunctionDeclaration: ['id', 'params', 'body'],
+ FunctionExpression: ['id', 'params', 'body'],
+ GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
+ Identifier: [],
+ IfStatement: ['test', 'consequent', 'alternate'],
+ ImportExpression: ['source'],
+ ImportDeclaration: ['specifiers', 'source'],
+ ImportDefaultSpecifier: ['local'],
+ ImportNamespaceSpecifier: ['local'],
+ ImportSpecifier: ['imported', 'local'],
+ Literal: [],
+ LabeledStatement: ['label', 'body'],
+ LogicalExpression: ['left', 'right'],
+ MemberExpression: ['object', 'property'],
+ MetaProperty: ['meta', 'property'],
+ MethodDefinition: ['key', 'value'],
+ ModuleSpecifier: [],
+ NewExpression: ['callee', 'arguments'],
+ ObjectExpression: ['properties'],
+ ObjectPattern: ['properties'],
+ Program: ['body'],
+ Property: ['key', 'value'],
+ RestElement: [ 'argument' ],
+ ReturnStatement: ['argument'],
+ SequenceExpression: ['expressions'],
+ SpreadElement: ['argument'],
+ Super: [],
+ SwitchStatement: ['discriminant', 'cases'],
+ SwitchCase: ['test', 'consequent'],
+ TaggedTemplateExpression: ['tag', 'quasi'],
+ TemplateElement: [],
+ TemplateLiteral: ['quasis', 'expressions'],
+ ThisExpression: [],
+ ThrowStatement: ['argument'],
+ TryStatement: ['block', 'handler', 'finalizer'],
+ UnaryExpression: ['argument'],
+ UpdateExpression: ['argument'],
+ VariableDeclaration: ['declarations'],
+ VariableDeclarator: ['id', 'init'],
+ WhileStatement: ['test', 'body'],
+ WithStatement: ['object', 'body'],
+ YieldExpression: ['argument']
+ };
+
+ // unique id
+ BREAK = {};
+ SKIP = {};
+ REMOVE = {};
+
+ VisitorOption = {
+ Break: BREAK,
+ Skip: SKIP,
+ Remove: REMOVE
+ };
+
+ function Reference(parent, key) {
+ this.parent = parent;
+ this.key = key;
+ }
+
+ Reference.prototype.replace = function replace(node) {
+ this.parent[this.key] = node;
+ };
+
+ Reference.prototype.remove = function remove() {
+ if (Array.isArray(this.parent)) {
+ this.parent.splice(this.key, 1);
+ return true;
+ } else {
+ this.replace(null);
+ return false;
+ }
+ };
+
+ function Element(node, path, wrap, ref) {
+ this.node = node;
+ this.path = path;
+ this.wrap = wrap;
+ this.ref = ref;
+ }
+
+ function Controller() { }
+
+ // API:
+ // return property path array from root to current node
+ Controller.prototype.path = function path() {
+ var i, iz, j, jz, result, element;
+
+ function addToPath(result, path) {
+ if (Array.isArray(path)) {
+ for (j = 0, jz = path.length; j < jz; ++j) {
+ result.push(path[j]);
+ }
+ } else {
+ result.push(path);
+ }
+ }
+
+ // root node
+ if (!this.__current.path) {
+ return null;
+ }
+
+ // first node is sentinel, second node is root element
+ result = [];
+ for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
+ element = this.__leavelist[i];
+ addToPath(result, element.path);
+ }
+ addToPath(result, this.__current.path);
+ return result;
+ };
+
+ // API:
+ // return type of current node
+ Controller.prototype.type = function () {
+ var node = this.current();
+ return node.type || this.__current.wrap;
+ };
+
+ // API:
+ // return array of parent elements
+ Controller.prototype.parents = function parents() {
+ var i, iz, result;
+
+ // first node is sentinel
+ result = [];
+ for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
+ result.push(this.__leavelist[i].node);
+ }
+
+ return result;
+ };
+
+ // API:
+ // return current node
+ Controller.prototype.current = function current() {
+ return this.__current.node;
+ };
+
+ Controller.prototype.__execute = function __execute(callback, element) {
+ var previous, result;
+
+ result = undefined;
+
+ previous = this.__current;
+ this.__current = element;
+ this.__state = null;
+ if (callback) {
+ result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
+ }
+ this.__current = previous;
+
+ return result;
+ };
+
+ // API:
+ // notify control skip / break
+ Controller.prototype.notify = function notify(flag) {
+ this.__state = flag;
+ };
+
+ // API:
+ // skip child nodes of current node
+ Controller.prototype.skip = function () {
+ this.notify(SKIP);
+ };
+
+ // API:
+ // break traversals
+ Controller.prototype['break'] = function () {
+ this.notify(BREAK);
+ };
+
+ // API:
+ // remove node
+ Controller.prototype.remove = function () {
+ this.notify(REMOVE);
+ };
+
+ Controller.prototype.__initialize = function(root, visitor) {
+ this.visitor = visitor;
+ this.root = root;
+ this.__worklist = [];
+ this.__leavelist = [];
+ this.__current = null;
+ this.__state = null;
+ this.__fallback = null;
+ if (visitor.fallback === 'iteration') {
+ this.__fallback = Object.keys;
+ } else if (typeof visitor.fallback === 'function') {
+ this.__fallback = visitor.fallback;
+ }
+
+ this.__keys = VisitorKeys;
+ if (visitor.keys) {
+ this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
+ }
+ };
+
+ function isNode(node) {
+ if (node == null) {
+ return false;
+ }
+ return typeof node === 'object' && typeof node.type === 'string';
+ }
+
+ function isProperty(nodeType, key) {
+ return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
+ }
+
+ Controller.prototype.traverse = function traverse(root, visitor) {
+ var worklist,
+ leavelist,
+ element,
+ node,
+ nodeType,
+ ret,
+ key,
+ current,
+ current2,
+ candidates,
+ candidate,
+ sentinel;
+
+ this.__initialize(root, visitor);
+
+ sentinel = {};
+
+ // reference
+ worklist = this.__worklist;
+ leavelist = this.__leavelist;
+
+ // initialize
+ worklist.push(new Element(root, null, null, null));
+ leavelist.push(new Element(null, null, null, null));
+
+ while (worklist.length) {
+ element = worklist.pop();
+
+ if (element === sentinel) {
+ element = leavelist.pop();
+
+ ret = this.__execute(visitor.leave, element);
+
+ if (this.__state === BREAK || ret === BREAK) {
+ return;
+ }
+ continue;
+ }
+
+ if (element.node) {
+
+ ret = this.__execute(visitor.enter, element);
+
+ if (this.__state === BREAK || ret === BREAK) {
+ return;
+ }
+
+ worklist.push(sentinel);
+ leavelist.push(element);
+
+ if (this.__state === SKIP || ret === SKIP) {
+ continue;
+ }
+
+ node = element.node;
+ nodeType = node.type || element.wrap;
+ candidates = this.__keys[nodeType];
+ if (!candidates) {
+ if (this.__fallback) {
+ candidates = this.__fallback(node);
+ } else {
+ throw new Error('Unknown node type ' + nodeType + '.');
+ }
+ }
+
+ current = candidates.length;
+ while ((current -= 1) >= 0) {
+ key = candidates[current];
+ candidate = node[key];
+ if (!candidate) {
+ continue;
+ }
+
+ if (Array.isArray(candidate)) {
+ current2 = candidate.length;
+ while ((current2 -= 1) >= 0) {
+ if (!candidate[current2]) {
+ continue;
+ }
+ if (isProperty(nodeType, candidates[current])) {
+ element = new Element(candidate[current2], [key, current2], 'Property', null);
+ } else if (isNode(candidate[current2])) {
+ element = new Element(candidate[current2], [key, current2], null, null);
+ } else {
+ continue;
+ }
+ worklist.push(element);
+ }
+ } else if (isNode(candidate)) {
+ worklist.push(new Element(candidate, key, null, null));
+ }
+ }
+ }
+ }
+ };
+
+ Controller.prototype.replace = function replace(root, visitor) {
+ var worklist,
+ leavelist,
+ node,
+ nodeType,
+ target,
+ element,
+ current,
+ current2,
+ candidates,
+ candidate,
+ sentinel,
+ outer,
+ key;
+
+ function removeElem(element) {
+ var i,
+ key,
+ nextElem,
+ parent;
+
+ if (element.ref.remove()) {
+ // When the reference is an element of an array.
+ key = element.ref.key;
+ parent = element.ref.parent;
+
+ // If removed from array, then decrease following items' keys.
+ i = worklist.length;
+ while (i--) {
+ nextElem = worklist[i];
+ if (nextElem.ref && nextElem.ref.parent === parent) {
+ if (nextElem.ref.key < key) {
+ break;
+ }
+ --nextElem.ref.key;
+ }
+ }
+ }
+ }
+
+ this.__initialize(root, visitor);
+
+ sentinel = {};
+
+ // reference
+ worklist = this.__worklist;
+ leavelist = this.__leavelist;
+
+ // initialize
+ outer = {
+ root: root
+ };
+ element = new Element(root, null, null, new Reference(outer, 'root'));
+ worklist.push(element);
+ leavelist.push(element);
+
+ while (worklist.length) {
+ element = worklist.pop();
+
+ if (element === sentinel) {
+ element = leavelist.pop();
+
+ target = this.__execute(visitor.leave, element);
+
+ // node may be replaced with null,
+ // so distinguish between undefined and null in this place
+ if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
+ // replace
+ element.ref.replace(target);
+ }
+
+ if (this.__state === REMOVE || target === REMOVE) {
+ removeElem(element);
+ }
+
+ if (this.__state === BREAK || target === BREAK) {
+ return outer.root;
+ }
+ continue;
+ }
+
+ target = this.__execute(visitor.enter, element);
+
+ // node may be replaced with null,
+ // so distinguish between undefined and null in this place
+ if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
+ // replace
+ element.ref.replace(target);
+ element.node = target;
+ }
+
+ if (this.__state === REMOVE || target === REMOVE) {
+ removeElem(element);
+ element.node = null;
+ }
+
+ if (this.__state === BREAK || target === BREAK) {
+ return outer.root;
+ }
+
+ // node may be null
+ node = element.node;
+ if (!node) {
+ continue;
+ }
+
+ worklist.push(sentinel);
+ leavelist.push(element);
+
+ if (this.__state === SKIP || target === SKIP) {
+ continue;
+ }
+
+ nodeType = node.type || element.wrap;
+ candidates = this.__keys[nodeType];
+ if (!candidates) {
+ if (this.__fallback) {
+ candidates = this.__fallback(node);
+ } else {
+ throw new Error('Unknown node type ' + nodeType + '.');
+ }
+ }
+
+ current = candidates.length;
+ while ((current -= 1) >= 0) {
+ key = candidates[current];
+ candidate = node[key];
+ if (!candidate) {
+ continue;
+ }
+
+ if (Array.isArray(candidate)) {
+ current2 = candidate.length;
+ while ((current2 -= 1) >= 0) {
+ if (!candidate[current2]) {
+ continue;
+ }
+ if (isProperty(nodeType, candidates[current])) {
+ element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
+ } else if (isNode(candidate[current2])) {
+ element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
+ } else {
+ continue;
+ }
+ worklist.push(element);
+ }
+ } else if (isNode(candidate)) {
+ worklist.push(new Element(candidate, key, null, new Reference(node, key)));
+ }
+ }
+ }
+
+ return outer.root;
+ };
+
+ function traverse(root, visitor) {
+ var controller = new Controller();
+ return controller.traverse(root, visitor);
+ }
+
+ function replace(root, visitor) {
+ var controller = new Controller();
+ return controller.replace(root, visitor);
+ }
+
+ function extendCommentRange(comment, tokens) {
+ var target;
+
+ target = upperBound(tokens, function search(token) {
+ return token.range[0] > comment.range[0];
+ });
+
+ comment.extendedRange = [comment.range[0], comment.range[1]];
+
+ if (target !== tokens.length) {
+ comment.extendedRange[1] = tokens[target].range[0];
+ }
+
+ target -= 1;
+ if (target >= 0) {
+ comment.extendedRange[0] = tokens[target].range[1];
+ }
+
+ return comment;
+ }
+
+ function attachComments(tree, providedComments, tokens) {
+ // At first, we should calculate extended comment ranges.
+ var comments = [], comment, len, i, cursor;
+
+ if (!tree.range) {
+ throw new Error('attachComments needs range information');
+ }
+
+ // tokens array is empty, we attach comments to tree as 'leadingComments'
+ if (!tokens.length) {
+ if (providedComments.length) {
+ for (i = 0, len = providedComments.length; i < len; i += 1) {
+ comment = deepCopy(providedComments[i]);
+ comment.extendedRange = [0, tree.range[0]];
+ comments.push(comment);
+ }
+ tree.leadingComments = comments;
+ }
+ return tree;
+ }
+
+ for (i = 0, len = providedComments.length; i < len; i += 1) {
+ comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
+ }
+
+ // This is based on John Freeman's implementation.
+ cursor = 0;
+ traverse(tree, {
+ enter: function (node) {
+ var comment;
+
+ while (cursor < comments.length) {
+ comment = comments[cursor];
+ if (comment.extendedRange[1] > node.range[0]) {
+ break;
+ }
+
+ if (comment.extendedRange[1] === node.range[0]) {
+ if (!node.leadingComments) {
+ node.leadingComments = [];
+ }
+ node.leadingComments.push(comment);
+ comments.splice(cursor, 1);
+ } else {
+ cursor += 1;
+ }
+ }
+
+ // already out of owned node
+ if (cursor === comments.length) {
+ return VisitorOption.Break;
+ }
+
+ if (comments[cursor].extendedRange[0] > node.range[1]) {
+ return VisitorOption.Skip;
+ }
+ }
+ });
+
+ cursor = 0;
+ traverse(tree, {
+ leave: function (node) {
+ var comment;
+
+ while (cursor < comments.length) {
+ comment = comments[cursor];
+ if (node.range[1] < comment.extendedRange[0]) {
+ break;
+ }
+
+ if (node.range[1] === comment.extendedRange[0]) {
+ if (!node.trailingComments) {
+ node.trailingComments = [];
+ }
+ node.trailingComments.push(comment);
+ comments.splice(cursor, 1);
+ } else {
+ cursor += 1;
+ }
+ }
+
+ // already out of owned node
+ if (cursor === comments.length) {
+ return VisitorOption.Break;
+ }
+
+ if (comments[cursor].extendedRange[0] > node.range[1]) {
+ return VisitorOption.Skip;
+ }
+ }
+ });
+
+ return tree;
+ }
+
+ exports.Syntax = Syntax;
+ exports.traverse = traverse;
+ exports.replace = replace;
+ exports.attachComments = attachComments;
+ exports.VisitorKeys = VisitorKeys;
+ exports.VisitorOption = VisitorOption;
+ exports.Controller = Controller;
+ exports.cloneEnvironment = function () { return clone({}); };
+
+ return exports;
+}(exports));
+/* vim: set sw=4 ts=4 et tw=80 : */
+});
+
+var parser = createCommonjsModule(function (module) {
+/*
+ * Generated by PEG.js 0.10.0.
+ *
+ * http://pegjs.org/
+ */
+(function(root, factory) {
+ if ( module.exports) {
+ module.exports = factory();
+ }
+})(commonjsGlobal, function() {
+
+ 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(ss) {
+ return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss };
+ },
+ peg$c1 = function() { return void 0; },
+ peg$c2 = " ",
+ peg$c3 = peg$literalExpectation(" ", false),
+ peg$c4 = /^[^ [\],():#!=><~+.]/,
+ peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false),
+ peg$c6 = function(i) { return i.join(''); },
+ peg$c7 = ">",
+ peg$c8 = peg$literalExpectation(">", false),
+ peg$c9 = function() { return 'child'; },
+ peg$c10 = "~",
+ peg$c11 = peg$literalExpectation("~", false),
+ peg$c12 = function() { return 'sibling'; },
+ peg$c13 = "+",
+ peg$c14 = peg$literalExpectation("+", false),
+ peg$c15 = function() { return 'adjacent'; },
+ peg$c16 = function() { return 'descendant'; },
+ peg$c17 = ",",
+ peg$c18 = peg$literalExpectation(",", false),
+ peg$c19 = function(s, ss) {
+ return [s].concat(ss.map(function (s) { return s[3]; }));
+ },
+ peg$c20 = function(a, ops) {
+ return ops.reduce(function (memo, rhs) {
+ return { type: rhs[0], left: memo, right: rhs[1] };
+ }, a);
+ },
+ peg$c21 = "!",
+ peg$c22 = peg$literalExpectation("!", false),
+ peg$c23 = function(subject, as) {
+ const b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
+ if(subject) b.subject = true;
+ return b;
+ },
+ peg$c24 = "*",
+ peg$c25 = peg$literalExpectation("*", false),
+ peg$c26 = function(a) { return { type: 'wildcard', value: a }; },
+ peg$c27 = "#",
+ peg$c28 = peg$literalExpectation("#", false),
+ peg$c29 = function(i) { return { type: 'identifier', value: i }; },
+ peg$c30 = "[",
+ peg$c31 = peg$literalExpectation("[", false),
+ peg$c32 = "]",
+ peg$c33 = peg$literalExpectation("]", false),
+ peg$c34 = function(v) { return v; },
+ peg$c35 = /^[>", "<", "!"], false, false),
+ peg$c37 = "=",
+ peg$c38 = peg$literalExpectation("=", false),
+ peg$c39 = function(a) { return (a || '') + '='; },
+ peg$c40 = /^[><]/,
+ peg$c41 = peg$classExpectation([">", "<"], false, false),
+ peg$c42 = ".",
+ peg$c43 = peg$literalExpectation(".", false),
+ peg$c44 = function(name, op, value) {
+ return { type: 'attribute', name: name, operator: op, value: value };
+ },
+ peg$c45 = function(name) { return { type: 'attribute', name: name }; },
+ peg$c46 = "\"",
+ peg$c47 = peg$literalExpectation("\"", false),
+ peg$c48 = /^[^\\"]/,
+ peg$c49 = peg$classExpectation(["\\", "\""], true, false),
+ peg$c50 = "\\",
+ peg$c51 = peg$literalExpectation("\\", false),
+ peg$c52 = peg$anyExpectation(),
+ peg$c53 = function(a, b) { return a + b; },
+ peg$c54 = function(d) {
+ return { type: 'literal', value: strUnescape(d.join('')) };
+ },
+ peg$c55 = "'",
+ peg$c56 = peg$literalExpectation("'", false),
+ peg$c57 = /^[^\\']/,
+ peg$c58 = peg$classExpectation(["\\", "'"], true, false),
+ peg$c59 = /^[0-9]/,
+ peg$c60 = peg$classExpectation([["0", "9"]], false, false),
+ peg$c61 = function(a, b) {
+ // Can use `a.flat().join('')` once supported
+ const leadingDecimals = a ? [].concat.apply([], a).join('') : '';
+ return { type: 'literal', value: parseFloat(leadingDecimals + b.join('')) };
+ },
+ peg$c62 = function(i) { return { type: 'literal', value: i }; },
+ peg$c63 = "type(",
+ peg$c64 = peg$literalExpectation("type(", false),
+ peg$c65 = /^[^ )]/,
+ peg$c66 = peg$classExpectation([" ", ")"], true, false),
+ peg$c67 = ")",
+ peg$c68 = peg$literalExpectation(")", false),
+ peg$c69 = function(t) { return { type: 'type', value: t.join('') }; },
+ peg$c70 = /^[imsu]/,
+ peg$c71 = peg$classExpectation(["i", "m", "s", "u"], false, false),
+ peg$c72 = "/",
+ peg$c73 = peg$literalExpectation("/", false),
+ peg$c74 = /^[^\/]/,
+ peg$c75 = peg$classExpectation(["/"], true, false),
+ peg$c76 = function(d, flgs) { return {
+ type: 'regexp', value: new RegExp(d.join(''), flgs ? flgs.join('') : '') };
+ },
+ peg$c77 = function(i, is) {
+ return { type: 'field', name: is.reduce(function(memo, p){ return memo + p[0] + p[1]; }, i)};
+ },
+ peg$c78 = ":not(",
+ peg$c79 = peg$literalExpectation(":not(", false),
+ peg$c80 = function(ss) { return { type: 'not', selectors: ss }; },
+ peg$c81 = ":matches(",
+ peg$c82 = peg$literalExpectation(":matches(", false),
+ peg$c83 = function(ss) { return { type: 'matches', selectors: ss }; },
+ peg$c84 = ":has(",
+ peg$c85 = peg$literalExpectation(":has(", false),
+ peg$c86 = function(ss) { return { type: 'has', selectors: ss }; },
+ peg$c87 = ":first-child",
+ peg$c88 = peg$literalExpectation(":first-child", false),
+ peg$c89 = function() { return nth(1); },
+ peg$c90 = ":last-child",
+ peg$c91 = peg$literalExpectation(":last-child", false),
+ peg$c92 = function() { return nthLast(1); },
+ peg$c93 = ":nth-child(",
+ peg$c94 = peg$literalExpectation(":nth-child(", false),
+ peg$c95 = function(n) { return nth(parseInt(n.join(''), 10)); },
+ peg$c96 = ":nth-last-child(",
+ peg$c97 = peg$literalExpectation(":nth-last-child(", false),
+ peg$c98 = function(n) { return nthLast(parseInt(n.join(''), 10)); },
+ peg$c99 = ":",
+ peg$c100 = peg$literalExpectation(":", false),
+ peg$c101 = "statement",
+ peg$c102 = peg$literalExpectation("statement", true),
+ peg$c103 = "expression",
+ peg$c104 = peg$literalExpectation("expression", true),
+ peg$c105 = "declaration",
+ peg$c106 = peg$literalExpectation("declaration", true),
+ peg$c107 = "function",
+ peg$c108 = peg$literalExpectation("function", true),
+ peg$c109 = "pattern",
+ peg$c110 = peg$literalExpectation("pattern", true),
+ peg$c111 = function(c) {
+ return { type: 'class', name: c };
+ },
+
+ peg$currPos = 0,
+ peg$posDetailsCache = [{ line: 1, column: 1 }],
+ peg$maxFailPos = 0,
+ peg$maxFailExpected = [],
+ peg$resultsCache = {},
+
+ 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 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$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$buildStructuredError(expected, found, location) {
+ return new peg$SyntaxError(
+ peg$SyntaxError.buildMessage(expected, found),
+ expected,
+ found,
+ location
+ );
+ }
+
+ function peg$parsestart() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 0,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseselectors();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c0(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c1();
+ }
+ s0 = s1;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parse_() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 1,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = [];
+ if (input.charCodeAt(peg$currPos) === 32) {
+ s1 = peg$c2;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c3); }
+ }
+ while (s1 !== peg$FAILED) {
+ s0.push(s1);
+ if (input.charCodeAt(peg$currPos) === 32) {
+ s1 = peg$c2;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c3); }
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseidentifierName() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 2,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = [];
+ if (peg$c4.test(input.charAt(peg$currPos))) {
+ s2 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c5); }
+ }
+ if (s2 !== peg$FAILED) {
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ if (peg$c4.test(input.charAt(peg$currPos))) {
+ s2 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c5); }
+ }
+ }
+ } else {
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c6(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsebinaryOp() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 3,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 62) {
+ s2 = peg$c7;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c8); }
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c9();
+ 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$parse_();
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 126) {
+ s2 = peg$c10;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c11); }
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c12();
+ 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$parse_();
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 43) {
+ s2 = peg$c13;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c14); }
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c15();
+ 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;
+ if (input.charCodeAt(peg$currPos) === 32) {
+ s1 = peg$c2;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c3); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c16();
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ }
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseselectors() {
+ var s0, s1, s2, s3, s4, s5, s6, s7;
+
+ var key = peg$currPos * 30 + 4,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parseselector();
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$currPos;
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 44) {
+ s5 = peg$c17;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c18); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parse_();
+ if (s6 !== peg$FAILED) {
+ s7 = peg$parseselector();
+ if (s7 !== peg$FAILED) {
+ s4 = [s4, s5, s6, s7];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$currPos;
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 44) {
+ s5 = peg$c17;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c18); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parse_();
+ if (s6 !== peg$FAILED) {
+ s7 = peg$parseselector();
+ if (s7 !== peg$FAILED) {
+ s4 = [s4, s5, s6, s7];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c19(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseselector() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 5,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parsesequence();
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$currPos;
+ s4 = peg$parsebinaryOp();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsesequence();
+ if (s5 !== peg$FAILED) {
+ s4 = [s4, s5];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$currPos;
+ s4 = peg$parsebinaryOp();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsesequence();
+ if (s5 !== peg$FAILED) {
+ s4 = [s4, s5];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c20(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsesequence() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 6,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 33) {
+ s1 = peg$c21;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c22); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$parseatom();
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$parseatom();
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c23(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseatom() {
+ var s0;
+
+ var key = peg$currPos * 30 + 7,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$parsewildcard();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseidentifier();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseattr();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsefield();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsenegation();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsematches();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsehas();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsefirstChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parselastChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsenthChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsenthLastChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseclass();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsewildcard() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 8,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 42) {
+ s1 = peg$c24;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c25); }
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c26(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseidentifier() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 9,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 35) {
+ s1 = peg$c27;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c28); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseidentifierName();
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c29(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattr() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 10,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 91) {
+ s1 = peg$c30;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c31); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseattrValue();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 93) {
+ s5 = peg$c32;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c33); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c34(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrOps() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 11,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (peg$c35.test(input.charAt(peg$currPos))) {
+ s1 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c36); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 61) {
+ s2 = peg$c37;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c38); }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c39(s1);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ if (peg$c40.test(input.charAt(peg$currPos))) {
+ s0 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ { peg$fail(peg$c41); }
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrEqOps() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 12,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 33) {
+ s1 = peg$c21;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c22); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 61) {
+ s2 = peg$c37;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c38); }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c39(s1);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrName() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 13,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = [];
+ s2 = peg$parseidentifierName();
+ if (s2 === peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s2 = peg$c42;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ s2 = peg$parseidentifierName();
+ if (s2 === peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s2 = peg$c42;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ }
+ }
+ } else {
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c6(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrValue() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 14,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parseattrName();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseattrEqOps();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsetype();
+ if (s5 === peg$FAILED) {
+ s5 = peg$parseregex();
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c44(s1, s3, s5);
+ 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$parseattrName();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseattrOps();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsestring();
+ if (s5 === peg$FAILED) {
+ s5 = peg$parsenumber();
+ if (s5 === peg$FAILED) {
+ s5 = peg$parsepath();
+ }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c44(s1, s3, s5);
+ 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$parseattrName();
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c45(s1);
+ }
+ s0 = s1;
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsestring() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 15,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 34) {
+ s1 = peg$c46;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c47); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c48.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c49); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c51); }
+ }
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c52); }
+ }
+ if (s5 !== peg$FAILED) {
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c48.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c49); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c51); }
+ }
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c52); }
+ }
+ if (s5 !== peg$FAILED) {
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 34) {
+ s3 = peg$c46;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c47); }
+ }
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c54(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;
+ if (input.charCodeAt(peg$currPos) === 39) {
+ s1 = peg$c55;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c56); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c57.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c58); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c51); }
+ }
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c52); }
+ }
+ if (s5 !== peg$FAILED) {
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c57.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c58); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c51); }
+ }
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c52); }
+ }
+ if (s5 !== peg$FAILED) {
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 39) {
+ s3 = peg$c55;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c56); }
+ }
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c54(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenumber() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 16,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$currPos;
+ s2 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s3 = peg$c42;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ if (s3 !== peg$FAILED) {
+ s2 = [s2, s3];
+ s1 = s2;
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c61(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsepath() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 17,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parseidentifierName();
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c62(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsetype() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 18,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 5) === peg$c63) {
+ s1 = peg$c63;
+ peg$currPos += 5;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c64); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ if (peg$c65.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c66); }
+ }
+ if (s4 !== peg$FAILED) {
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ if (peg$c65.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c66); }
+ }
+ }
+ } else {
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c69(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseflags() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 19,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = [];
+ if (peg$c70.test(input.charAt(peg$currPos))) {
+ s1 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c71); }
+ }
+ if (s1 !== peg$FAILED) {
+ while (s1 !== peg$FAILED) {
+ s0.push(s1);
+ if (peg$c70.test(input.charAt(peg$currPos))) {
+ s1 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c71); }
+ }
+ }
+ } else {
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseregex() {
+ var s0, s1, s2, s3, s4;
+
+ var key = peg$currPos * 30 + 20,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 47) {
+ s1 = peg$c72;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c73); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c74.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c75); }
+ }
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c74.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c75); }
+ }
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 47) {
+ s3 = peg$c72;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c73); }
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseflags();
+ if (s4 === peg$FAILED) {
+ s4 = null;
+ }
+ if (s4 !== peg$FAILED) {
+ s1 = peg$c76(s2, 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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsefield() {
+ var s0, s1, s2, s3, s4, s5, s6;
+
+ var key = peg$currPos * 30 + 21,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s1 = peg$c42;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseidentifierName();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ s4 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s5 = peg$c42;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parseidentifierName();
+ if (s6 !== peg$FAILED) {
+ s5 = [s5, s6];
+ s4 = s5;
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ s4 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s5 = peg$c42;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parseidentifierName();
+ if (s6 !== peg$FAILED) {
+ s5 = [s5, s6];
+ s4 = s5;
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ }
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c77(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenegation() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 22,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 5) === peg$c78) {
+ s1 = peg$c78;
+ peg$currPos += 5;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c79); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseselectors();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c80(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsematches() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 23,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 9) === peg$c81) {
+ s1 = peg$c81;
+ peg$currPos += 9;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c82); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseselectors();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c83(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsehas() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 24,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 5) === peg$c84) {
+ s1 = peg$c84;
+ peg$currPos += 5;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c85); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseselectors();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c86(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsefirstChild() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 25,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 12) === peg$c87) {
+ s1 = peg$c87;
+ peg$currPos += 12;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c88); }
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c89();
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parselastChild() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 26,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 11) === peg$c90) {
+ s1 = peg$c90;
+ peg$currPos += 11;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c91); }
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c92();
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenthChild() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 27,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 11) === peg$c93) {
+ s1 = peg$c93;
+ peg$currPos += 11;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c94); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ if (s4 !== peg$FAILED) {
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ }
+ } else {
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c95(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenthLastChild() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 28,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 16) === peg$c96) {
+ s1 = peg$c96;
+ peg$currPos += 16;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c97); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ if (s4 !== peg$FAILED) {
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ }
+ } else {
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c98(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseclass() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 29,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 58) {
+ s1 = peg$c99;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c100); }
+ }
+ if (s1 !== peg$FAILED) {
+ if (input.substr(peg$currPos, 9).toLowerCase() === peg$c101) {
+ s2 = input.substr(peg$currPos, 9);
+ peg$currPos += 9;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c102); }
+ }
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 10).toLowerCase() === peg$c103) {
+ s2 = input.substr(peg$currPos, 10);
+ peg$currPos += 10;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c104); }
+ }
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 11).toLowerCase() === peg$c105) {
+ s2 = input.substr(peg$currPos, 11);
+ peg$currPos += 11;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c106); }
+ }
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 8).toLowerCase() === peg$c107) {
+ s2 = input.substr(peg$currPos, 8);
+ peg$currPos += 8;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c108); }
+ }
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 7).toLowerCase() === peg$c109) {
+ s2 = input.substr(peg$currPos, 7);
+ peg$currPos += 7;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c110); }
+ }
+ }
+ }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c111(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+
+ 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) {
+ return s.replace(/\\(.)/g, function(match, ch) {
+ switch(ch) {
+ case 'b': return '\b';
+ case 'f': return '\f';
+ case 'n': return '\n';
+ case 'r': return '\r';
+ case 't': return '\t';
+ case 'v': return '\v';
+ default: return ch;
+ }
+ });
+ }
+
+
+ peg$result = peg$startRuleFunction();
+
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
+ return peg$result;
+ } else {
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
+ peg$fail(peg$endExpectation());
+ }
+
+ 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: peg$SyntaxError,
+ parse: peg$parse
+ };
+});
+});
+
+/* vim: set sw=4 sts=4 : */
+
+/**
+* @typedef {"LEFT_SIDE"|"RIGHT_SIDE"} Side
+*/
+
+const LEFT_SIDE = 'LEFT_SIDE';
+const RIGHT_SIDE = 'RIGHT_SIDE';
+
+/**
+ * @external AST
+ * @see https://esprima.readthedocs.io/en/latest/syntax-tree-format.html
+ */
+
+/**
+ * One of the rules of `grammar.pegjs`
+ * @typedef {PlainObject} SelectorAST
+ * @see grammar.pegjs
+*/
+
+/**
+ * The `sequence` production of `grammar.pegjs`
+ * @typedef {PlainObject} SelectorSequenceAST
+*/
+
+/**
+ * Get the value of a property which may be multiple levels down
+ * in the object.
+ * @param {?PlainObject} obj
+ * @param {string} key
+ * @returns {undefined|boolean|string|number|external:AST}
+ */
+function getPath(obj, key) {
+ const keys = key.split('.');
+ for (let i = 0; i < keys.length; i++) {
+ if (obj == null) { return obj; }
+ obj = obj[keys[i]];
+ }
+ return obj;
+}
+
+/**
+ * Determine whether `node` can be reached by following `path`,
+ * starting at `ancestor`.
+ * @param {?external:AST} node
+ * @param {?external:AST} ancestor
+ * @param {string[]} path
+ * @returns {boolean}
+ */
+function inPath(node, ancestor, path) {
+ if (path.length === 0) { return node === ancestor; }
+ if (ancestor == null) { return false; }
+ const field = ancestor[path[0]];
+ const remainingPath = path.slice(1);
+ if (Array.isArray(field)) {
+ for (let i = 0, l = field.length; i < l; ++i) {
+ if (inPath(node, field[i], remainingPath)) { return true; }
+ }
+ return false;
+ } else {
+ return inPath(node, field, remainingPath);
+ }
+}
+
+/**
+ * Given a `node` and its ancestors, determine if `node` is matched
+ * by `selector`.
+ * @param {?external:AST} node
+ * @param {?SelectorAST} selector
+ * @param {external:AST[]} [ancestry=[]]
+ * @throws {Error} Unknowns (operator, class name, selector type, or
+ * selector value type)
+ * @returns {boolean}
+ */
+function matches(node, selector, ancestry) {
+ if (!selector) { return true; }
+ if (!node) { return false; }
+ if (!ancestry) { ancestry = []; }
+
+ switch(selector.type) {
+ case 'wildcard':
+ return true;
+
+ case 'identifier':
+ return selector.value.toLowerCase() === node.type.toLowerCase();
+
+ case 'field': {
+ const path = selector.name.split('.');
+ const ancestor = ancestry[path.length - 1];
+ return inPath(node, ancestor, path);
+
+ }
+ case 'matches':
+ for (let i = 0, l = selector.selectors.length; i < l; ++i) {
+ if (matches(node, selector.selectors[i], ancestry)) { return true; }
+ }
+ return false;
+
+ case 'compound':
+ for (let i = 0, l = selector.selectors.length; i < l; ++i) {
+ if (!matches(node, selector.selectors[i], ancestry)) { return false; }
+ }
+ return true;
+
+ case 'not':
+ for (let i = 0, l = selector.selectors.length; i < l; ++i) {
+ if (matches(node, selector.selectors[i], ancestry)) { return false; }
+ }
+ return true;
+
+ case 'has': {
+ const collector = [];
+ for (let i = 0, l = selector.selectors.length; i < l; ++i) {
+ const a = [];
+ estraverse.traverse(node, {
+ enter (node, parent) {
+ if (parent != null) { a.unshift(parent); }
+ if (matches(node, selector.selectors[i], a)) {
+ collector.push(node);
+ }
+ },
+ leave () { a.shift(); },
+ fallback: 'iteration'
+ });
+ }
+ return collector.length !== 0;
+
+ }
+ case 'child':
+ if (matches(node, selector.right, ancestry)) {
+ return matches(ancestry[0], selector.left, ancestry.slice(1));
+ }
+ return false;
+
+ case 'descendant':
+ if (matches(node, selector.right, ancestry)) {
+ for (let i = 0, l = ancestry.length; i < l; ++i) {
+ if (matches(ancestry[i], selector.left, ancestry.slice(i + 1))) {
+ return true;
+ }
+ }
+ }
+ return false;
+
+ case 'attribute': {
+ const p = getPath(node, selector.name);
+ switch (selector.operator) {
+ case void 0:
+ return p != null;
+ case '=':
+ switch (selector.value.type) {
+ case 'regexp': return typeof p === 'string' && selector.value.value.test(p);
+ case 'literal': return `${selector.value.value}` === `${p}`;
+ case 'type': return selector.value.value === typeof p;
+ }
+ throw new Error(`Unknown selector value type: ${selector.value.type}`);
+ case '!=':
+ switch (selector.value.type) {
+ case 'regexp': return !selector.value.value.test(p);
+ case 'literal': return `${selector.value.value}` !== `${p}`;
+ case 'type': return selector.value.value !== typeof p;
+ }
+ throw new Error(`Unknown selector value type: ${selector.value.type}`);
+ case '<=': return p <= selector.value.value;
+ case '<': return p < selector.value.value;
+ case '>': return p > selector.value.value;
+ case '>=': return p >= selector.value.value;
+ }
+ throw new Error(`Unknown operator: ${selector.operator}`);
+ }
+ case 'sibling':
+ return matches(node, selector.right, ancestry) &&
+ sibling(node, selector.left, ancestry, LEFT_SIDE) ||
+ selector.left.subject &&
+ matches(node, selector.left, ancestry) &&
+ sibling(node, selector.right, ancestry, RIGHT_SIDE);
+ case 'adjacent':
+ return matches(node, selector.right, ancestry) &&
+ adjacent(node, selector.left, ancestry, LEFT_SIDE) ||
+ selector.right.subject &&
+ matches(node, selector.left, ancestry) &&
+ adjacent(node, selector.right, ancestry, RIGHT_SIDE);
+
+ case 'nth-child':
+ return matches(node, selector.right, ancestry) &&
+ nthChild(node, ancestry, function () {
+ return selector.index.value - 1;
+ });
+
+ case 'nth-last-child':
+ return matches(node, selector.right, ancestry) &&
+ nthChild(node, ancestry, function (length) {
+ return length - selector.index.value;
+ });
+
+ case 'class':
+ switch(selector.name.toLowerCase()){
+ case 'statement':
+ if(node.type.slice(-9) === 'Statement') return true;
+ // fallthrough: interface Declaration <: Statement { }
+ case 'declaration':
+ return node.type.slice(-11) === 'Declaration';
+ case 'pattern':
+ if(node.type.slice(-7) === 'Pattern') return true;
+ // fallthrough: interface Expression <: Node, Pattern { }
+ case 'expression':
+ return node.type.slice(-10) === 'Expression' ||
+ node.type.slice(-7) === 'Literal' ||
+ (
+ node.type === 'Identifier' &&
+ (ancestry.length === 0 || ancestry[0].type !== 'MetaProperty')
+ ) ||
+ node.type === 'MetaProperty';
+ case 'function':
+ return node.type === 'FunctionDeclaration' ||
+ node.type === 'FunctionExpression' ||
+ node.type === 'ArrowFunctionExpression';
+ }
+ throw new Error(`Unknown class name: ${selector.name}`);
+ }
+
+ throw new Error(`Unknown selector type: ${selector.type}`);
+}
+
+/**
+ * Determines if the given node has a sibling that matches the
+ * given selector.
+ * @param {external:AST} node
+ * @param {SelectorSequenceAST} selector
+ * @param {external:AST[]} ancestry
+ * @param {Side} side
+ * @returns {boolean}
+ */
+function sibling(node, selector, ancestry, side) {
+ const [parent] = ancestry;
+ if (!parent) { return false; }
+ const keys = estraverse.VisitorKeys[parent.type];
+ for (let i = 0, l = keys.length; i < l; ++i) {
+ const listProp = parent[keys[i]];
+ if (Array.isArray(listProp)) {
+ const startIndex = listProp.indexOf(node);
+ if (startIndex < 0) { continue; }
+ let lowerBound, upperBound;
+ if (side === LEFT_SIDE) {
+ lowerBound = 0;
+ upperBound = startIndex;
+ } else {
+ lowerBound = startIndex + 1;
+ upperBound = listProp.length;
+ }
+ for (let k = lowerBound; k < upperBound; ++k) {
+ if (matches(listProp[k], selector, ancestry)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+/**
+ * Determines if the given node has an adjacent sibling that matches
+ * the given selector.
+ * @param {external:AST} node
+ * @param {SelectorSequenceAST} selector
+ * @param {external:AST[]} ancestry
+ * @param {Side} side
+ * @returns {boolean}
+ */
+function adjacent(node, selector, ancestry, side) {
+ const [parent] = ancestry;
+ if (!parent) { return false; }
+ const keys = estraverse.VisitorKeys[parent.type];
+ for (let i = 0, l = keys.length; i < l; ++i) {
+ const listProp = parent[keys[i]];
+ if (Array.isArray(listProp)) {
+ const idx = listProp.indexOf(node);
+ if (idx < 0) { continue; }
+ if (side === LEFT_SIDE && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) {
+ return true;
+ }
+ if (side === RIGHT_SIDE && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+/**
+* @callback IndexFunction
+* @param {Integer} len Containing list's length
+* @returns {Integer}
+*/
+
+/**
+ * Determines if the given node is the nth child, determined by
+ * `idxFn`, which is given the containing list's length.
+ * @param {external:AST} node
+ * @param {external:AST[]} ancestry
+ * @param {IndexFunction} idxFn
+ * @returns {boolean}
+ */
+function nthChild(node, ancestry, idxFn) {
+ const [parent] = ancestry;
+ if (!parent) { return false; }
+ const keys = estraverse.VisitorKeys[parent.type];
+ for (let i = 0, l = keys.length; i < l; ++i) {
+ const listProp = parent[keys[i]];
+ if (Array.isArray(listProp)) {
+ const idx = listProp.indexOf(node);
+ if (idx >= 0 && idx === idxFn(listProp.length)) { return true; }
+ }
+ }
+ return false;
+}
+
+/**
+ * For each selector node marked as a subject, find the portion of the
+ * selector that the subject must match.
+ * @param {SelectorAST} selector
+ * @param {SelectorAST} [ancestor] Defaults to `selector`
+ * @returns {SelectorAST[]}
+ */
+function subjects(selector, ancestor) {
+ if (selector == null || typeof selector != 'object') { return []; }
+ if (ancestor == null) { ancestor = selector; }
+ const results = selector.subject ? [ancestor] : [];
+ for (const [p, sel] of Object.entries(selector)) {
+ results.push(...subjects(sel, p === 'left' ? sel : ancestor));
+ }
+ return results;
+}
+
+/**
+ * From a JS AST and a selector AST, collect all JS AST nodes that
+ * match the selector.
+ * @param {external:AST} ast
+ * @param {?SelectorAST} selector
+ * @returns {external:AST[]}
+ */
+function match(ast, selector) {
+ const ancestry = [], results = [];
+ if (!selector) { return results; }
+ const altSubjects = subjects(selector);
+ estraverse.traverse(ast, {
+ enter (node, parent) {
+ if (parent != null) { ancestry.unshift(parent); }
+ if (matches(node, selector, ancestry)) {
+ if (altSubjects.length) {
+ for (let i = 0, l = altSubjects.length; i < l; ++i) {
+ if (matches(node, altSubjects[i], ancestry)) { results.push(node); }
+ for (let k = 0, m = ancestry.length; k < m; ++k) {
+ if (matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))) {
+ results.push(ancestry[k]);
+ }
+ }
+ }
+ } else {
+ results.push(node);
+ }
+ }
+ },
+ leave () { ancestry.shift(); },
+ fallback: 'iteration'
+ });
+ return results;
+}
+
+/**
+ * Parse a selector string and return its AST.
+ * @param {string} selector
+ * @returns {SelectorAST}
+ */
+function parse(selector) {
+ return parser.parse(selector);
+}
+
+/**
+ * Query the code AST using the selector string.
+ * @param {external:AST} ast
+ * @param {string} selector
+ * @returns {external:AST[]}
+ */
+function query(ast, selector) {
+ return match(ast, parse(selector));
+}
+
+query.parse = parse;
+query.match = match;
+query.matches = matches;
+query.query = query;
+
+export default query;
diff --git a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.min.js b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.min.js
new file mode 100644
index 00000000000000..507a98c8dc29de
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.esm.min.js
@@ -0,0 +1,2 @@
+"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(e,t){return e(t={exports:{}},t.exports),t.exports}var t=e((function(e,t){!function e(t){var r,n,s,o,a,i;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function p(){}function f(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function d(e,t){return(new p).traverse(e,t)}function x(e,t){var r;return r=function(e,t){var r,n,s,o;for(n=e.length,s=0;n;)t(e[o=s+(r=n>>>1)])?n=r:(s=o+1,n-=r+1);return s}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},s={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},n={Break:o={},Skip:a={},Remove:i={}},u.prototype.replace=function(e){this.parent[this.key]=e},u.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)},p.prototype.path=function(){var e,t,r,n,s;function o(e,t){if(Array.isArray(t))for(r=0,n=t.length;r=0;)if(y=i[p=m[d]])if(Array.isArray(y)){for(x=y.length;(x-=1)>=0;)if(y[x]){if(h(l,m[d]))s=new c(y[x],[p,x],"Property",null);else{if(!f(y[x]))continue;s=new c(y[x],[p,x],null,null)}r.push(s)}}else f(y)&&r.push(new c(y,p,null,null))}}else if(s=n.pop(),u=this.__execute(t.leave,s),this.__state===o||u===o)return},p.prototype.replace=function(e,t){var r,n,s,l,p,d,x,m,y,g,v,A,E;function _(e){var t,n,s,o;if(e.ref.remove())for(n=e.ref.key,o=e.ref.parent,t=r.length;t--;)if((s=r[t]).ref&&s.ref.parent===o){if(s.ref.key=0;)if(g=s[E=y[x]])if(Array.isArray(g)){for(m=g.length;(m-=1)>=0;)if(g[m]){if(h(l,y[x]))d=new c(g[m],[E,m],"Property",new u(g,m));else{if(!f(g[m]))continue;d=new c(g[m],[E,m],null,new u(g,m))}r.push(d)}}else f(g)&&r.push(new c(g,E,null,new u(s,E)))}}else if(d=n.pop(),void 0!==(p=this.__execute(t.leave,d))&&p!==o&&p!==a&&p!==i&&d.ref.replace(p),this.__state!==i&&p!==i||_(d),this.__state===o||p===o)return A.root;return A.root},t.Syntax=r,t.traverse=d,t.replace=function(e,t){return(new p).replace(e,t)},t.attachComments=function(e,t,r){var s,o,a,i,u=[];if(!e.range)throw new Error("attachComments needs range information");if(!r.length){if(t.length){for(a=0,o=t.length;ae.range[0]);)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),u.splice(i,1)):i+=1;return i===u.length?n.Break:u[i].extendedRange[0]>e.range[1]?n.Skip:void 0}}),i=0,d(e,{leave:function(e){for(var t;ie.range[1]?n.Skip:void 0}}),e},t.VisitorKeys=s,t.VisitorOption=n,t.Controller=p,t.cloneEnvironment=function(){return e({})},t}(t)})),r=e((function(e){e.exports&&(e.exports=function(){function e(t,r,n,s){this.message=t,this.expected=r,this.found=n,this.location=s,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.buildMessage=function(e,t){var r={literal:function(e){return'"'+s(e.text)+'"'},class:function(e){var t,r="";for(t=0;t0){for(t=1,n=1;t<~+.]/,f=ye([" ","[","]",",","(",")",":","#","!","=",">","<","~","+","."],!0,!1),h=function(e){return e.join("")},d=me(">",!1),x=me("~",!1),m=me("+",!1),y=me(",",!1),g=me("!",!1),v=me("*",!1),A=me("#",!1),E=me("[",!1),_=me("]",!1),b=/^[>","<","!"],!1,!1),C=me("=",!1),w=function(e){return(e||"")+"="},P=/^[><]/,k=ye([">","<"],!1,!1),D=me(".",!1),I=function(e,t,r){return{type:"attribute",name:e,operator:t,value:r}},F=me('"',!1),j=/^[^\\"]/,T=ye(["\\",'"'],!0,!1),L=me("\\",!1),R={type:"any"},O=function(e,t){return e+t},B=function(e){return{type:"literal",value:(t=e.join(""),t.replace(/\\(.)/g,(function(e,t){switch(t){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";default:return t}})))};var t},M=me("'",!1),U=/^[^\\']/,V=ye(["\\","'"],!0,!1),q=/^[0-9]/,N=ye([["0","9"]],!1,!1),W=me("type(",!1),$=/^[^ )]/,G=ye([" ",")"],!0,!1),z=me(")",!1),K=/^[imsu]/,H=ye(["i","m","s","u"],!1,!1),Y=me("/",!1),J=/^[^\/]/,Q=ye(["/"],!0,!1),X=me(":not(",!1),Z=me(":matches(",!1),ee=me(":has(",!1),te=me(":first-child",!1),re=me(":last-child",!1),ne=me(":nth-child(",!1),se=me(":nth-last-child(",!1),oe=me(":",!1),ae=me("statement",!0),ie=me("expression",!0),le=me("declaration",!0),ue=me("function",!0),ce=me("pattern",!0),pe=0,fe=[{line:1,column:1}],he=0,de=[],xe={};if("startRule"in r){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=l[r.startRule]}function me(e,t){return{type:"literal",text:e,ignoreCase:t}}function ye(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function ge(e){var r,n=fe[e];if(n)return n;for(r=e-1;!fe[r];)r--;for(n={line:(n=fe[r]).line,column:n.column};rhe&&(he=pe,de=[]),de.push(e))}function Ee(){var e,t,r,n,s=30*pe+0,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,(t=_e())!==i&&(r=Ce())!==i&&_e()!==i?e=t=1===(n=r).length?n[0]:{type:"matches",selectors:n}:(pe=e,e=i),e===i&&(e=pe,(t=_e())!==i&&(t=void 0),e=t),xe[s]={nextPos:pe,result:e},e)}function _e(){var e,r,n=30*pe+1,s=xe[n];if(s)return pe=s.nextPos,s.result;for(e=[],32===t.charCodeAt(pe)?(r=" ",pe++):(r=i,Ae(c));r!==i;)e.push(r),32===t.charCodeAt(pe)?(r=" ",pe++):(r=i,Ae(c));return xe[n]={nextPos:pe,result:e},e}function be(){var e,r,n,s=30*pe+2,o=xe[s];if(o)return pe=o.nextPos,o.result;if(r=[],p.test(t.charAt(pe))?(n=t.charAt(pe),pe++):(n=i,Ae(f)),n!==i)for(;n!==i;)r.push(n),p.test(t.charAt(pe))?(n=t.charAt(pe),pe++):(n=i,Ae(f));else r=i;return r!==i&&(r=h(r)),e=r,xe[s]={nextPos:pe,result:e},e}function Se(){var e,r,n,s=30*pe+3,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,(r=_e())!==i?(62===t.charCodeAt(pe)?(n=">",pe++):(n=i,Ae(d)),n!==i&&_e()!==i?e=r="child":(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=_e())!==i?(126===t.charCodeAt(pe)?(n="~",pe++):(n=i,Ae(x)),n!==i&&_e()!==i?e=r="sibling":(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=_e())!==i?(43===t.charCodeAt(pe)?(n="+",pe++):(n=i,Ae(m)),n!==i&&_e()!==i?e=r="adjacent":(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,32===t.charCodeAt(pe)?(r=" ",pe++):(r=i,Ae(c)),r!==i&&(n=_e())!==i?e=r="descendant":(pe=e,e=i)))),xe[s]={nextPos:pe,result:e},e)}function Ce(){var e,r,n,s,o,a,l,u,c=30*pe+4,p=xe[c];if(p)return pe=p.nextPos,p.result;if(e=pe,(r=we())!==i){for(n=[],s=pe,(o=_e())!==i?(44===t.charCodeAt(pe)?(a=",",pe++):(a=i,Ae(y)),a!==i&&(l=_e())!==i&&(u=we())!==i?s=o=[o,a,l,u]:(pe=s,s=i)):(pe=s,s=i);s!==i;)n.push(s),s=pe,(o=_e())!==i?(44===t.charCodeAt(pe)?(a=",",pe++):(a=i,Ae(y)),a!==i&&(l=_e())!==i&&(u=we())!==i?s=o=[o,a,l,u]:(pe=s,s=i)):(pe=s,s=i);n!==i?e=r=[r].concat(n.map((function(e){return e[3]}))):(pe=e,e=i)}else pe=e,e=i;return xe[c]={nextPos:pe,result:e},e}function we(){var e,t,r,n,s,o,a,l=30*pe+5,u=xe[l];if(u)return pe=u.nextPos,u.result;if(e=pe,(t=Pe())!==i){for(r=[],n=pe,(s=Se())!==i&&(o=Pe())!==i?n=s=[s,o]:(pe=n,n=i);n!==i;)r.push(n),n=pe,(s=Se())!==i&&(o=Pe())!==i?n=s=[s,o]:(pe=n,n=i);r!==i?(a=t,e=t=r.reduce((function(e,t){return{type:t[0],left:e,right:t[1]}}),a)):(pe=e,e=i)}else pe=e,e=i;return xe[l]={nextPos:pe,result:e},e}function Pe(){var e,r,n,s,o=30*pe+6,a=xe[o];if(a)return pe=a.nextPos,a.result;if(e=pe,33===t.charCodeAt(pe)?(r="!",pe++):(r=i,Ae(g)),r===i&&(r=null),r!==i){if(n=[],(s=ke())!==i)for(;s!==i;)n.push(s),s=ke();else n=i;n!==i?e=r=function(e,t){const r=1===t.length?t[0]:{type:"compound",selectors:t};return e&&(r.subject=!0),r}(r,n):(pe=e,e=i)}else pe=e,e=i;return xe[o]={nextPos:pe,result:e},e}function ke(){var e,r=30*pe+7,n=xe[r];return n?(pe=n.nextPos,n.result):((e=function(){var e,r,n=30*pe+8,s=xe[n];return s?(pe=s.nextPos,s.result):(42===t.charCodeAt(pe)?(r="*",pe++):(r=i,Ae(v)),r!==i&&(r={type:"wildcard",value:r}),e=r,xe[n]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s=30*pe+9,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,35===t.charCodeAt(pe)?(r="#",pe++):(r=i,Ae(A)),r===i&&(r=null),r!==i&&(n=be())!==i?e=r={type:"identifier",value:n}:(pe=e,e=i),xe[s]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o=30*pe+10,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,91===t.charCodeAt(pe)?(r="[",pe++):(r=i,Ae(E)),r!==i&&_e()!==i&&(n=function(){var e,r,n,s,o=30*pe+14,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,(r=De())!==i&&_e()!==i&&(n=function(){var e,r,n,s=30*pe+12,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,33===t.charCodeAt(pe)?(r="!",pe++):(r=i,Ae(g)),r===i&&(r=null),r!==i?(61===t.charCodeAt(pe)?(n="=",pe++):(n=i,Ae(C)),n!==i?(r=w(r),e=r):(pe=e,e=i)):(pe=e,e=i),xe[s]={nextPos:pe,result:e},e)}())!==i&&_e()!==i?((s=function(){var e,r,n,s,o,a=30*pe+18,l=xe[a];if(l)return pe=l.nextPos,l.result;if(e=pe,"type("===t.substr(pe,5)?(r="type(",pe+=5):(r=i,Ae(W)),r!==i)if(_e()!==i){if(n=[],$.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(G)),s!==i)for(;s!==i;)n.push(s),$.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(G));else n=i;n!==i&&(s=_e())!==i?(41===t.charCodeAt(pe)?(o=")",pe++):(o=i,Ae(z)),o!==i?(r={type:"type",value:n.join("")},e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return xe[a]={nextPos:pe,result:e},e}())===i&&(s=function(){var e,r,n,s,o,a,l=30*pe+20,u=xe[l];if(u)return pe=u.nextPos,u.result;if(e=pe,47===t.charCodeAt(pe)?(r="/",pe++):(r=i,Ae(Y)),r!==i){if(n=[],J.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(Q)),s!==i)for(;s!==i;)n.push(s),J.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(Q));else n=i;n!==i?(47===t.charCodeAt(pe)?(s="/",pe++):(s=i,Ae(Y)),s!==i?((o=function(){var e,r,n=30*pe+19,s=xe[n];if(s)return pe=s.nextPos,s.result;if(e=[],K.test(t.charAt(pe))?(r=t.charAt(pe),pe++):(r=i,Ae(H)),r!==i)for(;r!==i;)e.push(r),K.test(t.charAt(pe))?(r=t.charAt(pe),pe++):(r=i,Ae(H));else e=i;return xe[n]={nextPos:pe,result:e},e}())===i&&(o=null),o!==i?(a=o,r={type:"regexp",value:new RegExp(n.join(""),a?a.join(""):"")},e=r):(pe=e,e=i)):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;return xe[l]={nextPos:pe,result:e},e}()),s!==i?(r=I(r,n,s),e=r):(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=De())!==i&&_e()!==i&&(n=function(){var e,r,n,s=30*pe+11,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,b.test(t.charAt(pe))?(r=t.charAt(pe),pe++):(r=i,Ae(S)),r===i&&(r=null),r!==i?(61===t.charCodeAt(pe)?(n="=",pe++):(n=i,Ae(C)),n!==i?(r=w(r),e=r):(pe=e,e=i)):(pe=e,e=i),e===i&&(P.test(t.charAt(pe))?(e=t.charAt(pe),pe++):(e=i,Ae(k))),xe[s]={nextPos:pe,result:e},e)}())!==i&&_e()!==i?((s=function(){var e,r,n,s,o,a,l=30*pe+15,u=xe[l];if(u)return pe=u.nextPos,u.result;if(e=pe,34===t.charCodeAt(pe)?(r='"',pe++):(r=i,Ae(F)),r!==i){for(n=[],j.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(T)),s===i&&(s=pe,92===t.charCodeAt(pe)?(o="\\",pe++):(o=i,Ae(L)),o!==i?(t.length>pe?(a=t.charAt(pe),pe++):(a=i,Ae(R)),a!==i?(o=O(o,a),s=o):(pe=s,s=i)):(pe=s,s=i));s!==i;)n.push(s),j.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(T)),s===i&&(s=pe,92===t.charCodeAt(pe)?(o="\\",pe++):(o=i,Ae(L)),o!==i?(t.length>pe?(a=t.charAt(pe),pe++):(a=i,Ae(R)),a!==i?(o=O(o,a),s=o):(pe=s,s=i)):(pe=s,s=i));n!==i?(34===t.charCodeAt(pe)?(s='"',pe++):(s=i,Ae(F)),s!==i?(r=B(n),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;if(e===i)if(e=pe,39===t.charCodeAt(pe)?(r="'",pe++):(r=i,Ae(M)),r!==i){for(n=[],U.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(V)),s===i&&(s=pe,92===t.charCodeAt(pe)?(o="\\",pe++):(o=i,Ae(L)),o!==i?(t.length>pe?(a=t.charAt(pe),pe++):(a=i,Ae(R)),a!==i?(o=O(o,a),s=o):(pe=s,s=i)):(pe=s,s=i));s!==i;)n.push(s),U.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(V)),s===i&&(s=pe,92===t.charCodeAt(pe)?(o="\\",pe++):(o=i,Ae(L)),o!==i?(t.length>pe?(a=t.charAt(pe),pe++):(a=i,Ae(R)),a!==i?(o=O(o,a),s=o):(pe=s,s=i)):(pe=s,s=i));n!==i?(39===t.charCodeAt(pe)?(s="'",pe++):(s=i,Ae(M)),s!==i?(r=B(n),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;return xe[l]={nextPos:pe,result:e},e}())===i&&(s=function(){var e,r,n,s,o=30*pe+16,a=xe[o];if(a)return pe=a.nextPos,a.result;for(e=pe,r=pe,n=[],q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));s!==i;)n.push(s),q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));if(n!==i?(46===t.charCodeAt(pe)?(s=".",pe++):(s=i,Ae(D)),s!==i?r=n=[n,s]:(pe=r,r=i)):(pe=r,r=i),r===i&&(r=null),r!==i){if(n=[],q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N)),s!==i)for(;s!==i;)n.push(s),q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));else n=i;n!==i?(r=function(e,t){const r=e?[].concat.apply([],e).join(""):"";return{type:"literal",value:parseFloat(r+t.join(""))}}(r,n),e=r):(pe=e,e=i)}else pe=e,e=i;return xe[o]={nextPos:pe,result:e},e}())===i&&(s=function(){var e,t,r=30*pe+17,n=xe[r];return n?(pe=n.nextPos,n.result):((t=be())!==i&&(t={type:"literal",value:t}),e=t,xe[r]={nextPos:pe,result:e},e)}()),s!==i?(r=I(r,n,s),e=r):(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=De())!==i&&(r={type:"attribute",name:r}),e=r)),xe[o]={nextPos:pe,result:e},e)}())!==i&&_e()!==i?(93===t.charCodeAt(pe)?(s="]",pe++):(s=i,Ae(_)),s!==i?e=r=n:(pe=e,e=i)):(pe=e,e=i),xe[o]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o,a,l,u,c=30*pe+21,p=xe[c];if(p)return pe=p.nextPos,p.result;if(e=pe,46===t.charCodeAt(pe)?(r=".",pe++):(r=i,Ae(D)),r!==i)if((n=be())!==i){for(s=[],o=pe,46===t.charCodeAt(pe)?(a=".",pe++):(a=i,Ae(D)),a!==i&&(l=be())!==i?o=a=[a,l]:(pe=o,o=i);o!==i;)s.push(o),o=pe,46===t.charCodeAt(pe)?(a=".",pe++):(a=i,Ae(D)),a!==i&&(l=be())!==i?o=a=[a,l]:(pe=o,o=i);s!==i?(u=n,r={type:"field",name:s.reduce((function(e,t){return e+t[0]+t[1]}),u)},e=r):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return xe[c]={nextPos:pe,result:e},e}())===i&&(e=function(){var e,r,n,s,o=30*pe+22,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,":not("===t.substr(pe,5)?(r=":not(",pe+=5):(r=i,Ae(X)),r!==i&&_e()!==i&&(n=Ce())!==i&&_e()!==i?(41===t.charCodeAt(pe)?(s=")",pe++):(s=i,Ae(z)),s!==i?e=r={type:"not",selectors:n}:(pe=e,e=i)):(pe=e,e=i),xe[o]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o=30*pe+23,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,":matches("===t.substr(pe,9)?(r=":matches(",pe+=9):(r=i,Ae(Z)),r!==i&&_e()!==i&&(n=Ce())!==i&&_e()!==i?(41===t.charCodeAt(pe)?(s=")",pe++):(s=i,Ae(z)),s!==i?e=r={type:"matches",selectors:n}:(pe=e,e=i)):(pe=e,e=i),xe[o]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o=30*pe+24,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,":has("===t.substr(pe,5)?(r=":has(",pe+=5):(r=i,Ae(ee)),r!==i&&_e()!==i&&(n=Ce())!==i&&_e()!==i?(41===t.charCodeAt(pe)?(s=")",pe++):(s=i,Ae(z)),s!==i?e=r={type:"has",selectors:n}:(pe=e,e=i)):(pe=e,e=i),xe[o]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n=30*pe+25,s=xe[n];return s?(pe=s.nextPos,s.result):(":first-child"===t.substr(pe,12)?(r=":first-child",pe+=12):(r=i,Ae(te)),r!==i&&(r=Ie(1)),e=r,xe[n]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n=30*pe+26,s=xe[n];return s?(pe=s.nextPos,s.result):(":last-child"===t.substr(pe,11)?(r=":last-child",pe+=11):(r=i,Ae(re)),r!==i&&(r=Fe(1)),e=r,xe[n]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o,a=30*pe+27,l=xe[a];if(l)return pe=l.nextPos,l.result;if(e=pe,":nth-child("===t.substr(pe,11)?(r=":nth-child(",pe+=11):(r=i,Ae(ne)),r!==i)if(_e()!==i){if(n=[],q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N)),s!==i)for(;s!==i;)n.push(s),q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));else n=i;n!==i&&(s=_e())!==i?(41===t.charCodeAt(pe)?(o=")",pe++):(o=i,Ae(z)),o!==i?(r=Ie(parseInt(n.join(""),10)),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return xe[a]={nextPos:pe,result:e},e}())===i&&(e=function(){var e,r,n,s,o,a=30*pe+28,l=xe[a];if(l)return pe=l.nextPos,l.result;if(e=pe,":nth-last-child("===t.substr(pe,16)?(r=":nth-last-child(",pe+=16):(r=i,Ae(se)),r!==i)if(_e()!==i){if(n=[],q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N)),s!==i)for(;s!==i;)n.push(s),q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));else n=i;n!==i&&(s=_e())!==i?(41===t.charCodeAt(pe)?(o=")",pe++):(o=i,Ae(z)),o!==i?(r=Fe(parseInt(n.join(""),10)),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return xe[a]={nextPos:pe,result:e},e}())===i&&(e=function(){var e,r,n,s=30*pe+29,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,58===t.charCodeAt(pe)?(r=":",pe++):(r=i,Ae(oe)),r!==i?("statement"===t.substr(pe,9).toLowerCase()?(n=t.substr(pe,9),pe+=9):(n=i,Ae(ae)),n===i&&("expression"===t.substr(pe,10).toLowerCase()?(n=t.substr(pe,10),pe+=10):(n=i,Ae(ie)),n===i&&("declaration"===t.substr(pe,11).toLowerCase()?(n=t.substr(pe,11),pe+=11):(n=i,Ae(le)),n===i&&("function"===t.substr(pe,8).toLowerCase()?(n=t.substr(pe,8),pe+=8):(n=i,Ae(ue)),n===i&&("pattern"===t.substr(pe,7).toLowerCase()?(n=t.substr(pe,7),pe+=7):(n=i,Ae(ce)))))),n!==i?e=r={type:"class",name:n}:(pe=e,e=i)):(pe=e,e=i),xe[s]={nextPos:pe,result:e},e)}()),xe[r]={nextPos:pe,result:e},e)}function De(){var e,r,n,s=30*pe+13,o=xe[s];if(o)return pe=o.nextPos,o.result;if(r=[],(n=be())===i&&(46===t.charCodeAt(pe)?(n=".",pe++):(n=i,Ae(D))),n!==i)for(;n!==i;)r.push(n),(n=be())===i&&(46===t.charCodeAt(pe)?(n=".",pe++):(n=i,Ae(D)));else r=i;return r!==i&&(r=h(r)),e=r,xe[s]={nextPos:pe,result:e},e}function Ie(e){return{type:"nth-child",index:{type:"literal",value:e}}}function Fe(e){return{type:"nth-last-child",index:{type:"literal",value:e}}}if((n=u())!==i&&pe===t.length)return n;throw n!==i&&pe":return t>r.value.value;case">=":return t>=r.value.value}throw new Error(`Unknown operator: ${r.operator}`)}case"sibling":return n(e,r.right,i)&&s(e,r.left,i,"LEFT_SIDE")||r.left.subject&&n(e,r.left,i)&&s(e,r.right,i,"RIGHT_SIDE");case"adjacent":return n(e,r.right,i)&&o(e,r.left,i,"LEFT_SIDE")||r.right.subject&&n(e,r.left,i)&&o(e,r.right,i,"RIGHT_SIDE");case"nth-child":return n(e,r.right,i)&&a(e,i,(function(){return r.index.value-1}));case"nth-last-child":return n(e,r.right,i)&&a(e,i,(function(e){return e-r.index.value}));case"class":switch(r.name.toLowerCase()){case"statement":if("Statement"===e.type.slice(-9))return!0;case"declaration":return"Declaration"===e.type.slice(-11);case"pattern":if("Pattern"===e.type.slice(-7))return!0;case"expression":return"Expression"===e.type.slice(-10)||"Literal"===e.type.slice(-7)||"Identifier"===e.type&&(0===i.length||"MetaProperty"!==i[0].type)||"MetaProperty"===e.type;case"function":return"FunctionDeclaration"===e.type||"FunctionExpression"===e.type||"ArrowFunctionExpression"===e.type}throw new Error(`Unknown class name: ${r.name}`)}throw new Error(`Unknown selector type: ${r.type}`)}function s(e,r,s,o){const[a]=s;if(!a)return!1;const i=t.VisitorKeys[a.type];for(let t=0,l=i.length;t0&&n(l[t-1],r,s))return!0;if("RIGHT_SIDE"===o&&t=0&&t===n(r.length))return!0}}return!1}function i(e,r){const s=[],o=[];if(!r)return o;const a=function e(t,r){if(null==t||"object"!=typeof t)return[];null==r&&(r=t);const n=t.subject?[r]:[];for(const[s,o]of Object.entries(t))n.push(...e(o,"left"===s?o:r));return n}(r);return t.traverse(e,{enter(e,t){if(null!=t&&s.unshift(t),n(e,r,s))if(a.length)for(let t=0,r=a.length;t
+ Copyright (C) 2012 Ariya Hidayat
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ /*jslint vars:false, bitwise:true*/
+ /*jshint indent:4*/
+ /*global exports:true*/
+ (function clone(exports) {
+
+ var Syntax,
+ VisitorOption,
+ VisitorKeys,
+ BREAK,
+ SKIP,
+ REMOVE;
+
+ function deepCopy(obj) {
+ var ret = {}, key, val;
+ for (key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ val = obj[key];
+ if (typeof val === 'object' && val !== null) {
+ ret[key] = deepCopy(val);
+ } else {
+ ret[key] = val;
+ }
+ }
+ }
+ return ret;
+ }
+
+ // based on LLVM libc++ upper_bound / lower_bound
+ // MIT License
+
+ function upperBound(array, func) {
+ var diff, len, i, current;
+
+ len = array.length;
+ i = 0;
+
+ while (len) {
+ diff = len >>> 1;
+ current = i + diff;
+ if (func(array[current])) {
+ len = diff;
+ } else {
+ i = current + 1;
+ len -= diff + 1;
+ }
+ }
+ return i;
+ }
+
+ Syntax = {
+ AssignmentExpression: 'AssignmentExpression',
+ AssignmentPattern: 'AssignmentPattern',
+ ArrayExpression: 'ArrayExpression',
+ ArrayPattern: 'ArrayPattern',
+ ArrowFunctionExpression: 'ArrowFunctionExpression',
+ AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
+ BlockStatement: 'BlockStatement',
+ BinaryExpression: 'BinaryExpression',
+ BreakStatement: 'BreakStatement',
+ CallExpression: 'CallExpression',
+ CatchClause: 'CatchClause',
+ ClassBody: 'ClassBody',
+ ClassDeclaration: 'ClassDeclaration',
+ ClassExpression: 'ClassExpression',
+ ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
+ ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
+ ConditionalExpression: 'ConditionalExpression',
+ ContinueStatement: 'ContinueStatement',
+ DebuggerStatement: 'DebuggerStatement',
+ DirectiveStatement: 'DirectiveStatement',
+ DoWhileStatement: 'DoWhileStatement',
+ EmptyStatement: 'EmptyStatement',
+ ExportAllDeclaration: 'ExportAllDeclaration',
+ ExportDefaultDeclaration: 'ExportDefaultDeclaration',
+ ExportNamedDeclaration: 'ExportNamedDeclaration',
+ ExportSpecifier: 'ExportSpecifier',
+ ExpressionStatement: 'ExpressionStatement',
+ ForStatement: 'ForStatement',
+ ForInStatement: 'ForInStatement',
+ ForOfStatement: 'ForOfStatement',
+ FunctionDeclaration: 'FunctionDeclaration',
+ FunctionExpression: 'FunctionExpression',
+ GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
+ Identifier: 'Identifier',
+ IfStatement: 'IfStatement',
+ ImportExpression: 'ImportExpression',
+ ImportDeclaration: 'ImportDeclaration',
+ ImportDefaultSpecifier: 'ImportDefaultSpecifier',
+ ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
+ ImportSpecifier: 'ImportSpecifier',
+ Literal: 'Literal',
+ LabeledStatement: 'LabeledStatement',
+ LogicalExpression: 'LogicalExpression',
+ MemberExpression: 'MemberExpression',
+ MetaProperty: 'MetaProperty',
+ MethodDefinition: 'MethodDefinition',
+ ModuleSpecifier: 'ModuleSpecifier',
+ NewExpression: 'NewExpression',
+ ObjectExpression: 'ObjectExpression',
+ ObjectPattern: 'ObjectPattern',
+ Program: 'Program',
+ Property: 'Property',
+ RestElement: 'RestElement',
+ ReturnStatement: 'ReturnStatement',
+ SequenceExpression: 'SequenceExpression',
+ SpreadElement: 'SpreadElement',
+ Super: 'Super',
+ SwitchStatement: 'SwitchStatement',
+ SwitchCase: 'SwitchCase',
+ TaggedTemplateExpression: 'TaggedTemplateExpression',
+ TemplateElement: 'TemplateElement',
+ TemplateLiteral: 'TemplateLiteral',
+ ThisExpression: 'ThisExpression',
+ ThrowStatement: 'ThrowStatement',
+ TryStatement: 'TryStatement',
+ UnaryExpression: 'UnaryExpression',
+ UpdateExpression: 'UpdateExpression',
+ VariableDeclaration: 'VariableDeclaration',
+ VariableDeclarator: 'VariableDeclarator',
+ WhileStatement: 'WhileStatement',
+ WithStatement: 'WithStatement',
+ YieldExpression: 'YieldExpression'
+ };
+
+ VisitorKeys = {
+ AssignmentExpression: ['left', 'right'],
+ AssignmentPattern: ['left', 'right'],
+ ArrayExpression: ['elements'],
+ ArrayPattern: ['elements'],
+ ArrowFunctionExpression: ['params', 'body'],
+ AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
+ BlockStatement: ['body'],
+ BinaryExpression: ['left', 'right'],
+ BreakStatement: ['label'],
+ CallExpression: ['callee', 'arguments'],
+ CatchClause: ['param', 'body'],
+ ClassBody: ['body'],
+ ClassDeclaration: ['id', 'superClass', 'body'],
+ ClassExpression: ['id', 'superClass', 'body'],
+ ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
+ ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
+ ConditionalExpression: ['test', 'consequent', 'alternate'],
+ ContinueStatement: ['label'],
+ DebuggerStatement: [],
+ DirectiveStatement: [],
+ DoWhileStatement: ['body', 'test'],
+ EmptyStatement: [],
+ ExportAllDeclaration: ['source'],
+ ExportDefaultDeclaration: ['declaration'],
+ ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
+ ExportSpecifier: ['exported', 'local'],
+ ExpressionStatement: ['expression'],
+ ForStatement: ['init', 'test', 'update', 'body'],
+ ForInStatement: ['left', 'right', 'body'],
+ ForOfStatement: ['left', 'right', 'body'],
+ FunctionDeclaration: ['id', 'params', 'body'],
+ FunctionExpression: ['id', 'params', 'body'],
+ GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
+ Identifier: [],
+ IfStatement: ['test', 'consequent', 'alternate'],
+ ImportExpression: ['source'],
+ ImportDeclaration: ['specifiers', 'source'],
+ ImportDefaultSpecifier: ['local'],
+ ImportNamespaceSpecifier: ['local'],
+ ImportSpecifier: ['imported', 'local'],
+ Literal: [],
+ LabeledStatement: ['label', 'body'],
+ LogicalExpression: ['left', 'right'],
+ MemberExpression: ['object', 'property'],
+ MetaProperty: ['meta', 'property'],
+ MethodDefinition: ['key', 'value'],
+ ModuleSpecifier: [],
+ NewExpression: ['callee', 'arguments'],
+ ObjectExpression: ['properties'],
+ ObjectPattern: ['properties'],
+ Program: ['body'],
+ Property: ['key', 'value'],
+ RestElement: [ 'argument' ],
+ ReturnStatement: ['argument'],
+ SequenceExpression: ['expressions'],
+ SpreadElement: ['argument'],
+ Super: [],
+ SwitchStatement: ['discriminant', 'cases'],
+ SwitchCase: ['test', 'consequent'],
+ TaggedTemplateExpression: ['tag', 'quasi'],
+ TemplateElement: [],
+ TemplateLiteral: ['quasis', 'expressions'],
+ ThisExpression: [],
+ ThrowStatement: ['argument'],
+ TryStatement: ['block', 'handler', 'finalizer'],
+ UnaryExpression: ['argument'],
+ UpdateExpression: ['argument'],
+ VariableDeclaration: ['declarations'],
+ VariableDeclarator: ['id', 'init'],
+ WhileStatement: ['test', 'body'],
+ WithStatement: ['object', 'body'],
+ YieldExpression: ['argument']
+ };
+
+ // unique id
+ BREAK = {};
+ SKIP = {};
+ REMOVE = {};
+
+ VisitorOption = {
+ Break: BREAK,
+ Skip: SKIP,
+ Remove: REMOVE
+ };
+
+ function Reference(parent, key) {
+ this.parent = parent;
+ this.key = key;
+ }
+
+ Reference.prototype.replace = function replace(node) {
+ this.parent[this.key] = node;
+ };
+
+ Reference.prototype.remove = function remove() {
+ if (Array.isArray(this.parent)) {
+ this.parent.splice(this.key, 1);
+ return true;
+ } else {
+ this.replace(null);
+ return false;
+ }
+ };
+
+ function Element(node, path, wrap, ref) {
+ this.node = node;
+ this.path = path;
+ this.wrap = wrap;
+ this.ref = ref;
+ }
+
+ function Controller() { }
+
+ // API:
+ // return property path array from root to current node
+ Controller.prototype.path = function path() {
+ var i, iz, j, jz, result, element;
+
+ function addToPath(result, path) {
+ if (Array.isArray(path)) {
+ for (j = 0, jz = path.length; j < jz; ++j) {
+ result.push(path[j]);
+ }
+ } else {
+ result.push(path);
+ }
+ }
+
+ // root node
+ if (!this.__current.path) {
+ return null;
+ }
+
+ // first node is sentinel, second node is root element
+ result = [];
+ for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
+ element = this.__leavelist[i];
+ addToPath(result, element.path);
+ }
+ addToPath(result, this.__current.path);
+ return result;
+ };
+
+ // API:
+ // return type of current node
+ Controller.prototype.type = function () {
+ var node = this.current();
+ return node.type || this.__current.wrap;
+ };
+
+ // API:
+ // return array of parent elements
+ Controller.prototype.parents = function parents() {
+ var i, iz, result;
+
+ // first node is sentinel
+ result = [];
+ for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
+ result.push(this.__leavelist[i].node);
+ }
+
+ return result;
+ };
+
+ // API:
+ // return current node
+ Controller.prototype.current = function current() {
+ return this.__current.node;
+ };
+
+ Controller.prototype.__execute = function __execute(callback, element) {
+ var previous, result;
+
+ result = undefined;
+
+ previous = this.__current;
+ this.__current = element;
+ this.__state = null;
+ if (callback) {
+ result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
+ }
+ this.__current = previous;
+
+ return result;
+ };
+
+ // API:
+ // notify control skip / break
+ Controller.prototype.notify = function notify(flag) {
+ this.__state = flag;
+ };
+
+ // API:
+ // skip child nodes of current node
+ Controller.prototype.skip = function () {
+ this.notify(SKIP);
+ };
+
+ // API:
+ // break traversals
+ Controller.prototype['break'] = function () {
+ this.notify(BREAK);
+ };
+
+ // API:
+ // remove node
+ Controller.prototype.remove = function () {
+ this.notify(REMOVE);
+ };
+
+ Controller.prototype.__initialize = function(root, visitor) {
+ this.visitor = visitor;
+ this.root = root;
+ this.__worklist = [];
+ this.__leavelist = [];
+ this.__current = null;
+ this.__state = null;
+ this.__fallback = null;
+ if (visitor.fallback === 'iteration') {
+ this.__fallback = Object.keys;
+ } else if (typeof visitor.fallback === 'function') {
+ this.__fallback = visitor.fallback;
+ }
+
+ this.__keys = VisitorKeys;
+ if (visitor.keys) {
+ this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
+ }
+ };
+
+ function isNode(node) {
+ if (node == null) {
+ return false;
+ }
+ return typeof node === 'object' && typeof node.type === 'string';
+ }
+
+ function isProperty(nodeType, key) {
+ return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
+ }
+
+ Controller.prototype.traverse = function traverse(root, visitor) {
+ var worklist,
+ leavelist,
+ element,
+ node,
+ nodeType,
+ ret,
+ key,
+ current,
+ current2,
+ candidates,
+ candidate,
+ sentinel;
+
+ this.__initialize(root, visitor);
+
+ sentinel = {};
+
+ // reference
+ worklist = this.__worklist;
+ leavelist = this.__leavelist;
+
+ // initialize
+ worklist.push(new Element(root, null, null, null));
+ leavelist.push(new Element(null, null, null, null));
+
+ while (worklist.length) {
+ element = worklist.pop();
+
+ if (element === sentinel) {
+ element = leavelist.pop();
+
+ ret = this.__execute(visitor.leave, element);
+
+ if (this.__state === BREAK || ret === BREAK) {
+ return;
+ }
+ continue;
+ }
+
+ if (element.node) {
+
+ ret = this.__execute(visitor.enter, element);
+
+ if (this.__state === BREAK || ret === BREAK) {
+ return;
+ }
+
+ worklist.push(sentinel);
+ leavelist.push(element);
+
+ if (this.__state === SKIP || ret === SKIP) {
+ continue;
+ }
+
+ node = element.node;
+ nodeType = node.type || element.wrap;
+ candidates = this.__keys[nodeType];
+ if (!candidates) {
+ if (this.__fallback) {
+ candidates = this.__fallback(node);
+ } else {
+ throw new Error('Unknown node type ' + nodeType + '.');
+ }
+ }
+
+ current = candidates.length;
+ while ((current -= 1) >= 0) {
+ key = candidates[current];
+ candidate = node[key];
+ if (!candidate) {
+ continue;
+ }
+
+ if (Array.isArray(candidate)) {
+ current2 = candidate.length;
+ while ((current2 -= 1) >= 0) {
+ if (!candidate[current2]) {
+ continue;
+ }
+ if (isProperty(nodeType, candidates[current])) {
+ element = new Element(candidate[current2], [key, current2], 'Property', null);
+ } else if (isNode(candidate[current2])) {
+ element = new Element(candidate[current2], [key, current2], null, null);
+ } else {
+ continue;
+ }
+ worklist.push(element);
+ }
+ } else if (isNode(candidate)) {
+ worklist.push(new Element(candidate, key, null, null));
+ }
+ }
+ }
+ }
+ };
+
+ Controller.prototype.replace = function replace(root, visitor) {
+ var worklist,
+ leavelist,
+ node,
+ nodeType,
+ target,
+ element,
+ current,
+ current2,
+ candidates,
+ candidate,
+ sentinel,
+ outer,
+ key;
+
+ function removeElem(element) {
+ var i,
+ key,
+ nextElem,
+ parent;
+
+ if (element.ref.remove()) {
+ // When the reference is an element of an array.
+ key = element.ref.key;
+ parent = element.ref.parent;
+
+ // If removed from array, then decrease following items' keys.
+ i = worklist.length;
+ while (i--) {
+ nextElem = worklist[i];
+ if (nextElem.ref && nextElem.ref.parent === parent) {
+ if (nextElem.ref.key < key) {
+ break;
+ }
+ --nextElem.ref.key;
+ }
+ }
+ }
+ }
+
+ this.__initialize(root, visitor);
+
+ sentinel = {};
+
+ // reference
+ worklist = this.__worklist;
+ leavelist = this.__leavelist;
+
+ // initialize
+ outer = {
+ root: root
+ };
+ element = new Element(root, null, null, new Reference(outer, 'root'));
+ worklist.push(element);
+ leavelist.push(element);
+
+ while (worklist.length) {
+ element = worklist.pop();
+
+ if (element === sentinel) {
+ element = leavelist.pop();
+
+ target = this.__execute(visitor.leave, element);
+
+ // node may be replaced with null,
+ // so distinguish between undefined and null in this place
+ if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
+ // replace
+ element.ref.replace(target);
+ }
+
+ if (this.__state === REMOVE || target === REMOVE) {
+ removeElem(element);
+ }
+
+ if (this.__state === BREAK || target === BREAK) {
+ return outer.root;
+ }
+ continue;
+ }
+
+ target = this.__execute(visitor.enter, element);
+
+ // node may be replaced with null,
+ // so distinguish between undefined and null in this place
+ if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
+ // replace
+ element.ref.replace(target);
+ element.node = target;
+ }
+
+ if (this.__state === REMOVE || target === REMOVE) {
+ removeElem(element);
+ element.node = null;
+ }
+
+ if (this.__state === BREAK || target === BREAK) {
+ return outer.root;
+ }
+
+ // node may be null
+ node = element.node;
+ if (!node) {
+ continue;
+ }
+
+ worklist.push(sentinel);
+ leavelist.push(element);
+
+ if (this.__state === SKIP || target === SKIP) {
+ continue;
+ }
+
+ nodeType = node.type || element.wrap;
+ candidates = this.__keys[nodeType];
+ if (!candidates) {
+ if (this.__fallback) {
+ candidates = this.__fallback(node);
+ } else {
+ throw new Error('Unknown node type ' + nodeType + '.');
+ }
+ }
+
+ current = candidates.length;
+ while ((current -= 1) >= 0) {
+ key = candidates[current];
+ candidate = node[key];
+ if (!candidate) {
+ continue;
+ }
+
+ if (Array.isArray(candidate)) {
+ current2 = candidate.length;
+ while ((current2 -= 1) >= 0) {
+ if (!candidate[current2]) {
+ continue;
+ }
+ if (isProperty(nodeType, candidates[current])) {
+ element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
+ } else if (isNode(candidate[current2])) {
+ element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
+ } else {
+ continue;
+ }
+ worklist.push(element);
+ }
+ } else if (isNode(candidate)) {
+ worklist.push(new Element(candidate, key, null, new Reference(node, key)));
+ }
+ }
+ }
+
+ return outer.root;
+ };
+
+ function traverse(root, visitor) {
+ var controller = new Controller();
+ return controller.traverse(root, visitor);
+ }
+
+ function replace(root, visitor) {
+ var controller = new Controller();
+ return controller.replace(root, visitor);
+ }
+
+ function extendCommentRange(comment, tokens) {
+ var target;
+
+ target = upperBound(tokens, function search(token) {
+ return token.range[0] > comment.range[0];
+ });
+
+ comment.extendedRange = [comment.range[0], comment.range[1]];
+
+ if (target !== tokens.length) {
+ comment.extendedRange[1] = tokens[target].range[0];
+ }
+
+ target -= 1;
+ if (target >= 0) {
+ comment.extendedRange[0] = tokens[target].range[1];
+ }
+
+ return comment;
+ }
+
+ function attachComments(tree, providedComments, tokens) {
+ // At first, we should calculate extended comment ranges.
+ var comments = [], comment, len, i, cursor;
+
+ if (!tree.range) {
+ throw new Error('attachComments needs range information');
+ }
+
+ // tokens array is empty, we attach comments to tree as 'leadingComments'
+ if (!tokens.length) {
+ if (providedComments.length) {
+ for (i = 0, len = providedComments.length; i < len; i += 1) {
+ comment = deepCopy(providedComments[i]);
+ comment.extendedRange = [0, tree.range[0]];
+ comments.push(comment);
+ }
+ tree.leadingComments = comments;
+ }
+ return tree;
+ }
+
+ for (i = 0, len = providedComments.length; i < len; i += 1) {
+ comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
+ }
+
+ // This is based on John Freeman's implementation.
+ cursor = 0;
+ traverse(tree, {
+ enter: function (node) {
+ var comment;
+
+ while (cursor < comments.length) {
+ comment = comments[cursor];
+ if (comment.extendedRange[1] > node.range[0]) {
+ break;
+ }
+
+ if (comment.extendedRange[1] === node.range[0]) {
+ if (!node.leadingComments) {
+ node.leadingComments = [];
+ }
+ node.leadingComments.push(comment);
+ comments.splice(cursor, 1);
+ } else {
+ cursor += 1;
+ }
+ }
+
+ // already out of owned node
+ if (cursor === comments.length) {
+ return VisitorOption.Break;
+ }
+
+ if (comments[cursor].extendedRange[0] > node.range[1]) {
+ return VisitorOption.Skip;
+ }
+ }
+ });
+
+ cursor = 0;
+ traverse(tree, {
+ leave: function (node) {
+ var comment;
+
+ while (cursor < comments.length) {
+ comment = comments[cursor];
+ if (node.range[1] < comment.extendedRange[0]) {
+ break;
+ }
+
+ if (node.range[1] === comment.extendedRange[0]) {
+ if (!node.trailingComments) {
+ node.trailingComments = [];
+ }
+ node.trailingComments.push(comment);
+ comments.splice(cursor, 1);
+ } else {
+ cursor += 1;
+ }
+ }
+
+ // already out of owned node
+ if (cursor === comments.length) {
+ return VisitorOption.Break;
+ }
+
+ if (comments[cursor].extendedRange[0] > node.range[1]) {
+ return VisitorOption.Skip;
+ }
+ }
+ });
+
+ return tree;
+ }
+
+ exports.Syntax = Syntax;
+ exports.traverse = traverse;
+ exports.replace = replace;
+ exports.attachComments = attachComments;
+ exports.VisitorKeys = VisitorKeys;
+ exports.VisitorOption = VisitorOption;
+ exports.Controller = Controller;
+ exports.cloneEnvironment = function () { return clone({}); };
+
+ return exports;
+ }(exports));
+ /* vim: set sw=4 ts=4 et tw=80 : */
+ });
+
+ var parser = createCommonjsModule(function (module) {
+ /*
+ * Generated by PEG.js 0.10.0.
+ *
+ * http://pegjs.org/
+ */
+ (function(root, factory) {
+ if ( module.exports) {
+ module.exports = factory();
+ }
+ })(commonjsGlobal, function() {
+
+ 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(ss) {
+ return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss };
+ },
+ peg$c1 = function() { return void 0; },
+ peg$c2 = " ",
+ peg$c3 = peg$literalExpectation(" ", false),
+ peg$c4 = /^[^ [\],():#!=><~+.]/,
+ peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false),
+ peg$c6 = function(i) { return i.join(''); },
+ peg$c7 = ">",
+ peg$c8 = peg$literalExpectation(">", false),
+ peg$c9 = function() { return 'child'; },
+ peg$c10 = "~",
+ peg$c11 = peg$literalExpectation("~", false),
+ peg$c12 = function() { return 'sibling'; },
+ peg$c13 = "+",
+ peg$c14 = peg$literalExpectation("+", false),
+ peg$c15 = function() { return 'adjacent'; },
+ peg$c16 = function() { return 'descendant'; },
+ peg$c17 = ",",
+ peg$c18 = peg$literalExpectation(",", false),
+ peg$c19 = function(s, ss) {
+ return [s].concat(ss.map(function (s) { return s[3]; }));
+ },
+ peg$c20 = function(a, ops) {
+ return ops.reduce(function (memo, rhs) {
+ return { type: rhs[0], left: memo, right: rhs[1] };
+ }, a);
+ },
+ peg$c21 = "!",
+ peg$c22 = peg$literalExpectation("!", false),
+ peg$c23 = function(subject, as) {
+ const b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
+ if(subject) b.subject = true;
+ return b;
+ },
+ peg$c24 = "*",
+ peg$c25 = peg$literalExpectation("*", false),
+ peg$c26 = function(a) { return { type: 'wildcard', value: a }; },
+ peg$c27 = "#",
+ peg$c28 = peg$literalExpectation("#", false),
+ peg$c29 = function(i) { return { type: 'identifier', value: i }; },
+ peg$c30 = "[",
+ peg$c31 = peg$literalExpectation("[", false),
+ peg$c32 = "]",
+ peg$c33 = peg$literalExpectation("]", false),
+ peg$c34 = function(v) { return v; },
+ peg$c35 = /^[>", "<", "!"], false, false),
+ peg$c37 = "=",
+ peg$c38 = peg$literalExpectation("=", false),
+ peg$c39 = function(a) { return (a || '') + '='; },
+ peg$c40 = /^[><]/,
+ peg$c41 = peg$classExpectation([">", "<"], false, false),
+ peg$c42 = ".",
+ peg$c43 = peg$literalExpectation(".", false),
+ peg$c44 = function(name, op, value) {
+ return { type: 'attribute', name: name, operator: op, value: value };
+ },
+ peg$c45 = function(name) { return { type: 'attribute', name: name }; },
+ peg$c46 = "\"",
+ peg$c47 = peg$literalExpectation("\"", false),
+ peg$c48 = /^[^\\"]/,
+ peg$c49 = peg$classExpectation(["\\", "\""], true, false),
+ peg$c50 = "\\",
+ peg$c51 = peg$literalExpectation("\\", false),
+ peg$c52 = peg$anyExpectation(),
+ peg$c53 = function(a, b) { return a + b; },
+ peg$c54 = function(d) {
+ return { type: 'literal', value: strUnescape(d.join('')) };
+ },
+ peg$c55 = "'",
+ peg$c56 = peg$literalExpectation("'", false),
+ peg$c57 = /^[^\\']/,
+ peg$c58 = peg$classExpectation(["\\", "'"], true, false),
+ peg$c59 = /^[0-9]/,
+ peg$c60 = peg$classExpectation([["0", "9"]], false, false),
+ peg$c61 = function(a, b) {
+ // Can use `a.flat().join('')` once supported
+ const leadingDecimals = a ? [].concat.apply([], a).join('') : '';
+ return { type: 'literal', value: parseFloat(leadingDecimals + b.join('')) };
+ },
+ peg$c62 = function(i) { return { type: 'literal', value: i }; },
+ peg$c63 = "type(",
+ peg$c64 = peg$literalExpectation("type(", false),
+ peg$c65 = /^[^ )]/,
+ peg$c66 = peg$classExpectation([" ", ")"], true, false),
+ peg$c67 = ")",
+ peg$c68 = peg$literalExpectation(")", false),
+ peg$c69 = function(t) { return { type: 'type', value: t.join('') }; },
+ peg$c70 = /^[imsu]/,
+ peg$c71 = peg$classExpectation(["i", "m", "s", "u"], false, false),
+ peg$c72 = "/",
+ peg$c73 = peg$literalExpectation("/", false),
+ peg$c74 = /^[^\/]/,
+ peg$c75 = peg$classExpectation(["/"], true, false),
+ peg$c76 = function(d, flgs) { return {
+ type: 'regexp', value: new RegExp(d.join(''), flgs ? flgs.join('') : '') };
+ },
+ peg$c77 = function(i, is) {
+ return { type: 'field', name: is.reduce(function(memo, p){ return memo + p[0] + p[1]; }, i)};
+ },
+ peg$c78 = ":not(",
+ peg$c79 = peg$literalExpectation(":not(", false),
+ peg$c80 = function(ss) { return { type: 'not', selectors: ss }; },
+ peg$c81 = ":matches(",
+ peg$c82 = peg$literalExpectation(":matches(", false),
+ peg$c83 = function(ss) { return { type: 'matches', selectors: ss }; },
+ peg$c84 = ":has(",
+ peg$c85 = peg$literalExpectation(":has(", false),
+ peg$c86 = function(ss) { return { type: 'has', selectors: ss }; },
+ peg$c87 = ":first-child",
+ peg$c88 = peg$literalExpectation(":first-child", false),
+ peg$c89 = function() { return nth(1); },
+ peg$c90 = ":last-child",
+ peg$c91 = peg$literalExpectation(":last-child", false),
+ peg$c92 = function() { return nthLast(1); },
+ peg$c93 = ":nth-child(",
+ peg$c94 = peg$literalExpectation(":nth-child(", false),
+ peg$c95 = function(n) { return nth(parseInt(n.join(''), 10)); },
+ peg$c96 = ":nth-last-child(",
+ peg$c97 = peg$literalExpectation(":nth-last-child(", false),
+ peg$c98 = function(n) { return nthLast(parseInt(n.join(''), 10)); },
+ peg$c99 = ":",
+ peg$c100 = peg$literalExpectation(":", false),
+ peg$c101 = "statement",
+ peg$c102 = peg$literalExpectation("statement", true),
+ peg$c103 = "expression",
+ peg$c104 = peg$literalExpectation("expression", true),
+ peg$c105 = "declaration",
+ peg$c106 = peg$literalExpectation("declaration", true),
+ peg$c107 = "function",
+ peg$c108 = peg$literalExpectation("function", true),
+ peg$c109 = "pattern",
+ peg$c110 = peg$literalExpectation("pattern", true),
+ peg$c111 = function(c) {
+ return { type: 'class', name: c };
+ },
+
+ peg$currPos = 0,
+ peg$posDetailsCache = [{ line: 1, column: 1 }],
+ peg$maxFailPos = 0,
+ peg$maxFailExpected = [],
+ peg$resultsCache = {},
+
+ 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 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$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$buildStructuredError(expected, found, location) {
+ return new peg$SyntaxError(
+ peg$SyntaxError.buildMessage(expected, found),
+ expected,
+ found,
+ location
+ );
+ }
+
+ function peg$parsestart() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 0,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseselectors();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c0(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c1();
+ }
+ s0 = s1;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parse_() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 1,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = [];
+ if (input.charCodeAt(peg$currPos) === 32) {
+ s1 = peg$c2;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c3); }
+ }
+ while (s1 !== peg$FAILED) {
+ s0.push(s1);
+ if (input.charCodeAt(peg$currPos) === 32) {
+ s1 = peg$c2;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c3); }
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseidentifierName() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 2,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = [];
+ if (peg$c4.test(input.charAt(peg$currPos))) {
+ s2 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c5); }
+ }
+ if (s2 !== peg$FAILED) {
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ if (peg$c4.test(input.charAt(peg$currPos))) {
+ s2 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c5); }
+ }
+ }
+ } else {
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c6(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsebinaryOp() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 3,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 62) {
+ s2 = peg$c7;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c8); }
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c9();
+ 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$parse_();
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 126) {
+ s2 = peg$c10;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c11); }
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c12();
+ 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$parse_();
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 43) {
+ s2 = peg$c13;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c14); }
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c15();
+ 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;
+ if (input.charCodeAt(peg$currPos) === 32) {
+ s1 = peg$c2;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c3); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c16();
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ }
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseselectors() {
+ var s0, s1, s2, s3, s4, s5, s6, s7;
+
+ var key = peg$currPos * 30 + 4,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parseselector();
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$currPos;
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 44) {
+ s5 = peg$c17;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c18); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parse_();
+ if (s6 !== peg$FAILED) {
+ s7 = peg$parseselector();
+ if (s7 !== peg$FAILED) {
+ s4 = [s4, s5, s6, s7];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$currPos;
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 44) {
+ s5 = peg$c17;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c18); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parse_();
+ if (s6 !== peg$FAILED) {
+ s7 = peg$parseselector();
+ if (s7 !== peg$FAILED) {
+ s4 = [s4, s5, s6, s7];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c19(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseselector() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 5,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parsesequence();
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$currPos;
+ s4 = peg$parsebinaryOp();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsesequence();
+ if (s5 !== peg$FAILED) {
+ s4 = [s4, s5];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$currPos;
+ s4 = peg$parsebinaryOp();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsesequence();
+ if (s5 !== peg$FAILED) {
+ s4 = [s4, s5];
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c20(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsesequence() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 6,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 33) {
+ s1 = peg$c21;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c22); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$parseatom();
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$parseatom();
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c23(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseatom() {
+ var s0;
+
+ var key = peg$currPos * 30 + 7,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$parsewildcard();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseidentifier();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseattr();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsefield();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsenegation();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsematches();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsehas();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsefirstChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parselastChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsenthChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsenthLastChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseclass();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsewildcard() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 8,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 42) {
+ s1 = peg$c24;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c25); }
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c26(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseidentifier() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 9,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 35) {
+ s1 = peg$c27;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c28); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseidentifierName();
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c29(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattr() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 10,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 91) {
+ s1 = peg$c30;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c31); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseattrValue();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 93) {
+ s5 = peg$c32;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c33); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c34(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrOps() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 11,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (peg$c35.test(input.charAt(peg$currPos))) {
+ s1 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c36); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 61) {
+ s2 = peg$c37;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c38); }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c39(s1);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ if (peg$c40.test(input.charAt(peg$currPos))) {
+ s0 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s0 = peg$FAILED;
+ { peg$fail(peg$c41); }
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrEqOps() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 12,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 33) {
+ s1 = peg$c21;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c22); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 61) {
+ s2 = peg$c37;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c38); }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c39(s1);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrName() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 13,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = [];
+ s2 = peg$parseidentifierName();
+ if (s2 === peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s2 = peg$c42;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ s2 = peg$parseidentifierName();
+ if (s2 === peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s2 = peg$c42;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ }
+ }
+ } else {
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c6(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrValue() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 14,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parseattrName();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseattrEqOps();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsetype();
+ if (s5 === peg$FAILED) {
+ s5 = peg$parseregex();
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c44(s1, s3, s5);
+ 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$parseattrName();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseattrOps();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsestring();
+ if (s5 === peg$FAILED) {
+ s5 = peg$parsenumber();
+ if (s5 === peg$FAILED) {
+ s5 = peg$parsepath();
+ }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c44(s1, s3, s5);
+ 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$parseattrName();
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c45(s1);
+ }
+ s0 = s1;
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsestring() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 15,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 34) {
+ s1 = peg$c46;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c47); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c48.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c49); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c51); }
+ }
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c52); }
+ }
+ if (s5 !== peg$FAILED) {
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c48.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c49); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c51); }
+ }
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c52); }
+ }
+ if (s5 !== peg$FAILED) {
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 34) {
+ s3 = peg$c46;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c47); }
+ }
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c54(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;
+ if (input.charCodeAt(peg$currPos) === 39) {
+ s1 = peg$c55;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c56); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c57.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c58); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c51); }
+ }
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c52); }
+ }
+ if (s5 !== peg$FAILED) {
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c57.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c58); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c51); }
+ }
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c52); }
+ }
+ if (s5 !== peg$FAILED) {
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 39) {
+ s3 = peg$c55;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c56); }
+ }
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c54(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenumber() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 16,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$currPos;
+ s2 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s3 = peg$c42;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ if (s3 !== peg$FAILED) {
+ s2 = [s2, s3];
+ s1 = s2;
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c61(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsepath() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 17,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parseidentifierName();
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c62(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsetype() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 18,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 5) === peg$c63) {
+ s1 = peg$c63;
+ peg$currPos += 5;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c64); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ if (peg$c65.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c66); }
+ }
+ if (s4 !== peg$FAILED) {
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ if (peg$c65.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c66); }
+ }
+ }
+ } else {
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c69(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseflags() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 19,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = [];
+ if (peg$c70.test(input.charAt(peg$currPos))) {
+ s1 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c71); }
+ }
+ if (s1 !== peg$FAILED) {
+ while (s1 !== peg$FAILED) {
+ s0.push(s1);
+ if (peg$c70.test(input.charAt(peg$currPos))) {
+ s1 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c71); }
+ }
+ }
+ } else {
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseregex() {
+ var s0, s1, s2, s3, s4;
+
+ var key = peg$currPos * 30 + 20,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 47) {
+ s1 = peg$c72;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c73); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c74.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c75); }
+ }
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c74.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c75); }
+ }
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 47) {
+ s3 = peg$c72;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ { peg$fail(peg$c73); }
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseflags();
+ if (s4 === peg$FAILED) {
+ s4 = null;
+ }
+ if (s4 !== peg$FAILED) {
+ s1 = peg$c76(s2, 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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsefield() {
+ var s0, s1, s2, s3, s4, s5, s6;
+
+ var key = peg$currPos * 30 + 21,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s1 = peg$c42;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseidentifierName();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ s4 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s5 = peg$c42;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parseidentifierName();
+ if (s6 !== peg$FAILED) {
+ s5 = [s5, s6];
+ s4 = s5;
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ s4 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s5 = peg$c42;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c43); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parseidentifierName();
+ if (s6 !== peg$FAILED) {
+ s5 = [s5, s6];
+ s4 = s5;
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ }
+ if (s3 !== peg$FAILED) {
+ s1 = peg$c77(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenegation() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 22,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 5) === peg$c78) {
+ s1 = peg$c78;
+ peg$currPos += 5;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c79); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseselectors();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c80(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsematches() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 23,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 9) === peg$c81) {
+ s1 = peg$c81;
+ peg$currPos += 9;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c82); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseselectors();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c83(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsehas() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 24,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 5) === peg$c84) {
+ s1 = peg$c84;
+ peg$currPos += 5;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c85); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseselectors();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c86(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsefirstChild() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 25,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 12) === peg$c87) {
+ s1 = peg$c87;
+ peg$currPos += 12;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c88); }
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c89();
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parselastChild() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 26,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 11) === peg$c90) {
+ s1 = peg$c90;
+ peg$currPos += 11;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c91); }
+ }
+ if (s1 !== peg$FAILED) {
+ s1 = peg$c92();
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenthChild() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 27,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 11) === peg$c93) {
+ s1 = peg$c93;
+ peg$currPos += 11;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c94); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ if (s4 !== peg$FAILED) {
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ }
+ } else {
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c95(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenthLastChild() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 28,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 16) === peg$c96) {
+ s1 = peg$c96;
+ peg$currPos += 16;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c97); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ if (s4 !== peg$FAILED) {
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ { peg$fail(peg$c60); }
+ }
+ }
+ } else {
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ s1 = peg$c98(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;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseclass() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 29,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 58) {
+ s1 = peg$c99;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ { peg$fail(peg$c100); }
+ }
+ if (s1 !== peg$FAILED) {
+ if (input.substr(peg$currPos, 9).toLowerCase() === peg$c101) {
+ s2 = input.substr(peg$currPos, 9);
+ peg$currPos += 9;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c102); }
+ }
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 10).toLowerCase() === peg$c103) {
+ s2 = input.substr(peg$currPos, 10);
+ peg$currPos += 10;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c104); }
+ }
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 11).toLowerCase() === peg$c105) {
+ s2 = input.substr(peg$currPos, 11);
+ peg$currPos += 11;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c106); }
+ }
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 8).toLowerCase() === peg$c107) {
+ s2 = input.substr(peg$currPos, 8);
+ peg$currPos += 8;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c108); }
+ }
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 7).toLowerCase() === peg$c109) {
+ s2 = input.substr(peg$currPos, 7);
+ peg$currPos += 7;
+ } else {
+ s2 = peg$FAILED;
+ { peg$fail(peg$c110); }
+ }
+ }
+ }
+ }
+ }
+ if (s2 !== peg$FAILED) {
+ s1 = peg$c111(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+
+ 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) {
+ return s.replace(/\\(.)/g, function(match, ch) {
+ switch(ch) {
+ case 'b': return '\b';
+ case 'f': return '\f';
+ case 'n': return '\n';
+ case 'r': return '\r';
+ case 't': return '\t';
+ case 'v': return '\v';
+ default: return ch;
+ }
+ });
+ }
+
+
+ peg$result = peg$startRuleFunction();
+
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
+ return peg$result;
+ } else {
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
+ peg$fail(peg$endExpectation());
+ }
+
+ 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: peg$SyntaxError,
+ parse: peg$parse
+ };
+ });
+ });
+
+ /* vim: set sw=4 sts=4 : */
+
+ /**
+ * @typedef {"LEFT_SIDE"|"RIGHT_SIDE"} Side
+ */
+
+ const LEFT_SIDE = 'LEFT_SIDE';
+ const RIGHT_SIDE = 'RIGHT_SIDE';
+
+ /**
+ * @external AST
+ * @see https://esprima.readthedocs.io/en/latest/syntax-tree-format.html
+ */
+
+ /**
+ * One of the rules of `grammar.pegjs`
+ * @typedef {PlainObject} SelectorAST
+ * @see grammar.pegjs
+ */
+
+ /**
+ * The `sequence` production of `grammar.pegjs`
+ * @typedef {PlainObject} SelectorSequenceAST
+ */
+
+ /**
+ * Get the value of a property which may be multiple levels down
+ * in the object.
+ * @param {?PlainObject} obj
+ * @param {string} key
+ * @returns {undefined|boolean|string|number|external:AST}
+ */
+ function getPath(obj, key) {
+ const keys = key.split('.');
+ for (let i = 0; i < keys.length; i++) {
+ if (obj == null) { return obj; }
+ obj = obj[keys[i]];
+ }
+ return obj;
+ }
+
+ /**
+ * Determine whether `node` can be reached by following `path`,
+ * starting at `ancestor`.
+ * @param {?external:AST} node
+ * @param {?external:AST} ancestor
+ * @param {string[]} path
+ * @returns {boolean}
+ */
+ function inPath(node, ancestor, path) {
+ if (path.length === 0) { return node === ancestor; }
+ if (ancestor == null) { return false; }
+ const field = ancestor[path[0]];
+ const remainingPath = path.slice(1);
+ if (Array.isArray(field)) {
+ for (let i = 0, l = field.length; i < l; ++i) {
+ if (inPath(node, field[i], remainingPath)) { return true; }
+ }
+ return false;
+ } else {
+ return inPath(node, field, remainingPath);
+ }
+ }
+
+ /**
+ * Given a `node` and its ancestors, determine if `node` is matched
+ * by `selector`.
+ * @param {?external:AST} node
+ * @param {?SelectorAST} selector
+ * @param {external:AST[]} [ancestry=[]]
+ * @throws {Error} Unknowns (operator, class name, selector type, or
+ * selector value type)
+ * @returns {boolean}
+ */
+ function matches(node, selector, ancestry) {
+ if (!selector) { return true; }
+ if (!node) { return false; }
+ if (!ancestry) { ancestry = []; }
+
+ switch(selector.type) {
+ case 'wildcard':
+ return true;
+
+ case 'identifier':
+ return selector.value.toLowerCase() === node.type.toLowerCase();
+
+ case 'field': {
+ const path = selector.name.split('.');
+ const ancestor = ancestry[path.length - 1];
+ return inPath(node, ancestor, path);
+
+ }
+ case 'matches':
+ for (let i = 0, l = selector.selectors.length; i < l; ++i) {
+ if (matches(node, selector.selectors[i], ancestry)) { return true; }
+ }
+ return false;
+
+ case 'compound':
+ for (let i = 0, l = selector.selectors.length; i < l; ++i) {
+ if (!matches(node, selector.selectors[i], ancestry)) { return false; }
+ }
+ return true;
+
+ case 'not':
+ for (let i = 0, l = selector.selectors.length; i < l; ++i) {
+ if (matches(node, selector.selectors[i], ancestry)) { return false; }
+ }
+ return true;
+
+ case 'has': {
+ const collector = [];
+ for (let i = 0, l = selector.selectors.length; i < l; ++i) {
+ const a = [];
+ estraverse.traverse(node, {
+ enter (node, parent) {
+ if (parent != null) { a.unshift(parent); }
+ if (matches(node, selector.selectors[i], a)) {
+ collector.push(node);
+ }
+ },
+ leave () { a.shift(); },
+ fallback: 'iteration'
+ });
+ }
+ return collector.length !== 0;
+
+ }
+ case 'child':
+ if (matches(node, selector.right, ancestry)) {
+ return matches(ancestry[0], selector.left, ancestry.slice(1));
+ }
+ return false;
+
+ case 'descendant':
+ if (matches(node, selector.right, ancestry)) {
+ for (let i = 0, l = ancestry.length; i < l; ++i) {
+ if (matches(ancestry[i], selector.left, ancestry.slice(i + 1))) {
+ return true;
+ }
+ }
+ }
+ return false;
+
+ case 'attribute': {
+ const p = getPath(node, selector.name);
+ switch (selector.operator) {
+ case void 0:
+ return p != null;
+ case '=':
+ switch (selector.value.type) {
+ case 'regexp': return typeof p === 'string' && selector.value.value.test(p);
+ case 'literal': return `${selector.value.value}` === `${p}`;
+ case 'type': return selector.value.value === typeof p;
+ }
+ throw new Error(`Unknown selector value type: ${selector.value.type}`);
+ case '!=':
+ switch (selector.value.type) {
+ case 'regexp': return !selector.value.value.test(p);
+ case 'literal': return `${selector.value.value}` !== `${p}`;
+ case 'type': return selector.value.value !== typeof p;
+ }
+ throw new Error(`Unknown selector value type: ${selector.value.type}`);
+ case '<=': return p <= selector.value.value;
+ case '<': return p < selector.value.value;
+ case '>': return p > selector.value.value;
+ case '>=': return p >= selector.value.value;
+ }
+ throw new Error(`Unknown operator: ${selector.operator}`);
+ }
+ case 'sibling':
+ return matches(node, selector.right, ancestry) &&
+ sibling(node, selector.left, ancestry, LEFT_SIDE) ||
+ selector.left.subject &&
+ matches(node, selector.left, ancestry) &&
+ sibling(node, selector.right, ancestry, RIGHT_SIDE);
+ case 'adjacent':
+ return matches(node, selector.right, ancestry) &&
+ adjacent(node, selector.left, ancestry, LEFT_SIDE) ||
+ selector.right.subject &&
+ matches(node, selector.left, ancestry) &&
+ adjacent(node, selector.right, ancestry, RIGHT_SIDE);
+
+ case 'nth-child':
+ return matches(node, selector.right, ancestry) &&
+ nthChild(node, ancestry, function () {
+ return selector.index.value - 1;
+ });
+
+ case 'nth-last-child':
+ return matches(node, selector.right, ancestry) &&
+ nthChild(node, ancestry, function (length) {
+ return length - selector.index.value;
+ });
+
+ case 'class':
+ switch(selector.name.toLowerCase()){
+ case 'statement':
+ if(node.type.slice(-9) === 'Statement') return true;
+ // fallthrough: interface Declaration <: Statement { }
+ case 'declaration':
+ return node.type.slice(-11) === 'Declaration';
+ case 'pattern':
+ if(node.type.slice(-7) === 'Pattern') return true;
+ // fallthrough: interface Expression <: Node, Pattern { }
+ case 'expression':
+ return node.type.slice(-10) === 'Expression' ||
+ node.type.slice(-7) === 'Literal' ||
+ (
+ node.type === 'Identifier' &&
+ (ancestry.length === 0 || ancestry[0].type !== 'MetaProperty')
+ ) ||
+ node.type === 'MetaProperty';
+ case 'function':
+ return node.type === 'FunctionDeclaration' ||
+ node.type === 'FunctionExpression' ||
+ node.type === 'ArrowFunctionExpression';
+ }
+ throw new Error(`Unknown class name: ${selector.name}`);
+ }
+
+ throw new Error(`Unknown selector type: ${selector.type}`);
+ }
+
+ /**
+ * Determines if the given node has a sibling that matches the
+ * given selector.
+ * @param {external:AST} node
+ * @param {SelectorSequenceAST} selector
+ * @param {external:AST[]} ancestry
+ * @param {Side} side
+ * @returns {boolean}
+ */
+ function sibling(node, selector, ancestry, side) {
+ const [parent] = ancestry;
+ if (!parent) { return false; }
+ const keys = estraverse.VisitorKeys[parent.type];
+ for (let i = 0, l = keys.length; i < l; ++i) {
+ const listProp = parent[keys[i]];
+ if (Array.isArray(listProp)) {
+ const startIndex = listProp.indexOf(node);
+ if (startIndex < 0) { continue; }
+ let lowerBound, upperBound;
+ if (side === LEFT_SIDE) {
+ lowerBound = 0;
+ upperBound = startIndex;
+ } else {
+ lowerBound = startIndex + 1;
+ upperBound = listProp.length;
+ }
+ for (let k = lowerBound; k < upperBound; ++k) {
+ if (matches(listProp[k], selector, ancestry)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Determines if the given node has an adjacent sibling that matches
+ * the given selector.
+ * @param {external:AST} node
+ * @param {SelectorSequenceAST} selector
+ * @param {external:AST[]} ancestry
+ * @param {Side} side
+ * @returns {boolean}
+ */
+ function adjacent(node, selector, ancestry, side) {
+ const [parent] = ancestry;
+ if (!parent) { return false; }
+ const keys = estraverse.VisitorKeys[parent.type];
+ for (let i = 0, l = keys.length; i < l; ++i) {
+ const listProp = parent[keys[i]];
+ if (Array.isArray(listProp)) {
+ const idx = listProp.indexOf(node);
+ if (idx < 0) { continue; }
+ if (side === LEFT_SIDE && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) {
+ return true;
+ }
+ if (side === RIGHT_SIDE && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @callback IndexFunction
+ * @param {Integer} len Containing list's length
+ * @returns {Integer}
+ */
+
+ /**
+ * Determines if the given node is the nth child, determined by
+ * `idxFn`, which is given the containing list's length.
+ * @param {external:AST} node
+ * @param {external:AST[]} ancestry
+ * @param {IndexFunction} idxFn
+ * @returns {boolean}
+ */
+ function nthChild(node, ancestry, idxFn) {
+ const [parent] = ancestry;
+ if (!parent) { return false; }
+ const keys = estraverse.VisitorKeys[parent.type];
+ for (let i = 0, l = keys.length; i < l; ++i) {
+ const listProp = parent[keys[i]];
+ if (Array.isArray(listProp)) {
+ const idx = listProp.indexOf(node);
+ if (idx >= 0 && idx === idxFn(listProp.length)) { return true; }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * For each selector node marked as a subject, find the portion of the
+ * selector that the subject must match.
+ * @param {SelectorAST} selector
+ * @param {SelectorAST} [ancestor] Defaults to `selector`
+ * @returns {SelectorAST[]}
+ */
+ function subjects(selector, ancestor) {
+ if (selector == null || typeof selector != 'object') { return []; }
+ if (ancestor == null) { ancestor = selector; }
+ const results = selector.subject ? [ancestor] : [];
+ for (const [p, sel] of Object.entries(selector)) {
+ results.push(...subjects(sel, p === 'left' ? sel : ancestor));
+ }
+ return results;
+ }
+
+ /**
+ * From a JS AST and a selector AST, collect all JS AST nodes that
+ * match the selector.
+ * @param {external:AST} ast
+ * @param {?SelectorAST} selector
+ * @returns {external:AST[]}
+ */
+ function match(ast, selector) {
+ const ancestry = [], results = [];
+ if (!selector) { return results; }
+ const altSubjects = subjects(selector);
+ estraverse.traverse(ast, {
+ enter (node, parent) {
+ if (parent != null) { ancestry.unshift(parent); }
+ if (matches(node, selector, ancestry)) {
+ if (altSubjects.length) {
+ for (let i = 0, l = altSubjects.length; i < l; ++i) {
+ if (matches(node, altSubjects[i], ancestry)) { results.push(node); }
+ for (let k = 0, m = ancestry.length; k < m; ++k) {
+ if (matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))) {
+ results.push(ancestry[k]);
+ }
+ }
+ }
+ } else {
+ results.push(node);
+ }
+ }
+ },
+ leave () { ancestry.shift(); },
+ fallback: 'iteration'
+ });
+ return results;
+ }
+
+ /**
+ * Parse a selector string and return its AST.
+ * @param {string} selector
+ * @returns {SelectorAST}
+ */
+ function parse(selector) {
+ return parser.parse(selector);
+ }
+
+ /**
+ * Query the code AST using the selector string.
+ * @param {external:AST} ast
+ * @param {string} selector
+ * @returns {external:AST[]}
+ */
+ function query(ast, selector) {
+ return match(ast, parse(selector));
+ }
+
+ query.parse = parse;
+ query.match = match;
+ query.matches = matches;
+ query.query = query;
+
+ return query;
+
+})));
diff --git a/tools/node_modules/eslint/node_modules/esquery/dist/esquery.min.js b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.min.js
new file mode 100644
index 00000000000000..eb2665517ea280
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/esquery/dist/esquery.min.js
@@ -0,0 +1,2 @@
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).esquery=t()}(this,(function(){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(e,t){return e(t={exports:{}},t.exports),t.exports}var t=e((function(e,t){!function e(t){var r,n,s,o,a,i;function l(e){var t,r,n={};for(t in e)e.hasOwnProperty(t)&&(r=e[t],n[t]="object"==typeof r&&null!==r?l(r):r);return n}function u(e,t){this.parent=e,this.key=t}function c(e,t,r,n){this.node=e,this.path=t,this.wrap=r,this.ref=n}function p(){}function f(e){return null!=e&&("object"==typeof e&&"string"==typeof e.type)}function h(e,t){return(e===r.ObjectExpression||e===r.ObjectPattern)&&"properties"===t}function d(e,t){return(new p).traverse(e,t)}function x(e,t){var r;return r=function(e,t){var r,n,s,o;for(n=e.length,s=0;n;)t(e[o=s+(r=n>>>1)])?n=r:(s=o+1,n-=r+1);return s}(t,(function(t){return t.range[0]>e.range[0]})),e.extendedRange=[e.range[0],e.range[1]],r!==t.length&&(e.extendedRange[1]=t[r].range[0]),(r-=1)>=0&&(e.extendedRange[0]=t[r].range[1]),e}return r={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ComprehensionBlock:"ComprehensionBlock",ComprehensionExpression:"ComprehensionExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DebuggerStatement:"DebuggerStatement",DirectiveStatement:"DirectiveStatement",DoWhileStatement:"DoWhileStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForInStatement:"ForInStatement",ForOfStatement:"ForOfStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",GeneratorExpression:"GeneratorExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportExpression:"ImportExpression",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",ModuleSpecifier:"ModuleSpecifier",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchStatement:"SwitchStatement",SwitchCase:"SwitchCase",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"},s={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ComprehensionBlock:["left","right"],ComprehensionExpression:["blocks","filter","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExportAllDeclaration:["source"],ExportDefaultDeclaration:["declaration"],ExportNamedDeclaration:["declaration","specifiers","source"],ExportSpecifier:["exported","local"],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],GeneratorExpression:["blocks","filter","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportExpression:["source"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],Program:["body"],Property:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],Super:[],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],YieldExpression:["argument"]},n={Break:o={},Skip:a={},Remove:i={}},u.prototype.replace=function(e){this.parent[this.key]=e},u.prototype.remove=function(){return Array.isArray(this.parent)?(this.parent.splice(this.key,1),!0):(this.replace(null),!1)},p.prototype.path=function(){var e,t,r,n,s;function o(e,t){if(Array.isArray(t))for(r=0,n=t.length;r=0;)if(y=i[p=m[d]])if(Array.isArray(y)){for(x=y.length;(x-=1)>=0;)if(y[x]){if(h(l,m[d]))s=new c(y[x],[p,x],"Property",null);else{if(!f(y[x]))continue;s=new c(y[x],[p,x],null,null)}r.push(s)}}else f(y)&&r.push(new c(y,p,null,null))}}else if(s=n.pop(),u=this.__execute(t.leave,s),this.__state===o||u===o)return},p.prototype.replace=function(e,t){var r,n,s,l,p,d,x,m,y,g,v,A,E;function _(e){var t,n,s,o;if(e.ref.remove())for(n=e.ref.key,o=e.ref.parent,t=r.length;t--;)if((s=r[t]).ref&&s.ref.parent===o){if(s.ref.key=0;)if(g=s[E=y[x]])if(Array.isArray(g)){for(m=g.length;(m-=1)>=0;)if(g[m]){if(h(l,y[x]))d=new c(g[m],[E,m],"Property",new u(g,m));else{if(!f(g[m]))continue;d=new c(g[m],[E,m],null,new u(g,m))}r.push(d)}}else f(g)&&r.push(new c(g,E,null,new u(s,E)))}}else if(d=n.pop(),void 0!==(p=this.__execute(t.leave,d))&&p!==o&&p!==a&&p!==i&&d.ref.replace(p),this.__state!==i&&p!==i||_(d),this.__state===o||p===o)return A.root;return A.root},t.Syntax=r,t.traverse=d,t.replace=function(e,t){return(new p).replace(e,t)},t.attachComments=function(e,t,r){var s,o,a,i,u=[];if(!e.range)throw new Error("attachComments needs range information");if(!r.length){if(t.length){for(a=0,o=t.length;ae.range[0]);)t.extendedRange[1]===e.range[0]?(e.leadingComments||(e.leadingComments=[]),e.leadingComments.push(t),u.splice(i,1)):i+=1;return i===u.length?n.Break:u[i].extendedRange[0]>e.range[1]?n.Skip:void 0}}),i=0,d(e,{leave:function(e){for(var t;ie.range[1]?n.Skip:void 0}}),e},t.VisitorKeys=s,t.VisitorOption=n,t.Controller=p,t.cloneEnvironment=function(){return e({})},t}(t)})),r=e((function(e){e.exports&&(e.exports=function(){function e(t,r,n,s){this.message=t,this.expected=r,this.found=n,this.location=s,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}return function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(e,Error),e.buildMessage=function(e,t){var r={literal:function(e){return'"'+s(e.text)+'"'},class:function(e){var t,r="";for(t=0;t0){for(t=1,n=1;t<~+.]/,f=ye([" ","[","]",",","(",")",":","#","!","=",">","<","~","+","."],!0,!1),h=function(e){return e.join("")},d=me(">",!1),x=me("~",!1),m=me("+",!1),y=me(",",!1),g=me("!",!1),v=me("*",!1),A=me("#",!1),E=me("[",!1),_=me("]",!1),b=/^[>","<","!"],!1,!1),C=me("=",!1),w=function(e){return(e||"")+"="},P=/^[><]/,k=ye([">","<"],!1,!1),D=me(".",!1),I=function(e,t,r){return{type:"attribute",name:e,operator:t,value:r}},j=me('"',!1),F=/^[^\\"]/,T=ye(["\\",'"'],!0,!1),L=me("\\",!1),R={type:"any"},O=function(e,t){return e+t},B=function(e){return{type:"literal",value:(t=e.join(""),t.replace(/\\(.)/g,(function(e,t){switch(t){case"b":return"\b";case"f":return"\f";case"n":return"\n";case"r":return"\r";case"t":return"\t";case"v":return"\v";default:return t}})))};var t},M=me("'",!1),U=/^[^\\']/,V=ye(["\\","'"],!0,!1),q=/^[0-9]/,N=ye([["0","9"]],!1,!1),W=me("type(",!1),$=/^[^ )]/,G=ye([" ",")"],!0,!1),z=me(")",!1),K=/^[imsu]/,H=ye(["i","m","s","u"],!1,!1),Y=me("/",!1),J=/^[^\/]/,Q=ye(["/"],!0,!1),X=me(":not(",!1),Z=me(":matches(",!1),ee=me(":has(",!1),te=me(":first-child",!1),re=me(":last-child",!1),ne=me(":nth-child(",!1),se=me(":nth-last-child(",!1),oe=me(":",!1),ae=me("statement",!0),ie=me("expression",!0),le=me("declaration",!0),ue=me("function",!0),ce=me("pattern",!0),pe=0,fe=[{line:1,column:1}],he=0,de=[],xe={};if("startRule"in r){if(!(r.startRule in l))throw new Error("Can't start parsing from rule \""+r.startRule+'".');u=l[r.startRule]}function me(e,t){return{type:"literal",text:e,ignoreCase:t}}function ye(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function ge(e){var r,n=fe[e];if(n)return n;for(r=e-1;!fe[r];)r--;for(n={line:(n=fe[r]).line,column:n.column};rhe&&(he=pe,de=[]),de.push(e))}function Ee(){var e,t,r,n,s=30*pe+0,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,(t=_e())!==i&&(r=Ce())!==i&&_e()!==i?e=t=1===(n=r).length?n[0]:{type:"matches",selectors:n}:(pe=e,e=i),e===i&&(e=pe,(t=_e())!==i&&(t=void 0),e=t),xe[s]={nextPos:pe,result:e},e)}function _e(){var e,r,n=30*pe+1,s=xe[n];if(s)return pe=s.nextPos,s.result;for(e=[],32===t.charCodeAt(pe)?(r=" ",pe++):(r=i,Ae(c));r!==i;)e.push(r),32===t.charCodeAt(pe)?(r=" ",pe++):(r=i,Ae(c));return xe[n]={nextPos:pe,result:e},e}function be(){var e,r,n,s=30*pe+2,o=xe[s];if(o)return pe=o.nextPos,o.result;if(r=[],p.test(t.charAt(pe))?(n=t.charAt(pe),pe++):(n=i,Ae(f)),n!==i)for(;n!==i;)r.push(n),p.test(t.charAt(pe))?(n=t.charAt(pe),pe++):(n=i,Ae(f));else r=i;return r!==i&&(r=h(r)),e=r,xe[s]={nextPos:pe,result:e},e}function Se(){var e,r,n,s=30*pe+3,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,(r=_e())!==i?(62===t.charCodeAt(pe)?(n=">",pe++):(n=i,Ae(d)),n!==i&&_e()!==i?e=r="child":(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=_e())!==i?(126===t.charCodeAt(pe)?(n="~",pe++):(n=i,Ae(x)),n!==i&&_e()!==i?e=r="sibling":(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=_e())!==i?(43===t.charCodeAt(pe)?(n="+",pe++):(n=i,Ae(m)),n!==i&&_e()!==i?e=r="adjacent":(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,32===t.charCodeAt(pe)?(r=" ",pe++):(r=i,Ae(c)),r!==i&&(n=_e())!==i?e=r="descendant":(pe=e,e=i)))),xe[s]={nextPos:pe,result:e},e)}function Ce(){var e,r,n,s,o,a,l,u,c=30*pe+4,p=xe[c];if(p)return pe=p.nextPos,p.result;if(e=pe,(r=we())!==i){for(n=[],s=pe,(o=_e())!==i?(44===t.charCodeAt(pe)?(a=",",pe++):(a=i,Ae(y)),a!==i&&(l=_e())!==i&&(u=we())!==i?s=o=[o,a,l,u]:(pe=s,s=i)):(pe=s,s=i);s!==i;)n.push(s),s=pe,(o=_e())!==i?(44===t.charCodeAt(pe)?(a=",",pe++):(a=i,Ae(y)),a!==i&&(l=_e())!==i&&(u=we())!==i?s=o=[o,a,l,u]:(pe=s,s=i)):(pe=s,s=i);n!==i?e=r=[r].concat(n.map((function(e){return e[3]}))):(pe=e,e=i)}else pe=e,e=i;return xe[c]={nextPos:pe,result:e},e}function we(){var e,t,r,n,s,o,a,l=30*pe+5,u=xe[l];if(u)return pe=u.nextPos,u.result;if(e=pe,(t=Pe())!==i){for(r=[],n=pe,(s=Se())!==i&&(o=Pe())!==i?n=s=[s,o]:(pe=n,n=i);n!==i;)r.push(n),n=pe,(s=Se())!==i&&(o=Pe())!==i?n=s=[s,o]:(pe=n,n=i);r!==i?(a=t,e=t=r.reduce((function(e,t){return{type:t[0],left:e,right:t[1]}}),a)):(pe=e,e=i)}else pe=e,e=i;return xe[l]={nextPos:pe,result:e},e}function Pe(){var e,r,n,s,o=30*pe+6,a=xe[o];if(a)return pe=a.nextPos,a.result;if(e=pe,33===t.charCodeAt(pe)?(r="!",pe++):(r=i,Ae(g)),r===i&&(r=null),r!==i){if(n=[],(s=ke())!==i)for(;s!==i;)n.push(s),s=ke();else n=i;n!==i?e=r=function(e,t){const r=1===t.length?t[0]:{type:"compound",selectors:t};return e&&(r.subject=!0),r}(r,n):(pe=e,e=i)}else pe=e,e=i;return xe[o]={nextPos:pe,result:e},e}function ke(){var e,r=30*pe+7,n=xe[r];return n?(pe=n.nextPos,n.result):((e=function(){var e,r,n=30*pe+8,s=xe[n];return s?(pe=s.nextPos,s.result):(42===t.charCodeAt(pe)?(r="*",pe++):(r=i,Ae(v)),r!==i&&(r={type:"wildcard",value:r}),e=r,xe[n]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s=30*pe+9,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,35===t.charCodeAt(pe)?(r="#",pe++):(r=i,Ae(A)),r===i&&(r=null),r!==i&&(n=be())!==i?e=r={type:"identifier",value:n}:(pe=e,e=i),xe[s]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o=30*pe+10,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,91===t.charCodeAt(pe)?(r="[",pe++):(r=i,Ae(E)),r!==i&&_e()!==i&&(n=function(){var e,r,n,s,o=30*pe+14,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,(r=De())!==i&&_e()!==i&&(n=function(){var e,r,n,s=30*pe+12,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,33===t.charCodeAt(pe)?(r="!",pe++):(r=i,Ae(g)),r===i&&(r=null),r!==i?(61===t.charCodeAt(pe)?(n="=",pe++):(n=i,Ae(C)),n!==i?(r=w(r),e=r):(pe=e,e=i)):(pe=e,e=i),xe[s]={nextPos:pe,result:e},e)}())!==i&&_e()!==i?((s=function(){var e,r,n,s,o,a=30*pe+18,l=xe[a];if(l)return pe=l.nextPos,l.result;if(e=pe,"type("===t.substr(pe,5)?(r="type(",pe+=5):(r=i,Ae(W)),r!==i)if(_e()!==i){if(n=[],$.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(G)),s!==i)for(;s!==i;)n.push(s),$.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(G));else n=i;n!==i&&(s=_e())!==i?(41===t.charCodeAt(pe)?(o=")",pe++):(o=i,Ae(z)),o!==i?(r={type:"type",value:n.join("")},e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return xe[a]={nextPos:pe,result:e},e}())===i&&(s=function(){var e,r,n,s,o,a,l=30*pe+20,u=xe[l];if(u)return pe=u.nextPos,u.result;if(e=pe,47===t.charCodeAt(pe)?(r="/",pe++):(r=i,Ae(Y)),r!==i){if(n=[],J.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(Q)),s!==i)for(;s!==i;)n.push(s),J.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(Q));else n=i;n!==i?(47===t.charCodeAt(pe)?(s="/",pe++):(s=i,Ae(Y)),s!==i?((o=function(){var e,r,n=30*pe+19,s=xe[n];if(s)return pe=s.nextPos,s.result;if(e=[],K.test(t.charAt(pe))?(r=t.charAt(pe),pe++):(r=i,Ae(H)),r!==i)for(;r!==i;)e.push(r),K.test(t.charAt(pe))?(r=t.charAt(pe),pe++):(r=i,Ae(H));else e=i;return xe[n]={nextPos:pe,result:e},e}())===i&&(o=null),o!==i?(a=o,r={type:"regexp",value:new RegExp(n.join(""),a?a.join(""):"")},e=r):(pe=e,e=i)):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;return xe[l]={nextPos:pe,result:e},e}()),s!==i?(r=I(r,n,s),e=r):(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=De())!==i&&_e()!==i&&(n=function(){var e,r,n,s=30*pe+11,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,b.test(t.charAt(pe))?(r=t.charAt(pe),pe++):(r=i,Ae(S)),r===i&&(r=null),r!==i?(61===t.charCodeAt(pe)?(n="=",pe++):(n=i,Ae(C)),n!==i?(r=w(r),e=r):(pe=e,e=i)):(pe=e,e=i),e===i&&(P.test(t.charAt(pe))?(e=t.charAt(pe),pe++):(e=i,Ae(k))),xe[s]={nextPos:pe,result:e},e)}())!==i&&_e()!==i?((s=function(){var e,r,n,s,o,a,l=30*pe+15,u=xe[l];if(u)return pe=u.nextPos,u.result;if(e=pe,34===t.charCodeAt(pe)?(r='"',pe++):(r=i,Ae(j)),r!==i){for(n=[],F.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(T)),s===i&&(s=pe,92===t.charCodeAt(pe)?(o="\\",pe++):(o=i,Ae(L)),o!==i?(t.length>pe?(a=t.charAt(pe),pe++):(a=i,Ae(R)),a!==i?(o=O(o,a),s=o):(pe=s,s=i)):(pe=s,s=i));s!==i;)n.push(s),F.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(T)),s===i&&(s=pe,92===t.charCodeAt(pe)?(o="\\",pe++):(o=i,Ae(L)),o!==i?(t.length>pe?(a=t.charAt(pe),pe++):(a=i,Ae(R)),a!==i?(o=O(o,a),s=o):(pe=s,s=i)):(pe=s,s=i));n!==i?(34===t.charCodeAt(pe)?(s='"',pe++):(s=i,Ae(j)),s!==i?(r=B(n),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;if(e===i)if(e=pe,39===t.charCodeAt(pe)?(r="'",pe++):(r=i,Ae(M)),r!==i){for(n=[],U.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(V)),s===i&&(s=pe,92===t.charCodeAt(pe)?(o="\\",pe++):(o=i,Ae(L)),o!==i?(t.length>pe?(a=t.charAt(pe),pe++):(a=i,Ae(R)),a!==i?(o=O(o,a),s=o):(pe=s,s=i)):(pe=s,s=i));s!==i;)n.push(s),U.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(V)),s===i&&(s=pe,92===t.charCodeAt(pe)?(o="\\",pe++):(o=i,Ae(L)),o!==i?(t.length>pe?(a=t.charAt(pe),pe++):(a=i,Ae(R)),a!==i?(o=O(o,a),s=o):(pe=s,s=i)):(pe=s,s=i));n!==i?(39===t.charCodeAt(pe)?(s="'",pe++):(s=i,Ae(M)),s!==i?(r=B(n),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;return xe[l]={nextPos:pe,result:e},e}())===i&&(s=function(){var e,r,n,s,o=30*pe+16,a=xe[o];if(a)return pe=a.nextPos,a.result;for(e=pe,r=pe,n=[],q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));s!==i;)n.push(s),q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));if(n!==i?(46===t.charCodeAt(pe)?(s=".",pe++):(s=i,Ae(D)),s!==i?r=n=[n,s]:(pe=r,r=i)):(pe=r,r=i),r===i&&(r=null),r!==i){if(n=[],q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N)),s!==i)for(;s!==i;)n.push(s),q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));else n=i;n!==i?(r=function(e,t){const r=e?[].concat.apply([],e).join(""):"";return{type:"literal",value:parseFloat(r+t.join(""))}}(r,n),e=r):(pe=e,e=i)}else pe=e,e=i;return xe[o]={nextPos:pe,result:e},e}())===i&&(s=function(){var e,t,r=30*pe+17,n=xe[r];return n?(pe=n.nextPos,n.result):((t=be())!==i&&(t={type:"literal",value:t}),e=t,xe[r]={nextPos:pe,result:e},e)}()),s!==i?(r=I(r,n,s),e=r):(pe=e,e=i)):(pe=e,e=i),e===i&&(e=pe,(r=De())!==i&&(r={type:"attribute",name:r}),e=r)),xe[o]={nextPos:pe,result:e},e)}())!==i&&_e()!==i?(93===t.charCodeAt(pe)?(s="]",pe++):(s=i,Ae(_)),s!==i?e=r=n:(pe=e,e=i)):(pe=e,e=i),xe[o]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o,a,l,u,c=30*pe+21,p=xe[c];if(p)return pe=p.nextPos,p.result;if(e=pe,46===t.charCodeAt(pe)?(r=".",pe++):(r=i,Ae(D)),r!==i)if((n=be())!==i){for(s=[],o=pe,46===t.charCodeAt(pe)?(a=".",pe++):(a=i,Ae(D)),a!==i&&(l=be())!==i?o=a=[a,l]:(pe=o,o=i);o!==i;)s.push(o),o=pe,46===t.charCodeAt(pe)?(a=".",pe++):(a=i,Ae(D)),a!==i&&(l=be())!==i?o=a=[a,l]:(pe=o,o=i);s!==i?(u=n,r={type:"field",name:s.reduce((function(e,t){return e+t[0]+t[1]}),u)},e=r):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return xe[c]={nextPos:pe,result:e},e}())===i&&(e=function(){var e,r,n,s,o=30*pe+22,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,":not("===t.substr(pe,5)?(r=":not(",pe+=5):(r=i,Ae(X)),r!==i&&_e()!==i&&(n=Ce())!==i&&_e()!==i?(41===t.charCodeAt(pe)?(s=")",pe++):(s=i,Ae(z)),s!==i?e=r={type:"not",selectors:n}:(pe=e,e=i)):(pe=e,e=i),xe[o]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o=30*pe+23,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,":matches("===t.substr(pe,9)?(r=":matches(",pe+=9):(r=i,Ae(Z)),r!==i&&_e()!==i&&(n=Ce())!==i&&_e()!==i?(41===t.charCodeAt(pe)?(s=")",pe++):(s=i,Ae(z)),s!==i?e=r={type:"matches",selectors:n}:(pe=e,e=i)):(pe=e,e=i),xe[o]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o=30*pe+24,a=xe[o];return a?(pe=a.nextPos,a.result):(e=pe,":has("===t.substr(pe,5)?(r=":has(",pe+=5):(r=i,Ae(ee)),r!==i&&_e()!==i&&(n=Ce())!==i&&_e()!==i?(41===t.charCodeAt(pe)?(s=")",pe++):(s=i,Ae(z)),s!==i?e=r={type:"has",selectors:n}:(pe=e,e=i)):(pe=e,e=i),xe[o]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n=30*pe+25,s=xe[n];return s?(pe=s.nextPos,s.result):(":first-child"===t.substr(pe,12)?(r=":first-child",pe+=12):(r=i,Ae(te)),r!==i&&(r=Ie(1)),e=r,xe[n]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n=30*pe+26,s=xe[n];return s?(pe=s.nextPos,s.result):(":last-child"===t.substr(pe,11)?(r=":last-child",pe+=11):(r=i,Ae(re)),r!==i&&(r=je(1)),e=r,xe[n]={nextPos:pe,result:e},e)}())===i&&(e=function(){var e,r,n,s,o,a=30*pe+27,l=xe[a];if(l)return pe=l.nextPos,l.result;if(e=pe,":nth-child("===t.substr(pe,11)?(r=":nth-child(",pe+=11):(r=i,Ae(ne)),r!==i)if(_e()!==i){if(n=[],q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N)),s!==i)for(;s!==i;)n.push(s),q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));else n=i;n!==i&&(s=_e())!==i?(41===t.charCodeAt(pe)?(o=")",pe++):(o=i,Ae(z)),o!==i?(r=Ie(parseInt(n.join(""),10)),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return xe[a]={nextPos:pe,result:e},e}())===i&&(e=function(){var e,r,n,s,o,a=30*pe+28,l=xe[a];if(l)return pe=l.nextPos,l.result;if(e=pe,":nth-last-child("===t.substr(pe,16)?(r=":nth-last-child(",pe+=16):(r=i,Ae(se)),r!==i)if(_e()!==i){if(n=[],q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N)),s!==i)for(;s!==i;)n.push(s),q.test(t.charAt(pe))?(s=t.charAt(pe),pe++):(s=i,Ae(N));else n=i;n!==i&&(s=_e())!==i?(41===t.charCodeAt(pe)?(o=")",pe++):(o=i,Ae(z)),o!==i?(r=je(parseInt(n.join(""),10)),e=r):(pe=e,e=i)):(pe=e,e=i)}else pe=e,e=i;else pe=e,e=i;return xe[a]={nextPos:pe,result:e},e}())===i&&(e=function(){var e,r,n,s=30*pe+29,o=xe[s];return o?(pe=o.nextPos,o.result):(e=pe,58===t.charCodeAt(pe)?(r=":",pe++):(r=i,Ae(oe)),r!==i?("statement"===t.substr(pe,9).toLowerCase()?(n=t.substr(pe,9),pe+=9):(n=i,Ae(ae)),n===i&&("expression"===t.substr(pe,10).toLowerCase()?(n=t.substr(pe,10),pe+=10):(n=i,Ae(ie)),n===i&&("declaration"===t.substr(pe,11).toLowerCase()?(n=t.substr(pe,11),pe+=11):(n=i,Ae(le)),n===i&&("function"===t.substr(pe,8).toLowerCase()?(n=t.substr(pe,8),pe+=8):(n=i,Ae(ue)),n===i&&("pattern"===t.substr(pe,7).toLowerCase()?(n=t.substr(pe,7),pe+=7):(n=i,Ae(ce)))))),n!==i?e=r={type:"class",name:n}:(pe=e,e=i)):(pe=e,e=i),xe[s]={nextPos:pe,result:e},e)}()),xe[r]={nextPos:pe,result:e},e)}function De(){var e,r,n,s=30*pe+13,o=xe[s];if(o)return pe=o.nextPos,o.result;if(r=[],(n=be())===i&&(46===t.charCodeAt(pe)?(n=".",pe++):(n=i,Ae(D))),n!==i)for(;n!==i;)r.push(n),(n=be())===i&&(46===t.charCodeAt(pe)?(n=".",pe++):(n=i,Ae(D)));else r=i;return r!==i&&(r=h(r)),e=r,xe[s]={nextPos:pe,result:e},e}function Ie(e){return{type:"nth-child",index:{type:"literal",value:e}}}function je(e){return{type:"nth-last-child",index:{type:"literal",value:e}}}if((n=u())!==i&&pe===t.length)return n;throw n!==i&&pe":return t>r.value.value;case">=":return t>=r.value.value}throw new Error(`Unknown operator: ${r.operator}`)}case"sibling":return n(e,r.right,i)&&s(e,r.left,i,"LEFT_SIDE")||r.left.subject&&n(e,r.left,i)&&s(e,r.right,i,"RIGHT_SIDE");case"adjacent":return n(e,r.right,i)&&o(e,r.left,i,"LEFT_SIDE")||r.right.subject&&n(e,r.left,i)&&o(e,r.right,i,"RIGHT_SIDE");case"nth-child":return n(e,r.right,i)&&a(e,i,(function(){return r.index.value-1}));case"nth-last-child":return n(e,r.right,i)&&a(e,i,(function(e){return e-r.index.value}));case"class":switch(r.name.toLowerCase()){case"statement":if("Statement"===e.type.slice(-9))return!0;case"declaration":return"Declaration"===e.type.slice(-11);case"pattern":if("Pattern"===e.type.slice(-7))return!0;case"expression":return"Expression"===e.type.slice(-10)||"Literal"===e.type.slice(-7)||"Identifier"===e.type&&(0===i.length||"MetaProperty"!==i[0].type)||"MetaProperty"===e.type;case"function":return"FunctionDeclaration"===e.type||"FunctionExpression"===e.type||"ArrowFunctionExpression"===e.type}throw new Error(`Unknown class name: ${r.name}`)}throw new Error(`Unknown selector type: ${r.type}`)}function s(e,r,s,o){const[a]=s;if(!a)return!1;const i=t.VisitorKeys[a.type];for(let t=0,l=i.length;t0&&n(l[t-1],r,s))return!0;if("RIGHT_SIDE"===o&&t=0&&t===n(r.length))return!0}}return!1}function i(e,r){const s=[],o=[];if(!r)return o;const a=function e(t,r){if(null==t||"object"!=typeof t)return[];null==r&&(r=t);const n=t.subject?[r]:[];for(const[s,o]of Object.entries(t))n.push(...e(o,"left"===s?o:r));return n}(r);return t.traverse(e,{enter(e,t){if(null!=t&&s.unshift(t),n(e,r,s))if(a.length)for(let t=0,r=a.length;t': return p > selector.value.value;
- case '>=': return p >= selector.value.value;
- }
-
- case 'sibling':
- return matches(node, selector.right, ancestry) &&
- sibling(node, selector.left, ancestry, LEFT_SIDE) ||
- selector.left.subject &&
- matches(node, selector.left, ancestry) &&
- sibling(node, selector.right, ancestry, RIGHT_SIDE);
-
- case 'adjacent':
- return matches(node, selector.right, ancestry) &&
- adjacent(node, selector.left, ancestry, LEFT_SIDE) ||
- selector.right.subject &&
- matches(node, selector.left, ancestry) &&
- adjacent(node, selector.right, ancestry, RIGHT_SIDE);
-
- case 'nth-child':
- return matches(node, selector.right, ancestry) &&
- nthChild(node, ancestry, function (length) {
- return selector.index.value - 1;
- });
-
- case 'nth-last-child':
- return matches(node, selector.right, ancestry) &&
- nthChild(node, ancestry, function (length) {
- return length - selector.index.value;
- });
-
- case 'class':
- if(!node.type) return false;
- switch(selector.name.toLowerCase()){
- case 'statement':
- if(node.type.slice(-9) === 'Statement') return true;
- // fallthrough: interface Declaration <: Statement { }
- case 'declaration':
- return node.type.slice(-11) === 'Declaration';
- case 'pattern':
- if(node.type.slice(-7) === 'Pattern') return true;
- // fallthrough: interface Expression <: Node, Pattern { }
- case 'expression':
- return node.type.slice(-10) === 'Expression' ||
- node.type.slice(-7) === 'Literal' ||
- (
- node.type === 'Identifier' &&
- (ancestry.length === 0 || ancestry[0].type !== 'MetaProperty')
- ) ||
- node.type === 'MetaProperty';
- case 'function':
- return node.type.slice(0, 8) === 'Function' ||
- node.type === 'ArrowFunctionExpression';
- }
- throw new Error('Unknown class name: ' + selector.name);
- }
-
- throw new Error('Unknown selector type: ' + selector.type);
- }
-
- /*
- * Determines if the given node has a sibling that matches the given selector.
- */
- function sibling(node, selector, ancestry, side) {
- var parent = ancestry[0], listProp, startIndex, keys, i, l, k, lowerBound, upperBound;
- if (!parent) { return false; }
- keys = estraverse.VisitorKeys[parent.type];
- for (i = 0, l = keys.length; i < l; ++i) {
- listProp = parent[keys[i]];
- if (isArray(listProp)) {
- startIndex = listProp.indexOf(node);
- if (startIndex < 0) { continue; }
- if (side === LEFT_SIDE) {
- lowerBound = 0;
- upperBound = startIndex;
- } else {
- lowerBound = startIndex + 1;
- upperBound = listProp.length;
- }
- for (k = lowerBound; k < upperBound; ++k) {
- if (matches(listProp[k], selector, ancestry)) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /*
- * Determines if the given node has an adjacent sibling that matches the given selector.
- */
- function adjacent(node, selector, ancestry, side) {
- var parent = ancestry[0], listProp, keys, i, l, idx;
- if (!parent) { return false; }
- keys = estraverse.VisitorKeys[parent.type];
- for (i = 0, l = keys.length; i < l; ++i) {
- listProp = parent[keys[i]];
- if (isArray(listProp)) {
- idx = listProp.indexOf(node);
- if (idx < 0) { continue; }
- if (side === LEFT_SIDE && idx > 0 && matches(listProp[idx - 1], selector, ancestry)) {
- return true;
- }
- if (side === RIGHT_SIDE && idx < listProp.length - 1 && matches(listProp[idx + 1], selector, ancestry)) {
- return true;
- }
- }
- }
- return false;
- }
-
- /*
- * Determines if the given node is the nth child, determined by idxFn, which is given the containing list's length.
- */
- function nthChild(node, ancestry, idxFn) {
- var parent = ancestry[0], listProp, keys, i, l, idx;
- if (!parent) { return false; }
- keys = estraverse.VisitorKeys[parent.type];
- for (i = 0, l = keys.length; i < l; ++i) {
- listProp = parent[keys[i]];
- if (isArray(listProp)) {
- idx = listProp.indexOf(node);
- if (idx >= 0 && idx === idxFn(listProp.length)) { return true; }
- }
- }
- return false;
- }
-
- /*
- * For each selector node marked as a subject, find the portion of the selector that the subject must match.
- */
- function subjects(selector, ancestor) {
- var results, p;
- if (selector == null || typeof selector != 'object') { return []; }
- if (ancestor == null) { ancestor = selector; }
- results = selector.subject ? [ancestor] : [];
- for(p in selector) {
- if(!{}.hasOwnProperty.call(selector, p)) { continue; }
- [].push.apply(results, subjects(selector[p], p === 'left' ? selector[p] : ancestor));
- }
- return results;
- }
-
- /**
- * From a JS AST and a selector AST, collect all JS AST nodes that match the selector.
- */
- function match(ast, selector) {
- var ancestry = [], results = [], altSubjects, i, l, k, m;
- if (!selector) { return results; }
- altSubjects = subjects(selector);
- estraverse.traverse(ast, {
- enter: function (node, parent) {
- if (parent != null) { ancestry.unshift(parent); }
- if (matches(node, selector, ancestry)) {
- if (altSubjects.length) {
- for (i = 0, l = altSubjects.length; i < l; ++i) {
- if (matches(node, altSubjects[i], ancestry)) { results.push(node); }
- for (k = 0, m = ancestry.length; k < m; ++k) {
- if (matches(ancestry[k], altSubjects[i], ancestry.slice(k + 1))) {
- results.push(ancestry[k]);
- }
- }
- }
- } else {
- results.push(node);
- }
- }
- },
- leave: function () { ancestry.shift(); },
- fallback: 'iteration'
- });
- return results;
- }
-
- /**
- * Parse a selector string and return its AST.
- */
- function parse(selector) {
- return parser.parse(selector);
- }
-
- /**
- * Query the code AST using the selector string.
- */
- function query(ast, selector) {
- return match(ast, parse(selector));
- }
-
- query.parse = parse;
- query.match = match;
- query.matches = matches;
- return query.query = query;
- }
-
-
- if (typeof define === "function" && define.amd) {
- define(esqueryModule);
- } else if (typeof module !== 'undefined' && module.exports) {
- module.exports = esqueryModule();
- } else {
- this.esquery = esqueryModule();
- }
-
-})();
diff --git a/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/LICENSE.BSD b/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/LICENSE.BSD
new file mode 100644
index 00000000000000..3e580c355a96e5
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/LICENSE.BSD
@@ -0,0 +1,19 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/README.md b/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/README.md
new file mode 100644
index 00000000000000..ccd3377f3e9449
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/README.md
@@ -0,0 +1,153 @@
+### Estraverse [![Build Status](https://secure.travis-ci.org/estools/estraverse.svg)](http://travis-ci.org/estools/estraverse)
+
+Estraverse ([estraverse](http://github.com/estools/estraverse)) is
+[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
+traversal functions from [esmangle project](http://github.com/estools/esmangle).
+
+### Documentation
+
+You can find usage docs at [wiki page](https://github.com/estools/estraverse/wiki/Usage).
+
+### Example Usage
+
+The following code will output all variables declared at the root of a file.
+
+```javascript
+estraverse.traverse(ast, {
+ enter: function (node, parent) {
+ if (node.type == 'FunctionExpression' || node.type == 'FunctionDeclaration')
+ return estraverse.VisitorOption.Skip;
+ },
+ leave: function (node, parent) {
+ if (node.type == 'VariableDeclarator')
+ console.log(node.id.name);
+ }
+});
+```
+
+We can use `this.skip`, `this.remove` and `this.break` functions instead of using Skip, Remove and Break.
+
+```javascript
+estraverse.traverse(ast, {
+ enter: function (node) {
+ this.break();
+ }
+});
+```
+
+And estraverse provides `estraverse.replace` function. When returning node from `enter`/`leave`, current node is replaced with it.
+
+```javascript
+result = estraverse.replace(tree, {
+ enter: function (node) {
+ // Replace it with replaced.
+ if (node.type === 'Literal')
+ return replaced;
+ }
+});
+```
+
+By passing `visitor.keys` mapping, we can extend estraverse traversing functionality.
+
+```javascript
+// This tree contains a user-defined `TestExpression` node.
+var tree = {
+ type: 'TestExpression',
+
+ // This 'argument' is the property containing the other **node**.
+ argument: {
+ type: 'Literal',
+ value: 20
+ },
+
+ // This 'extended' is the property not containing the other **node**.
+ extended: true
+};
+estraverse.traverse(tree, {
+ enter: function (node) { },
+
+ // Extending the existing traversing rules.
+ keys: {
+ // TargetNodeName: [ 'keys', 'containing', 'the', 'other', '**node**' ]
+ TestExpression: ['argument']
+ }
+});
+```
+
+By passing `visitor.fallback` option, we can control the behavior when encountering unknown nodes.
+
+```javascript
+// This tree contains a user-defined `TestExpression` node.
+var tree = {
+ type: 'TestExpression',
+
+ // This 'argument' is the property containing the other **node**.
+ argument: {
+ type: 'Literal',
+ value: 20
+ },
+
+ // This 'extended' is the property not containing the other **node**.
+ extended: true
+};
+estraverse.traverse(tree, {
+ enter: function (node) { },
+
+ // Iterating the child **nodes** of unknown nodes.
+ fallback: 'iteration'
+});
+```
+
+When `visitor.fallback` is a function, we can determine which keys to visit on each node.
+
+```javascript
+// This tree contains a user-defined `TestExpression` node.
+var tree = {
+ type: 'TestExpression',
+
+ // This 'argument' is the property containing the other **node**.
+ argument: {
+ type: 'Literal',
+ value: 20
+ },
+
+ // This 'extended' is the property not containing the other **node**.
+ extended: true
+};
+estraverse.traverse(tree, {
+ enter: function (node) { },
+
+ // Skip the `argument` property of each node
+ fallback: function(node) {
+ return Object.keys(node).filter(function(key) {
+ return key !== 'argument';
+ });
+ }
+});
+```
+
+### License
+
+Copyright (C) 2012-2016 [Yusuke Suzuki](http://github.com/Constellation)
+ (twitter: [@Constellation](http://twitter.com/Constellation)) and other contributors.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/estraverse.js b/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/estraverse.js
new file mode 100644
index 00000000000000..6e28ca02f1c848
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/estraverse.js
@@ -0,0 +1,781 @@
+/*
+ Copyright (C) 2012-2013 Yusuke Suzuki
+ Copyright (C) 2012 Ariya Hidayat
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/*jslint vars:false, bitwise:true*/
+/*jshint indent:4*/
+/*global exports:true*/
+(function clone(exports) {
+ 'use strict';
+
+ var Syntax,
+ VisitorOption,
+ VisitorKeys,
+ BREAK,
+ SKIP,
+ REMOVE;
+
+ function deepCopy(obj) {
+ var ret = {}, key, val;
+ for (key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ val = obj[key];
+ if (typeof val === 'object' && val !== null) {
+ ret[key] = deepCopy(val);
+ } else {
+ ret[key] = val;
+ }
+ }
+ }
+ return ret;
+ }
+
+ // based on LLVM libc++ upper_bound / lower_bound
+ // MIT License
+
+ function upperBound(array, func) {
+ var diff, len, i, current;
+
+ len = array.length;
+ i = 0;
+
+ while (len) {
+ diff = len >>> 1;
+ current = i + diff;
+ if (func(array[current])) {
+ len = diff;
+ } else {
+ i = current + 1;
+ len -= diff + 1;
+ }
+ }
+ return i;
+ }
+
+ Syntax = {
+ AssignmentExpression: 'AssignmentExpression',
+ AssignmentPattern: 'AssignmentPattern',
+ ArrayExpression: 'ArrayExpression',
+ ArrayPattern: 'ArrayPattern',
+ ArrowFunctionExpression: 'ArrowFunctionExpression',
+ AwaitExpression: 'AwaitExpression', // CAUTION: It's deferred to ES7.
+ BlockStatement: 'BlockStatement',
+ BinaryExpression: 'BinaryExpression',
+ BreakStatement: 'BreakStatement',
+ CallExpression: 'CallExpression',
+ CatchClause: 'CatchClause',
+ ClassBody: 'ClassBody',
+ ClassDeclaration: 'ClassDeclaration',
+ ClassExpression: 'ClassExpression',
+ ComprehensionBlock: 'ComprehensionBlock', // CAUTION: It's deferred to ES7.
+ ComprehensionExpression: 'ComprehensionExpression', // CAUTION: It's deferred to ES7.
+ ConditionalExpression: 'ConditionalExpression',
+ ContinueStatement: 'ContinueStatement',
+ DebuggerStatement: 'DebuggerStatement',
+ DirectiveStatement: 'DirectiveStatement',
+ DoWhileStatement: 'DoWhileStatement',
+ EmptyStatement: 'EmptyStatement',
+ ExportAllDeclaration: 'ExportAllDeclaration',
+ ExportDefaultDeclaration: 'ExportDefaultDeclaration',
+ ExportNamedDeclaration: 'ExportNamedDeclaration',
+ ExportSpecifier: 'ExportSpecifier',
+ ExpressionStatement: 'ExpressionStatement',
+ ForStatement: 'ForStatement',
+ ForInStatement: 'ForInStatement',
+ ForOfStatement: 'ForOfStatement',
+ FunctionDeclaration: 'FunctionDeclaration',
+ FunctionExpression: 'FunctionExpression',
+ GeneratorExpression: 'GeneratorExpression', // CAUTION: It's deferred to ES7.
+ Identifier: 'Identifier',
+ IfStatement: 'IfStatement',
+ ImportExpression: 'ImportExpression',
+ ImportDeclaration: 'ImportDeclaration',
+ ImportDefaultSpecifier: 'ImportDefaultSpecifier',
+ ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
+ ImportSpecifier: 'ImportSpecifier',
+ Literal: 'Literal',
+ LabeledStatement: 'LabeledStatement',
+ LogicalExpression: 'LogicalExpression',
+ MemberExpression: 'MemberExpression',
+ MetaProperty: 'MetaProperty',
+ MethodDefinition: 'MethodDefinition',
+ ModuleSpecifier: 'ModuleSpecifier',
+ NewExpression: 'NewExpression',
+ ObjectExpression: 'ObjectExpression',
+ ObjectPattern: 'ObjectPattern',
+ Program: 'Program',
+ Property: 'Property',
+ RestElement: 'RestElement',
+ ReturnStatement: 'ReturnStatement',
+ SequenceExpression: 'SequenceExpression',
+ SpreadElement: 'SpreadElement',
+ Super: 'Super',
+ SwitchStatement: 'SwitchStatement',
+ SwitchCase: 'SwitchCase',
+ TaggedTemplateExpression: 'TaggedTemplateExpression',
+ TemplateElement: 'TemplateElement',
+ TemplateLiteral: 'TemplateLiteral',
+ ThisExpression: 'ThisExpression',
+ ThrowStatement: 'ThrowStatement',
+ TryStatement: 'TryStatement',
+ UnaryExpression: 'UnaryExpression',
+ UpdateExpression: 'UpdateExpression',
+ VariableDeclaration: 'VariableDeclaration',
+ VariableDeclarator: 'VariableDeclarator',
+ WhileStatement: 'WhileStatement',
+ WithStatement: 'WithStatement',
+ YieldExpression: 'YieldExpression'
+ };
+
+ VisitorKeys = {
+ AssignmentExpression: ['left', 'right'],
+ AssignmentPattern: ['left', 'right'],
+ ArrayExpression: ['elements'],
+ ArrayPattern: ['elements'],
+ ArrowFunctionExpression: ['params', 'body'],
+ AwaitExpression: ['argument'], // CAUTION: It's deferred to ES7.
+ BlockStatement: ['body'],
+ BinaryExpression: ['left', 'right'],
+ BreakStatement: ['label'],
+ CallExpression: ['callee', 'arguments'],
+ CatchClause: ['param', 'body'],
+ ClassBody: ['body'],
+ ClassDeclaration: ['id', 'superClass', 'body'],
+ ClassExpression: ['id', 'superClass', 'body'],
+ ComprehensionBlock: ['left', 'right'], // CAUTION: It's deferred to ES7.
+ ComprehensionExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
+ ConditionalExpression: ['test', 'consequent', 'alternate'],
+ ContinueStatement: ['label'],
+ DebuggerStatement: [],
+ DirectiveStatement: [],
+ DoWhileStatement: ['body', 'test'],
+ EmptyStatement: [],
+ ExportAllDeclaration: ['source'],
+ ExportDefaultDeclaration: ['declaration'],
+ ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
+ ExportSpecifier: ['exported', 'local'],
+ ExpressionStatement: ['expression'],
+ ForStatement: ['init', 'test', 'update', 'body'],
+ ForInStatement: ['left', 'right', 'body'],
+ ForOfStatement: ['left', 'right', 'body'],
+ FunctionDeclaration: ['id', 'params', 'body'],
+ FunctionExpression: ['id', 'params', 'body'],
+ GeneratorExpression: ['blocks', 'filter', 'body'], // CAUTION: It's deferred to ES7.
+ Identifier: [],
+ IfStatement: ['test', 'consequent', 'alternate'],
+ ImportExpression: ['source'],
+ ImportDeclaration: ['specifiers', 'source'],
+ ImportDefaultSpecifier: ['local'],
+ ImportNamespaceSpecifier: ['local'],
+ ImportSpecifier: ['imported', 'local'],
+ Literal: [],
+ LabeledStatement: ['label', 'body'],
+ LogicalExpression: ['left', 'right'],
+ MemberExpression: ['object', 'property'],
+ MetaProperty: ['meta', 'property'],
+ MethodDefinition: ['key', 'value'],
+ ModuleSpecifier: [],
+ NewExpression: ['callee', 'arguments'],
+ ObjectExpression: ['properties'],
+ ObjectPattern: ['properties'],
+ Program: ['body'],
+ Property: ['key', 'value'],
+ RestElement: [ 'argument' ],
+ ReturnStatement: ['argument'],
+ SequenceExpression: ['expressions'],
+ SpreadElement: ['argument'],
+ Super: [],
+ SwitchStatement: ['discriminant', 'cases'],
+ SwitchCase: ['test', 'consequent'],
+ TaggedTemplateExpression: ['tag', 'quasi'],
+ TemplateElement: [],
+ TemplateLiteral: ['quasis', 'expressions'],
+ ThisExpression: [],
+ ThrowStatement: ['argument'],
+ TryStatement: ['block', 'handler', 'finalizer'],
+ UnaryExpression: ['argument'],
+ UpdateExpression: ['argument'],
+ VariableDeclaration: ['declarations'],
+ VariableDeclarator: ['id', 'init'],
+ WhileStatement: ['test', 'body'],
+ WithStatement: ['object', 'body'],
+ YieldExpression: ['argument']
+ };
+
+ // unique id
+ BREAK = {};
+ SKIP = {};
+ REMOVE = {};
+
+ VisitorOption = {
+ Break: BREAK,
+ Skip: SKIP,
+ Remove: REMOVE
+ };
+
+ function Reference(parent, key) {
+ this.parent = parent;
+ this.key = key;
+ }
+
+ Reference.prototype.replace = function replace(node) {
+ this.parent[this.key] = node;
+ };
+
+ Reference.prototype.remove = function remove() {
+ if (Array.isArray(this.parent)) {
+ this.parent.splice(this.key, 1);
+ return true;
+ } else {
+ this.replace(null);
+ return false;
+ }
+ };
+
+ function Element(node, path, wrap, ref) {
+ this.node = node;
+ this.path = path;
+ this.wrap = wrap;
+ this.ref = ref;
+ }
+
+ function Controller() { }
+
+ // API:
+ // return property path array from root to current node
+ Controller.prototype.path = function path() {
+ var i, iz, j, jz, result, element;
+
+ function addToPath(result, path) {
+ if (Array.isArray(path)) {
+ for (j = 0, jz = path.length; j < jz; ++j) {
+ result.push(path[j]);
+ }
+ } else {
+ result.push(path);
+ }
+ }
+
+ // root node
+ if (!this.__current.path) {
+ return null;
+ }
+
+ // first node is sentinel, second node is root element
+ result = [];
+ for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
+ element = this.__leavelist[i];
+ addToPath(result, element.path);
+ }
+ addToPath(result, this.__current.path);
+ return result;
+ };
+
+ // API:
+ // return type of current node
+ Controller.prototype.type = function () {
+ var node = this.current();
+ return node.type || this.__current.wrap;
+ };
+
+ // API:
+ // return array of parent elements
+ Controller.prototype.parents = function parents() {
+ var i, iz, result;
+
+ // first node is sentinel
+ result = [];
+ for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
+ result.push(this.__leavelist[i].node);
+ }
+
+ return result;
+ };
+
+ // API:
+ // return current node
+ Controller.prototype.current = function current() {
+ return this.__current.node;
+ };
+
+ Controller.prototype.__execute = function __execute(callback, element) {
+ var previous, result;
+
+ result = undefined;
+
+ previous = this.__current;
+ this.__current = element;
+ this.__state = null;
+ if (callback) {
+ result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
+ }
+ this.__current = previous;
+
+ return result;
+ };
+
+ // API:
+ // notify control skip / break
+ Controller.prototype.notify = function notify(flag) {
+ this.__state = flag;
+ };
+
+ // API:
+ // skip child nodes of current node
+ Controller.prototype.skip = function () {
+ this.notify(SKIP);
+ };
+
+ // API:
+ // break traversals
+ Controller.prototype['break'] = function () {
+ this.notify(BREAK);
+ };
+
+ // API:
+ // remove node
+ Controller.prototype.remove = function () {
+ this.notify(REMOVE);
+ };
+
+ Controller.prototype.__initialize = function(root, visitor) {
+ this.visitor = visitor;
+ this.root = root;
+ this.__worklist = [];
+ this.__leavelist = [];
+ this.__current = null;
+ this.__state = null;
+ this.__fallback = null;
+ if (visitor.fallback === 'iteration') {
+ this.__fallback = Object.keys;
+ } else if (typeof visitor.fallback === 'function') {
+ this.__fallback = visitor.fallback;
+ }
+
+ this.__keys = VisitorKeys;
+ if (visitor.keys) {
+ this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
+ }
+ };
+
+ function isNode(node) {
+ if (node == null) {
+ return false;
+ }
+ return typeof node === 'object' && typeof node.type === 'string';
+ }
+
+ function isProperty(nodeType, key) {
+ return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
+ }
+
+ Controller.prototype.traverse = function traverse(root, visitor) {
+ var worklist,
+ leavelist,
+ element,
+ node,
+ nodeType,
+ ret,
+ key,
+ current,
+ current2,
+ candidates,
+ candidate,
+ sentinel;
+
+ this.__initialize(root, visitor);
+
+ sentinel = {};
+
+ // reference
+ worklist = this.__worklist;
+ leavelist = this.__leavelist;
+
+ // initialize
+ worklist.push(new Element(root, null, null, null));
+ leavelist.push(new Element(null, null, null, null));
+
+ while (worklist.length) {
+ element = worklist.pop();
+
+ if (element === sentinel) {
+ element = leavelist.pop();
+
+ ret = this.__execute(visitor.leave, element);
+
+ if (this.__state === BREAK || ret === BREAK) {
+ return;
+ }
+ continue;
+ }
+
+ if (element.node) {
+
+ ret = this.__execute(visitor.enter, element);
+
+ if (this.__state === BREAK || ret === BREAK) {
+ return;
+ }
+
+ worklist.push(sentinel);
+ leavelist.push(element);
+
+ if (this.__state === SKIP || ret === SKIP) {
+ continue;
+ }
+
+ node = element.node;
+ nodeType = node.type || element.wrap;
+ candidates = this.__keys[nodeType];
+ if (!candidates) {
+ if (this.__fallback) {
+ candidates = this.__fallback(node);
+ } else {
+ throw new Error('Unknown node type ' + nodeType + '.');
+ }
+ }
+
+ current = candidates.length;
+ while ((current -= 1) >= 0) {
+ key = candidates[current];
+ candidate = node[key];
+ if (!candidate) {
+ continue;
+ }
+
+ if (Array.isArray(candidate)) {
+ current2 = candidate.length;
+ while ((current2 -= 1) >= 0) {
+ if (!candidate[current2]) {
+ continue;
+ }
+ if (isProperty(nodeType, candidates[current])) {
+ element = new Element(candidate[current2], [key, current2], 'Property', null);
+ } else if (isNode(candidate[current2])) {
+ element = new Element(candidate[current2], [key, current2], null, null);
+ } else {
+ continue;
+ }
+ worklist.push(element);
+ }
+ } else if (isNode(candidate)) {
+ worklist.push(new Element(candidate, key, null, null));
+ }
+ }
+ }
+ }
+ };
+
+ Controller.prototype.replace = function replace(root, visitor) {
+ var worklist,
+ leavelist,
+ node,
+ nodeType,
+ target,
+ element,
+ current,
+ current2,
+ candidates,
+ candidate,
+ sentinel,
+ outer,
+ key;
+
+ function removeElem(element) {
+ var i,
+ key,
+ nextElem,
+ parent;
+
+ if (element.ref.remove()) {
+ // When the reference is an element of an array.
+ key = element.ref.key;
+ parent = element.ref.parent;
+
+ // If removed from array, then decrease following items' keys.
+ i = worklist.length;
+ while (i--) {
+ nextElem = worklist[i];
+ if (nextElem.ref && nextElem.ref.parent === parent) {
+ if (nextElem.ref.key < key) {
+ break;
+ }
+ --nextElem.ref.key;
+ }
+ }
+ }
+ }
+
+ this.__initialize(root, visitor);
+
+ sentinel = {};
+
+ // reference
+ worklist = this.__worklist;
+ leavelist = this.__leavelist;
+
+ // initialize
+ outer = {
+ root: root
+ };
+ element = new Element(root, null, null, new Reference(outer, 'root'));
+ worklist.push(element);
+ leavelist.push(element);
+
+ while (worklist.length) {
+ element = worklist.pop();
+
+ if (element === sentinel) {
+ element = leavelist.pop();
+
+ target = this.__execute(visitor.leave, element);
+
+ // node may be replaced with null,
+ // so distinguish between undefined and null in this place
+ if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
+ // replace
+ element.ref.replace(target);
+ }
+
+ if (this.__state === REMOVE || target === REMOVE) {
+ removeElem(element);
+ }
+
+ if (this.__state === BREAK || target === BREAK) {
+ return outer.root;
+ }
+ continue;
+ }
+
+ target = this.__execute(visitor.enter, element);
+
+ // node may be replaced with null,
+ // so distinguish between undefined and null in this place
+ if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
+ // replace
+ element.ref.replace(target);
+ element.node = target;
+ }
+
+ if (this.__state === REMOVE || target === REMOVE) {
+ removeElem(element);
+ element.node = null;
+ }
+
+ if (this.__state === BREAK || target === BREAK) {
+ return outer.root;
+ }
+
+ // node may be null
+ node = element.node;
+ if (!node) {
+ continue;
+ }
+
+ worklist.push(sentinel);
+ leavelist.push(element);
+
+ if (this.__state === SKIP || target === SKIP) {
+ continue;
+ }
+
+ nodeType = node.type || element.wrap;
+ candidates = this.__keys[nodeType];
+ if (!candidates) {
+ if (this.__fallback) {
+ candidates = this.__fallback(node);
+ } else {
+ throw new Error('Unknown node type ' + nodeType + '.');
+ }
+ }
+
+ current = candidates.length;
+ while ((current -= 1) >= 0) {
+ key = candidates[current];
+ candidate = node[key];
+ if (!candidate) {
+ continue;
+ }
+
+ if (Array.isArray(candidate)) {
+ current2 = candidate.length;
+ while ((current2 -= 1) >= 0) {
+ if (!candidate[current2]) {
+ continue;
+ }
+ if (isProperty(nodeType, candidates[current])) {
+ element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
+ } else if (isNode(candidate[current2])) {
+ element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
+ } else {
+ continue;
+ }
+ worklist.push(element);
+ }
+ } else if (isNode(candidate)) {
+ worklist.push(new Element(candidate, key, null, new Reference(node, key)));
+ }
+ }
+ }
+
+ return outer.root;
+ };
+
+ function traverse(root, visitor) {
+ var controller = new Controller();
+ return controller.traverse(root, visitor);
+ }
+
+ function replace(root, visitor) {
+ var controller = new Controller();
+ return controller.replace(root, visitor);
+ }
+
+ function extendCommentRange(comment, tokens) {
+ var target;
+
+ target = upperBound(tokens, function search(token) {
+ return token.range[0] > comment.range[0];
+ });
+
+ comment.extendedRange = [comment.range[0], comment.range[1]];
+
+ if (target !== tokens.length) {
+ comment.extendedRange[1] = tokens[target].range[0];
+ }
+
+ target -= 1;
+ if (target >= 0) {
+ comment.extendedRange[0] = tokens[target].range[1];
+ }
+
+ return comment;
+ }
+
+ function attachComments(tree, providedComments, tokens) {
+ // At first, we should calculate extended comment ranges.
+ var comments = [], comment, len, i, cursor;
+
+ if (!tree.range) {
+ throw new Error('attachComments needs range information');
+ }
+
+ // tokens array is empty, we attach comments to tree as 'leadingComments'
+ if (!tokens.length) {
+ if (providedComments.length) {
+ for (i = 0, len = providedComments.length; i < len; i += 1) {
+ comment = deepCopy(providedComments[i]);
+ comment.extendedRange = [0, tree.range[0]];
+ comments.push(comment);
+ }
+ tree.leadingComments = comments;
+ }
+ return tree;
+ }
+
+ for (i = 0, len = providedComments.length; i < len; i += 1) {
+ comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
+ }
+
+ // This is based on John Freeman's implementation.
+ cursor = 0;
+ traverse(tree, {
+ enter: function (node) {
+ var comment;
+
+ while (cursor < comments.length) {
+ comment = comments[cursor];
+ if (comment.extendedRange[1] > node.range[0]) {
+ break;
+ }
+
+ if (comment.extendedRange[1] === node.range[0]) {
+ if (!node.leadingComments) {
+ node.leadingComments = [];
+ }
+ node.leadingComments.push(comment);
+ comments.splice(cursor, 1);
+ } else {
+ cursor += 1;
+ }
+ }
+
+ // already out of owned node
+ if (cursor === comments.length) {
+ return VisitorOption.Break;
+ }
+
+ if (comments[cursor].extendedRange[0] > node.range[1]) {
+ return VisitorOption.Skip;
+ }
+ }
+ });
+
+ cursor = 0;
+ traverse(tree, {
+ leave: function (node) {
+ var comment;
+
+ while (cursor < comments.length) {
+ comment = comments[cursor];
+ if (node.range[1] < comment.extendedRange[0]) {
+ break;
+ }
+
+ if (node.range[1] === comment.extendedRange[0]) {
+ if (!node.trailingComments) {
+ node.trailingComments = [];
+ }
+ node.trailingComments.push(comment);
+ comments.splice(cursor, 1);
+ } else {
+ cursor += 1;
+ }
+ }
+
+ // already out of owned node
+ if (cursor === comments.length) {
+ return VisitorOption.Break;
+ }
+
+ if (comments[cursor].extendedRange[0] > node.range[1]) {
+ return VisitorOption.Skip;
+ }
+ }
+ });
+
+ return tree;
+ }
+
+ exports.Syntax = Syntax;
+ exports.traverse = traverse;
+ exports.replace = replace;
+ exports.attachComments = attachComments;
+ exports.VisitorKeys = VisitorKeys;
+ exports.VisitorOption = VisitorOption;
+ exports.Controller = Controller;
+ exports.cloneEnvironment = function () { return clone({}); };
+
+ return exports;
+}(exports));
+/* vim: set sw=4 ts=4 et tw=80 : */
diff --git a/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/package.json b/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/package.json
new file mode 100644
index 00000000000000..f4cce047d0fcff
--- /dev/null
+++ b/tools/node_modules/eslint/node_modules/esquery/node_modules/estraverse/package.json
@@ -0,0 +1,45 @@
+{
+ "bugs": {
+ "url": "https://github.com/estools/estraverse/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "ECMAScript JS AST traversal functions",
+ "devDependencies": {
+ "babel-preset-env": "^1.6.1",
+ "babel-register": "^6.3.13",
+ "chai": "^2.1.1",
+ "espree": "^1.11.0",
+ "gulp": "^3.8.10",
+ "gulp-bump": "^0.2.2",
+ "gulp-filter": "^2.0.0",
+ "gulp-git": "^1.0.1",
+ "gulp-tag-version": "^1.3.0",
+ "jshint": "^2.5.6",
+ "mocha": "^2.1.0"
+ },
+ "engines": {
+ "node": ">=4.0"
+ },
+ "homepage": "https://github.com/estools/estraverse",
+ "license": "BSD-2-Clause",
+ "main": "estraverse.js",
+ "maintainers": [
+ {
+ "name": "Yusuke Suzuki",
+ "email": "utatane.tea@gmail.com",
+ "url": "http://github.com/Constellation"
+ }
+ ],
+ "name": "estraverse",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/estools/estraverse.git"
+ },
+ "scripts": {
+ "lint": "jshint estraverse.js",
+ "test": "npm run-script lint && npm run-script unit-test",
+ "unit-test": "mocha --compilers js:babel-register"
+ },
+ "version": "5.0.0"
+}
\ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/esquery/package.json b/tools/node_modules/eslint/node_modules/esquery/package.json
index 0c7beea2c592e9..8d19ba044293b0 100644
--- a/tools/node_modules/eslint/node_modules/esquery/package.json
+++ b/tools/node_modules/eslint/node_modules/esquery/package.json
@@ -4,30 +4,40 @@
"email": "jrfeenst+esquery@gmail.com"
},
"bugs": {
- "url": "https://github.com/jrfeenst/esquery/issues"
+ "url": "https://github.com/estools/esquery/issues"
},
"bundleDependencies": false,
+ "contributors": [],
"dependencies": {
- "estraverse": "^4.0.0"
+ "estraverse": "^5.0.0"
},
"deprecated": false,
"description": "A query library for ECMAScript AST using a CSS selector like query language.",
"devDependencies": {
- "commonjs-everywhere": "~0.9.4",
- "esprima": "~1.1.1",
- "jstestr": ">=0.4",
- "pegjs": "~0.7.0"
+ "@rollup/plugin-commonjs": "^11.0.2",
+ "@rollup/plugin-json": "^4.0.2",
+ "@rollup/plugin-node-resolve": "^7.1.1",
+ "chai": "^4.2.0",
+ "eslint": "^6.8.0",
+ "esm": "^3.2.25",
+ "esprima": "~4.0.1",
+ "mocha": "^7.1.1",
+ "nyc": "^15.0.0",
+ "pegjs": "~0.10.0",
+ "rollup": "^1.32.0",
+ "rollup-plugin-terser": "^5.2.0"
},
"engines": {
- "node": ">=0.6"
+ "node": ">=8.0"
},
"files": [
- "esquery.js",
+ "dist/*.js",
+ "dist/*.map",
"parser.js",
"license.txt",
"README.md"
],
- "homepage": "https://github.com/jrfeenst/esquery#readme",
+ "homepage": "https://github.com/estools/esquery/",
"keywords": [
"ast",
"ecmascript",
@@ -35,15 +45,37 @@
"query"
],
"license": "BSD-3-Clause",
- "main": "esquery.js",
+ "main": "dist/esquery.min.js",
+ "module": "dist/esquery.esm.min.js",
"name": "esquery",
- "preferGlobal": false,
+ "nyc": {
+ "branches": 100,
+ "lines": 100,
+ "functions": 100,
+ "statements": 100,
+ "reporter": [
+ "html",
+ "text"
+ ],
+ "exclude": [
+ "parser.js",
+ "dist",
+ "tests"
+ ]
+ },
"repository": {
"type": "git",
- "url": "git+https://github.com/jrfeenst/esquery.git"
+ "url": "git+https://github.com/estools/esquery.git"
},
"scripts": {
- "test": "node node_modules/jstestr/bin/jstestr.js path=tests"
+ "build": "npm run build:parser && npm run build:browser",
+ "build:browser": "rollup -c",
+ "build:parser": "rm parser.js && pegjs --cache --format umd -o \"parser.js\" \"grammar.pegjs\"",
+ "lint": "eslint .",
+ "mocha": "mocha --require chai/register-assert --require esm tests",
+ "prepublishOnly": "npm run build && npm test",
+ "test": "nyc npm run mocha && npm run lint",
+ "test:ci": "npm run mocha"
},
- "version": "1.1.0"
+ "version": "1.2.0"
}
\ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/esquery/parser.js b/tools/node_modules/eslint/node_modules/esquery/parser.js
index b7cd714ae8e55e..ef8bf10a44e4a3 100644
--- a/tools/node_modules/eslint/node_modules/esquery/parser.js
+++ b/tools/node_modules/eslint/node_modules/esquery/parser.js
@@ -1,718 +1,947 @@
-var result = (function(){
- /*
- * Generated by PEG.js 0.7.0.
- *
- * http://pegjs.majda.cz/
- */
-
- function quote(s) {
- /*
- * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
- * string literal except for the closing quote character, backslash,
- * carriage return, line separator, paragraph separator, and line feed.
- * Any character may appear in the form of an escape sequence.
- *
- * For portability, we also escape escape all control and non-ASCII
- * characters. Note that "\0" and "\v" escape sequences are not used
- * because JSHint does not like the first and IE the second.
- */
- return '"' + s
- .replace(/\\/g, '\\\\') // backslash
- .replace(/"/g, '\\"') // closing quote character
- .replace(/\x08/g, '\\b') // backspace
- .replace(/\t/g, '\\t') // horizontal tab
- .replace(/\n/g, '\\n') // line feed
- .replace(/\f/g, '\\f') // form feed
- .replace(/\r/g, '\\r') // carriage return
- .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape)
- + '"';
+/*
+ * 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();
}
-
- var result = {
- /*
- * Parses the input with a generated parser. If the parsing is successful,
- * returns a value explicitly or implicitly specified by the grammar from
- * which the parser was generated (see |PEG.buildParser|). If the parsing is
- * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
- */
- parse: function(input, startRule) {
- var parseFunctions = {
- "start": parse_start,
- "_": parse__,
- "identifierName": parse_identifierName,
- "binaryOp": parse_binaryOp,
- "selectors": parse_selectors,
- "selector": parse_selector,
- "sequence": parse_sequence,
- "atom": parse_atom,
- "wildcard": parse_wildcard,
- "identifier": parse_identifier,
- "attr": parse_attr,
- "attrOps": parse_attrOps,
- "attrEqOps": parse_attrEqOps,
- "attrName": parse_attrName,
- "attrValue": parse_attrValue,
- "string": parse_string,
- "number": parse_number,
- "path": parse_path,
- "type": parse_type,
- "regex": parse_regex,
- "field": parse_field,
- "negation": parse_negation,
- "matches": parse_matches,
- "has": parse_has,
- "firstChild": parse_firstChild,
- "lastChild": parse_lastChild,
- "nthChild": parse_nthChild,
- "nthLastChild": parse_nthLastChild,
- "class": parse_class
- };
-
- if (startRule !== undefined) {
- if (parseFunctions[startRule] === undefined) {
- throw new Error("Invalid rule name: " + quote(startRule) + ".");
+})(this, function() {
+ "use strict";
+
+ function peg$subclass(child, parent) {
+ function ctor() { this.constructor = child; }
+ ctor.prototype = parent.prototype;
+ child.prototype = new ctor();
+ }
+
+ function peg$SyntaxError(message, expected, found, location) {
+ this.message = message;
+ this.expected = expected;
+ this.found = found;
+ this.location = location;
+ this.name = "SyntaxError";
+
+ if (typeof Error.captureStackTrace === "function") {
+ Error.captureStackTrace(this, peg$SyntaxError);
+ }
+ }
+
+ peg$subclass(peg$SyntaxError, Error);
+
+ peg$SyntaxError.buildMessage = function(expected, found) {
+ var DESCRIBE_EXPECTATION_FNS = {
+ literal: function(expectation) {
+ return "\"" + literalEscape(expectation.text) + "\"";
+ },
+
+ "class": function(expectation) {
+ var escapedParts = "",
+ i;
+
+ for (i = 0; i < expectation.parts.length; i++) {
+ escapedParts += expectation.parts[i] instanceof Array
+ ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
+ : classEscape(expectation.parts[i]);
+ }
+
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
+ },
+
+ any: function(expectation) {
+ return "any character";
+ },
+
+ end: function(expectation) {
+ return "end of input";
+ },
+
+ other: function(expectation) {
+ return expectation.description;
+ }
+ };
+
+ function hex(ch) {
+ return ch.charCodeAt(0).toString(16).toUpperCase();
+ }
+
+ function literalEscape(s) {
+ return s
+ .replace(/\\/g, '\\\\')
+ .replace(/"/g, '\\"')
+ .replace(/\0/g, '\\0')
+ .replace(/\t/g, '\\t')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r')
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
+ }
+
+ function classEscape(s) {
+ return s
+ .replace(/\\/g, '\\\\')
+ .replace(/\]/g, '\\]')
+ .replace(/\^/g, '\\^')
+ .replace(/-/g, '\\-')
+ .replace(/\0/g, '\\0')
+ .replace(/\t/g, '\\t')
+ .replace(/\n/g, '\\n')
+ .replace(/\r/g, '\\r')
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
+ }
+
+ function describeExpectation(expectation) {
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
+ }
+
+ function describeExpected(expected) {
+ var descriptions = new Array(expected.length),
+ i, j;
+
+ for (i = 0; i < expected.length; i++) {
+ descriptions[i] = describeExpectation(expected[i]);
+ }
+
+ descriptions.sort();
+
+ if (descriptions.length > 0) {
+ for (i = 1, j = 1; i < descriptions.length; i++) {
+ if (descriptions[i - 1] !== descriptions[i]) {
+ descriptions[j] = descriptions[i];
+ j++;
+ }
}
+ descriptions.length = j;
+ }
+
+ switch (descriptions.length) {
+ case 1:
+ return descriptions[0];
+
+ case 2:
+ return descriptions[0] + " or " + descriptions[1];
+
+ default:
+ return descriptions.slice(0, -1).join(", ")
+ + ", or "
+ + descriptions[descriptions.length - 1];
+ }
+ }
+
+ function describeFound(found) {
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
+ }
+
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
+ };
+
+ function peg$parse(input, options) {
+ options = options !== void 0 ? options : {};
+
+ var peg$FAILED = {},
+
+ peg$startRuleFunctions = { start: peg$parsestart },
+ peg$startRuleFunction = peg$parsestart,
+
+ peg$c0 = function(ss) {
+ return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss };
+ },
+ peg$c1 = function() { return void 0; },
+ peg$c2 = " ",
+ peg$c3 = peg$literalExpectation(" ", false),
+ peg$c4 = /^[^ [\],():#!=><~+.]/,
+ peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false),
+ peg$c6 = function(i) { return i.join(''); },
+ peg$c7 = ">",
+ peg$c8 = peg$literalExpectation(">", false),
+ peg$c9 = function() { return 'child'; },
+ peg$c10 = "~",
+ peg$c11 = peg$literalExpectation("~", false),
+ peg$c12 = function() { return 'sibling'; },
+ peg$c13 = "+",
+ peg$c14 = peg$literalExpectation("+", false),
+ peg$c15 = function() { return 'adjacent'; },
+ peg$c16 = function() { return 'descendant'; },
+ peg$c17 = ",",
+ peg$c18 = peg$literalExpectation(",", false),
+ peg$c19 = function(s, ss) {
+ return [s].concat(ss.map(function (s) { return s[3]; }));
+ },
+ peg$c20 = function(a, ops) {
+ return ops.reduce(function (memo, rhs) {
+ return { type: rhs[0], left: memo, right: rhs[1] };
+ }, a);
+ },
+ peg$c21 = "!",
+ peg$c22 = peg$literalExpectation("!", false),
+ peg$c23 = function(subject, as) {
+ const b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
+ if(subject) b.subject = true;
+ return b;
+ },
+ peg$c24 = "*",
+ peg$c25 = peg$literalExpectation("*", false),
+ peg$c26 = function(a) { return { type: 'wildcard', value: a }; },
+ peg$c27 = "#",
+ peg$c28 = peg$literalExpectation("#", false),
+ peg$c29 = function(i) { return { type: 'identifier', value: i }; },
+ peg$c30 = "[",
+ peg$c31 = peg$literalExpectation("[", false),
+ peg$c32 = "]",
+ peg$c33 = peg$literalExpectation("]", false),
+ peg$c34 = function(v) { return v; },
+ peg$c35 = /^[>", "<", "!"], false, false),
+ peg$c37 = "=",
+ peg$c38 = peg$literalExpectation("=", false),
+ peg$c39 = function(a) { return (a || '') + '='; },
+ peg$c40 = /^[><]/,
+ peg$c41 = peg$classExpectation([">", "<"], false, false),
+ peg$c42 = ".",
+ peg$c43 = peg$literalExpectation(".", false),
+ peg$c44 = function(name, op, value) {
+ return { type: 'attribute', name: name, operator: op, value: value };
+ },
+ peg$c45 = function(name) { return { type: 'attribute', name: name }; },
+ peg$c46 = "\"",
+ peg$c47 = peg$literalExpectation("\"", false),
+ peg$c48 = /^[^\\"]/,
+ peg$c49 = peg$classExpectation(["\\", "\""], true, false),
+ peg$c50 = "\\",
+ peg$c51 = peg$literalExpectation("\\", false),
+ peg$c52 = peg$anyExpectation(),
+ peg$c53 = function(a, b) { return a + b; },
+ peg$c54 = function(d) {
+ return { type: 'literal', value: strUnescape(d.join('')) };
+ },
+ peg$c55 = "'",
+ peg$c56 = peg$literalExpectation("'", false),
+ peg$c57 = /^[^\\']/,
+ peg$c58 = peg$classExpectation(["\\", "'"], true, false),
+ peg$c59 = /^[0-9]/,
+ peg$c60 = peg$classExpectation([["0", "9"]], false, false),
+ peg$c61 = function(a, b) {
+ // Can use `a.flat().join('')` once supported
+ const leadingDecimals = a ? [].concat.apply([], a).join('') : '';
+ return { type: 'literal', value: parseFloat(leadingDecimals + b.join('')) };
+ },
+ peg$c62 = function(i) { return { type: 'literal', value: i }; },
+ peg$c63 = "type(",
+ peg$c64 = peg$literalExpectation("type(", false),
+ peg$c65 = /^[^ )]/,
+ peg$c66 = peg$classExpectation([" ", ")"], true, false),
+ peg$c67 = ")",
+ peg$c68 = peg$literalExpectation(")", false),
+ peg$c69 = function(t) { return { type: 'type', value: t.join('') }; },
+ peg$c70 = /^[imsu]/,
+ peg$c71 = peg$classExpectation(["i", "m", "s", "u"], false, false),
+ peg$c72 = "/",
+ peg$c73 = peg$literalExpectation("/", false),
+ peg$c74 = /^[^\/]/,
+ peg$c75 = peg$classExpectation(["/"], true, false),
+ peg$c76 = function(d, flgs) { return {
+ type: 'regexp', value: new RegExp(d.join(''), flgs ? flgs.join('') : '') };
+ },
+ peg$c77 = function(i, is) {
+ return { type: 'field', name: is.reduce(function(memo, p){ return memo + p[0] + p[1]; }, i)};
+ },
+ peg$c78 = ":not(",
+ peg$c79 = peg$literalExpectation(":not(", false),
+ peg$c80 = function(ss) { return { type: 'not', selectors: ss }; },
+ peg$c81 = ":matches(",
+ peg$c82 = peg$literalExpectation(":matches(", false),
+ peg$c83 = function(ss) { return { type: 'matches', selectors: ss }; },
+ peg$c84 = ":has(",
+ peg$c85 = peg$literalExpectation(":has(", false),
+ peg$c86 = function(ss) { return { type: 'has', selectors: ss }; },
+ peg$c87 = ":first-child",
+ peg$c88 = peg$literalExpectation(":first-child", false),
+ peg$c89 = function() { return nth(1); },
+ peg$c90 = ":last-child",
+ peg$c91 = peg$literalExpectation(":last-child", false),
+ peg$c92 = function() { return nthLast(1); },
+ peg$c93 = ":nth-child(",
+ peg$c94 = peg$literalExpectation(":nth-child(", false),
+ peg$c95 = function(n) { return nth(parseInt(n.join(''), 10)); },
+ peg$c96 = ":nth-last-child(",
+ peg$c97 = peg$literalExpectation(":nth-last-child(", false),
+ peg$c98 = function(n) { return nthLast(parseInt(n.join(''), 10)); },
+ peg$c99 = ":",
+ peg$c100 = peg$literalExpectation(":", false),
+ peg$c101 = "statement",
+ peg$c102 = peg$literalExpectation("statement", true),
+ peg$c103 = "expression",
+ peg$c104 = peg$literalExpectation("expression", true),
+ peg$c105 = "declaration",
+ peg$c106 = peg$literalExpectation("declaration", true),
+ peg$c107 = "function",
+ peg$c108 = peg$literalExpectation("function", true),
+ peg$c109 = "pattern",
+ peg$c110 = peg$literalExpectation("pattern", true),
+ peg$c111 = function(c) {
+ return { type: 'class', name: c };
+ },
+
+ peg$currPos = 0,
+ peg$savedPos = 0,
+ peg$posDetailsCache = [{ line: 1, column: 1 }],
+ peg$maxFailPos = 0,
+ peg$maxFailExpected = [],
+ peg$silentFails = 0,
+
+ peg$resultsCache = {},
+
+ 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 {
- 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;
- } else {
- escapeChar = 'u';
- length = 4;
+ 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++;
}
-
- return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
+
+ peg$posDetailsCache[pos] = details;
+ return details;
}
-
- 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];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
+ }
+
+ 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
}
-
- var result0, result1, result2;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse__();
- if (result0 !== null) {
- result1 = parse_selectors();
- if (result1 !== null) {
- result2 = parse__();
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
+ };
+ }
+
+ 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;
+
+ var key = peg$currPos * 30 + 0,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseselectors();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c0(s2);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 !== null) {
- result0 = (function(offset, ss) { return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss }; })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- result0 = parse__();
- if (result0 !== null) {
- result0 = (function(offset) { return void 0; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse__() {
- var cacheKey = "_@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
-
- result0 = [];
- if (input.charCodeAt(pos) === 32) {
- result1 = " ";
- pos++;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c1();
+ }
+ s0 = s1;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parse_() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 1,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = [];
+ if (input.charCodeAt(peg$currPos) === 32) {
+ s1 = peg$c2;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c3); }
+ }
+ while (s1 !== peg$FAILED) {
+ s0.push(s1);
+ if (input.charCodeAt(peg$currPos) === 32) {
+ s1 = peg$c2;
+ peg$currPos++;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\" \"");
- }
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c3); }
}
- while (result1 !== null) {
- result0.push(result1);
- if (input.charCodeAt(pos) === 32) {
- result1 = " ";
- pos++;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseidentifierName() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 2,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = [];
+ if (peg$c4.test(input.charAt(peg$currPos))) {
+ s2 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c5); }
+ }
+ if (s2 !== peg$FAILED) {
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ if (peg$c4.test(input.charAt(peg$currPos))) {
+ s2 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\" \"");
- }
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_identifierName() {
- var cacheKey = "identifierName@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0;
-
- pos0 = pos;
- if (/^[^ [\],():#!=><~+.]/.test(input.charAt(pos))) {
- result1 = input.charAt(pos);
- pos++;
+ } else {
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c6(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsebinaryOp() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 3,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 62) {
+ s2 = peg$c7;
+ peg$currPos++;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("[^ [\\],():#!=><~+.]");
- }
- }
- if (result1 !== null) {
- result0 = [];
- while (result1 !== null) {
- result0.push(result1);
- if (/^[^ [\],():#!=><~+.]/.test(input.charAt(pos))) {
- result1 = input.charAt(pos);
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("[^ [\\],():#!=><~+.]");
- }
- }
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c8); }
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c9();
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- }
- if (result0 !== null) {
- result0 = (function(offset, i) { return i.join(''); })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_binaryOp() {
- var cacheKey = "binaryOp@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse__();
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 62) {
- result1 = ">";
- pos++;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 126) {
+ s2 = peg$c10;
+ peg$currPos++;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\">\"");
- }
- }
- if (result1 !== null) {
- result2 = parse__();
- if (result2 !== null) {
- result0 = [result0, result1, result2];
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c11); }
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c12();
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset) { return 'child'; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- result0 = parse__();
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 126) {
- result1 = "~";
- pos++;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$parse_();
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 43) {
+ s2 = peg$c13;
+ peg$currPos++;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"~\"");
- }
- }
- if (result1 !== null) {
- result2 = parse__();
- if (result2 !== null) {
- result0 = [result0, result1, result2];
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c14); }
+ }
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parse_();
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c15();
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset) { return 'sibling'; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- result0 = parse__();
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 43) {
- result1 = "+";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"+\"");
- }
- }
- if (result1 !== null) {
- result2 = parse__();
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 32) {
+ s1 = peg$c2;
+ peg$currPos++;
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset) { return 'adjacent'; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 32) {
- result0 = " ";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\" \"");
- }
- }
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c3); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c16();
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset) { return 'descendant'; })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
}
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_selectors() {
- var cacheKey = "selectors@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4, result5;
- var pos0, pos1, pos2;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse_selector();
- if (result0 !== null) {
- result1 = [];
- pos2 = pos;
- result2 = parse__();
- if (result2 !== null) {
- if (input.charCodeAt(pos) === 44) {
- result3 = ",";
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("\",\"");
- }
- }
- if (result3 !== null) {
- result4 = parse__();
- if (result4 !== null) {
- result5 = parse_selector();
- if (result5 !== null) {
- result2 = [result2, result3, result4, result5];
- } else {
- result2 = null;
- pos = pos2;
- }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseselectors() {
+ var s0, s1, s2, s3, s4, s5, s6, s7;
+
+ var key = peg$currPos * 30 + 4,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parseselector();
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$currPos;
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 44) {
+ s5 = peg$c17;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c18); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parse_();
+ if (s6 !== peg$FAILED) {
+ s7 = peg$parseselector();
+ if (s7 !== peg$FAILED) {
+ s4 = [s4, s5, s6, s7];
+ s3 = s4;
} else {
- result2 = null;
- pos = pos2;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
} else {
- result2 = null;
- pos = pos2;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
} else {
- result2 = null;
- pos = pos2;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
- while (result2 !== null) {
- result1.push(result2);
- pos2 = pos;
- result2 = parse__();
- if (result2 !== null) {
- if (input.charCodeAt(pos) === 44) {
- result3 = ",";
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("\",\"");
- }
- }
- if (result3 !== null) {
- result4 = parse__();
- if (result4 !== null) {
- result5 = parse_selector();
- if (result5 !== null) {
- result2 = [result2, result3, result4, result5];
- } else {
- result2 = null;
- pos = pos2;
- }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$currPos;
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 44) {
+ s5 = peg$c17;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c18); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parse_();
+ if (s6 !== peg$FAILED) {
+ s7 = peg$parseselector();
+ if (s7 !== peg$FAILED) {
+ s4 = [s4, s5, s6, s7];
+ s3 = s4;
} else {
- result2 = null;
- pos = pos2;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
} else {
- result2 = null;
- pos = pos2;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
} else {
- result2 = null;
- pos = pos2;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
- }
- if (result1 !== null) {
- result0 = [result0, result1];
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, s, ss) {
- return [s].concat(ss.map(function (s) { return s[3]; }));
- })(pos0, result0[0], result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_selector() {
- var cacheKey = "selector@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c19(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
-
- var result0, result1, result2, result3;
- var pos0, pos1, pos2;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse_sequence();
- if (result0 !== null) {
- result1 = [];
- pos2 = pos;
- result2 = parse_binaryOp();
- if (result2 !== null) {
- result3 = parse_sequence();
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos2;
- }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseselector() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 5,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parsesequence();
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$currPos;
+ s4 = peg$parsebinaryOp();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsesequence();
+ if (s5 !== peg$FAILED) {
+ s4 = [s4, s5];
+ s3 = s4;
} else {
- result2 = null;
- pos = pos2;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
- while (result2 !== null) {
- result1.push(result2);
- pos2 = pos;
- result2 = parse_binaryOp();
- if (result2 !== null) {
- result3 = parse_sequence();
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos2;
- }
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$currPos;
+ s4 = peg$parsebinaryOp();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsesequence();
+ if (s5 !== peg$FAILED) {
+ s4 = [s4, s5];
+ s3 = s4;
} else {
- result2 = null;
- pos = pos2;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
- }
- if (result1 !== null) {
- result0 = [result0, result1];
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, a, ops) {
- return ops.reduce(function (memo, rhs) {
- return { type: rhs[0], left: memo, right: rhs[1] };
- }, a);
- })(pos0, result0[0], result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_sequence() {
- var cacheKey = "sequence@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 33) {
- result0 = "!";
- pos++;
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c20(s1, s2);
+ s0 = s1;
} else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"!\"");
- }
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- result0 = result0 !== null ? result0 : "";
- if (result0 !== null) {
- result2 = parse_atom();
- if (result2 !== null) {
- result1 = [];
- while (result2 !== null) {
- result1.push(result2);
- result2 = parse_atom();
- }
- } else {
- result1 = null;
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsesequence() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 6,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 33) {
+ s1 = peg$c21;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c22); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ s3 = peg$parseatom();
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ s3 = peg$parseatom();
}
} else {
- result0 = null;
- pos = pos1;
+ s2 = peg$FAILED;
}
- if (result0 !== null) {
- result0 = (function(offset, subject, as) {
- var b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
- if(subject) b.subject = true;
- return b;
- })(pos0, result0[0], result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_atom() {
- var cacheKey = "atom@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c23(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
-
- var result0;
-
- result0 = parse_wildcard();
- if (result0 === null) {
- result0 = parse_identifier();
- if (result0 === null) {
- result0 = parse_attr();
- if (result0 === null) {
- result0 = parse_field();
- if (result0 === null) {
- result0 = parse_negation();
- if (result0 === null) {
- result0 = parse_matches();
- if (result0 === null) {
- result0 = parse_has();
- if (result0 === null) {
- result0 = parse_firstChild();
- if (result0 === null) {
- result0 = parse_lastChild();
- if (result0 === null) {
- result0 = parse_nthChild();
- if (result0 === null) {
- result0 = parse_nthLastChild();
- if (result0 === null) {
- result0 = parse_class();
- }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseatom() {
+ var s0;
+
+ var key = peg$currPos * 30 + 7,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$parsewildcard();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseidentifier();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseattr();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsefield();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsenegation();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsematches();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsehas();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsefirstChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parselastChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsenthChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parsenthLastChild();
+ if (s0 === peg$FAILED) {
+ s0 = peg$parseclass();
}
}
}
@@ -723,1951 +952,1621 @@ var result = (function(){
}
}
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_wildcard() {
- var cacheKey = "wildcard@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0;
- var pos0;
-
- pos0 = pos;
- if (input.charCodeAt(pos) === 42) {
- result0 = "*";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"*\"");
- }
- }
- if (result0 !== null) {
- result0 = (function(offset, a) { return { type: 'wildcard', value: a }; })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_identifier() {
- var cacheKey = "identifier@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 35) {
- result0 = "#";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"#\"");
- }
- }
- result0 = result0 !== null ? result0 : "";
- if (result0 !== null) {
- result1 = parse_identifierName();
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, i) { return { type: 'identifier', value: i }; })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attr() {
- var cacheKey = "attr@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 91) {
- result0 = "[";
- pos++;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsewildcard() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 8,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 42) {
+ s1 = peg$c24;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c25); }
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c26(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseidentifier() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 9,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 35) {
+ s1 = peg$c27;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c28); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseidentifierName();
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c29(s2);
+ s0 = s1;
} else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"[\"");
- }
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_attrValue();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 93) {
- result4 = "]";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\"]\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattr() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 10,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 91) {
+ s1 = peg$c30;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c31); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseattrValue();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 93) {
+ s5 = peg$c32;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c33); }
+ }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c34(s3);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, v) { return v; })(pos0, result0[2]);
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attrOps() {
- var cacheKey = "attrOps@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (/^[><]/.test(input.charAt(pos))) {
- result0 = input.charAt(pos);
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("[><]");
- }
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attrEqOps() {
- var cacheKey = "attrEqOps@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
-
- var result0, result1;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 33) {
- result0 = "!";
- pos++;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ if (peg$c40.test(input.charAt(peg$currPos))) {
+ s0 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"!\"");
- }
+ s0 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c41); }
}
- result0 = result0 !== null ? result0 : "";
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 61) {
- result1 = "=";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"=\"");
- }
- }
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrEqOps() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 12,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 33) {
+ s1 = peg$c21;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c22); }
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 61) {
+ s2 = peg$c37;
+ peg$currPos++;
} else {
- result0 = null;
- pos = pos1;
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c38); }
}
- if (result0 !== null) {
- result0 = (function(offset, a) { return a + '='; })(pos0, result0[0]);
- }
- if (result0 === null) {
- pos = pos0;
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c39(s1);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attrName() {
- var cacheKey = "attrName@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrName() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 13,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = [];
+ s2 = peg$parseidentifierName();
+ if (s2 === peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s2 = peg$c42;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c43); }
}
-
- var result0, result1;
- var pos0;
-
- pos0 = pos;
- result1 = parse_identifierName();
- if (result1 === null) {
- if (input.charCodeAt(pos) === 46) {
- result1 = ".";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
+ }
+ if (s2 !== peg$FAILED) {
+ while (s2 !== peg$FAILED) {
+ s1.push(s2);
+ s2 = peg$parseidentifierName();
+ if (s2 === peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s2 = peg$c42;
+ peg$currPos++;
+ } else {
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c43); }
}
}
}
- if (result1 !== null) {
- result0 = [];
- while (result1 !== null) {
- result0.push(result1);
- result1 = parse_identifierName();
- if (result1 === null) {
- if (input.charCodeAt(pos) === 46) {
- result1 = ".";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
+ } else {
+ s1 = peg$FAILED;
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c6(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseattrValue() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 14,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parseattrName();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseattrEqOps();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsetype();
+ if (s5 === peg$FAILED) {
+ s5 = peg$parseregex();
}
- }
- }
- } else {
- result0 = null;
- }
- if (result0 !== null) {
- result0 = (function(offset, i) { return i.join(''); })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_attrValue() {
- var cacheKey = "attrValue@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- result0 = parse_attrName();
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_attrEqOps();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- result4 = parse_type();
- if (result4 === null) {
- result4 = parse_regex();
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c44(s1, s3, s5);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 !== null) {
- result0 = (function(offset, name, op, value) {
- return { type: 'attribute', name: name, operator: op, value: value };
- })(pos0, result0[0], result0[2], result0[4]);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- result0 = parse_attrName();
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_attrOps();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- result4 = parse_string();
- if (result4 === null) {
- result4 = parse_number();
- if (result4 === null) {
- result4 = parse_path();
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$parseattrName();
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseattrOps();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ s5 = peg$parsestring();
+ if (s5 === peg$FAILED) {
+ s5 = peg$parsenumber();
+ if (s5 === peg$FAILED) {
+ s5 = peg$parsepath();
}
+ }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c44(s1, s3, s5);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, name, op, value) {
- return { type: 'attribute', name: name, operator: op, value: value };
- })(pos0, result0[0], result0[2], result0[4]);
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- result0 = parse_attrName();
- if (result0 !== null) {
- result0 = (function(offset, name) { return { type: 'attribute', name: name }; })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
- }
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_string() {
- var cacheKey = "string@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- 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) {
- result0 = "\"";
- pos++;
} else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\"\"");
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ s1 = peg$parseattrName();
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c45(s1);
}
+ s0 = s1;
}
- if (result0 !== null) {
- result1 = [];
- if (/^[^\\"]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsestring() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 15,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 34) {
+ s1 = peg$c46;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c47); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c48.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c49); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
} else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\\\\"]");
- }
- }
- if (result2 === null) {
- pos2 = pos;
- pos3 = pos;
- if (input.charCodeAt(pos) === 92) {
- result2 = "\\";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
- }
- }
- if (result2 !== null) {
- if (input.length > pos) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos3;
- }
- } else {
- result2 = null;
- pos = pos3;
- }
- if (result2 !== null) {
- result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
- }
- if (result2 === null) {
- pos = pos2;
- }
- }
- while (result2 !== null) {
- result1.push(result2);
- if (/^[^\\"]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\\\\"]");
- }
- }
- if (result2 === null) {
- pos2 = pos;
- pos3 = pos;
- if (input.charCodeAt(pos) === 92) {
- result2 = "\\";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
- }
- }
- if (result2 !== null) {
- if (input.length > pos) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos3;
- }
- } else {
- result2 = null;
- pos = pos3;
- }
- if (result2 !== null) {
- result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
- }
- if (result2 === null) {
- pos = pos2;
- }
- }
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
- if (result1 !== null) {
- if (input.charCodeAt(pos) === 34) {
- result2 = "\"";
- pos++;
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\"\"");
- }
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c52); }
}
- if (result2 !== null) {
- result0 = [result0, result1, result2];
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s3;
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
- } else {
- result0 = null;
- pos = pos1;
}
- if (result0 !== null) {
- result0 = (function(offset, d) {
- return { type: 'literal', value: strUnescape(d.join('')) };
- })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
- if (result0 === null) {
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 39) {
- result0 = "'";
- pos++;
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c48.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"'\"");
- }
- }
- if (result0 !== null) {
- result1 = [];
- if (/^[^\\']/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c49); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
} else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\\\']");
- }
- }
- if (result2 === null) {
- pos2 = pos;
- pos3 = pos;
- if (input.charCodeAt(pos) === 92) {
- result2 = "\\";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
- }
- }
- if (result2 !== null) {
- if (input.length > pos) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos3;
- }
- } else {
- result2 = null;
- pos = pos3;
- }
- if (result2 !== null) {
- result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
- }
- if (result2 === null) {
- pos = pos2;
- }
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
- while (result2 !== null) {
- result1.push(result2);
- if (/^[^\\']/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\\\']");
- }
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c52); }
}
- if (result2 === null) {
- pos2 = pos;
- pos3 = pos;
- if (input.charCodeAt(pos) === 92) {
- result2 = "\\";
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"\\\\\"");
- }
- }
- if (result2 !== null) {
- if (input.length > pos) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("any character");
- }
- }
- if (result3 !== null) {
- result2 = [result2, result3];
- } else {
- result2 = null;
- pos = pos3;
- }
- } else {
- result2 = null;
- pos = pos3;
- }
- if (result2 !== null) {
- result2 = (function(offset, a, b) { return a + b; })(pos2, result2[0], result2[1]);
- }
- if (result2 === null) {
- pos = pos2;
- }
- }
- }
- if (result1 !== null) {
- if (input.charCodeAt(pos) === 39) {
- result2 = "'";
- pos++;
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s3;
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
} else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"'\"");
- }
- }
- if (result2 !== null) {
- result0 = [result0, result1, result2];
- } else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, d) {
- return { type: 'literal', value: strUnescape(d.join('')) };
- })(pos0, result0[1]);
}
- if (result0 === null) {
- pos = pos0;
- }
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_number() {
- var cacheKey = "number@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
}
-
- var result0, result1, result2;
- var pos0, pos1, pos2;
-
- pos0 = pos;
- pos1 = pos;
- pos2 = pos;
- result0 = [];
- if (/^[0-9]/.test(input.charAt(pos))) {
- result1 = input.charAt(pos);
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
- while (result1 !== null) {
- result0.push(result1);
- if (/^[0-9]/.test(input.charAt(pos))) {
- result1 = input.charAt(pos);
- pos++;
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 34) {
+ s3 = peg$c46;
+ peg$currPos++;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c47); }
}
- }
- if (result0 !== null) {
- if (input.charCodeAt(pos) === 46) {
- result1 = ".";
- pos++;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
- }
- if (result1 !== null) {
- result0 = [result0, result1];
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c54(s2);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos2;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos2;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- result0 = result0 !== null ? result0 : "";
- if (result0 !== null) {
- if (/^[0-9]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ if (s0 === peg$FAILED) {
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 39) {
+ s1 = peg$c55;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c56); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c57.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c58); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
- }
- if (result2 !== null) {
- result1 = [];
- while (result2 !== null) {
- result1.push(result2);
- if (/^[0-9]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c52); }
+ }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s3;
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
+ } else {
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
- } else {
- result1 = null;
}
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, a, b) {
- return { type: 'literal', value: parseFloat((a ? a.join('') : '') + b.join('')) };
- })(pos0, result0[0], result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_path() {
- var cacheKey = "path@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0;
- var pos0;
-
- pos0 = pos;
- result0 = parse_identifierName();
- if (result0 !== null) {
- result0 = (function(offset, i) { return { type: 'literal', value: i }; })(pos0, result0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_type() {
- var cacheKey = "type@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- 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(") {
- result0 = "type(";
- pos += 5;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"type(\"");
- }
- }
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- if (/^[^ )]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c57.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[^ )]");
- }
- }
- if (result3 !== null) {
- result2 = [];
- while (result3 !== null) {
- result2.push(result3);
- if (/^[^ )]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[^ )]");
- }
- }
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c58); }
+ }
+ if (s3 === peg$FAILED) {
+ s3 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 92) {
+ s4 = peg$c50;
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c51); }
}
- } else {
- result2 = null;
- }
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
+ if (s4 !== peg$FAILED) {
+ if (input.length > peg$currPos) {
+ s5 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c52); }
}
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s3;
+ s4 = peg$c53(s4, s5);
+ s3 = s4;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, t) { return { type: 'type', value: t.join('') }; })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_regex() {
- var cacheKey = "regex@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 47) {
- result0 = "/";
- pos++;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\"/\"");
- }
- }
- if (result0 !== null) {
- if (/^[^\/]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\/]");
- }
- }
- if (result2 !== null) {
- result1 = [];
- while (result2 !== null) {
- result1.push(result2);
- if (/^[^\/]/.test(input.charAt(pos))) {
- result2 = input.charAt(pos);
- pos++;
- } else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("[^\\/]");
- }
+ peg$currPos = s3;
+ s3 = peg$FAILED;
}
}
- } else {
- result1 = null;
}
- if (result1 !== null) {
- if (input.charCodeAt(pos) === 47) {
- result2 = "/";
- pos++;
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 39) {
+ s3 = peg$c55;
+ peg$currPos++;
} else {
- result2 = null;
- if (reportFailures === 0) {
- matchFailed("\"/\"");
- }
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c56); }
}
- if (result2 !== null) {
- result0 = [result0, result1, result2];
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c54(s2);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 !== null) {
- result0 = (function(offset, d) { return { type: 'regexp', value: new RegExp(d.join('')) }; })(pos0, result0[1]);
- }
- if (result0 === null) {
- pos = pos0;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenumber() {
+ var s0, s1, s2, s3;
+
+ var key = peg$currPos * 30 + 16,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$currPos;
+ s2 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
+ }
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_field() {
- var cacheKey = "field@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
+ }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s3 = peg$c42;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c43); }
}
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1, pos2;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 46) {
- result0 = ".";
- pos++;
+ if (s3 !== peg$FAILED) {
+ s2 = [s2, s3];
+ s1 = s2;
} else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
+ peg$currPos = s1;
+ s1 = peg$FAILED;
}
- if (result0 !== null) {
- result1 = parse_identifierName();
- if (result1 !== null) {
- result2 = [];
- pos2 = pos;
- if (input.charCodeAt(pos) === 46) {
- result3 = ".";
- pos++;
+ } else {
+ peg$currPos = s1;
+ s1 = peg$FAILED;
+ }
+ if (s1 === peg$FAILED) {
+ s1 = null;
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
+ }
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
}
- if (result3 !== null) {
- result4 = parse_identifierName();
- if (result4 !== null) {
- result3 = [result3, result4];
+ }
+ } else {
+ s2 = peg$FAILED;
+ }
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c61(s1, s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsepath() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 17,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ s1 = peg$parseidentifierName();
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c62(s1);
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsetype() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 18,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 5) === peg$c63) {
+ s1 = peg$c63;
+ peg$currPos += 5;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c64); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ if (peg$c65.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c66); }
+ }
+ if (s4 !== peg$FAILED) {
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ if (peg$c65.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result3 = null;
- pos = pos2;
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c66); }
}
- } else {
- result3 = null;
- pos = pos2;
}
- while (result3 !== null) {
- result2.push(result3);
- pos2 = pos;
- if (input.charCodeAt(pos) === 46) {
- result3 = ".";
- pos++;
+ } else {
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
} else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("\".\"");
- }
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c68); }
}
- if (result3 !== null) {
- result4 = parse_identifierName();
- if (result4 !== null) {
- result3 = [result3, result4];
- } else {
- result3 = null;
- pos = pos2;
- }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c69(s3);
+ s0 = s1;
} else {
- result3 = null;
- pos = pos2;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- }
- if (result2 !== null) {
- result0 = [result0, result1, result2];
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, i, is) {
- return { type: 'field', name: is.reduce(function(memo, p){ return memo + p[0] + p[1]; }, i)};
- })(pos0, result0[1], result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_negation() {
- var cacheKey = "negation@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseflags() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 19,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = [];
+ if (peg$c70.test(input.charAt(peg$currPos))) {
+ s1 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c71); }
+ }
+ if (s1 !== peg$FAILED) {
+ while (s1 !== peg$FAILED) {
+ s0.push(s1);
+ if (peg$c70.test(input.charAt(peg$currPos))) {
+ s1 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c71); }
+ }
}
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.substr(pos, 5) === ":not(") {
- result0 = ":not(";
- pos += 5;
+ } else {
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseregex() {
+ var s0, s1, s2, s3, s4;
+
+ var key = peg$currPos * 30 + 20,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 47) {
+ s1 = peg$c72;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c73); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = [];
+ if (peg$c74.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
} else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":not(\"");
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c75); }
+ }
+ if (s3 !== peg$FAILED) {
+ while (s3 !== peg$FAILED) {
+ s2.push(s3);
+ if (peg$c74.test(input.charAt(peg$currPos))) {
+ s3 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c75); }
+ }
}
+ } else {
+ s2 = peg$FAILED;
}
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_selectors();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
+ if (s2 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 47) {
+ s3 = peg$c72;
+ peg$currPos++;
+ } else {
+ s3 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c73); }
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parseflags();
+ if (s4 === peg$FAILED) {
+ s4 = null;
+ }
+ if (s4 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c76(s2, s4);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, ss) { return { type: 'not', selectors: ss }; })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_matches() {
- var cacheKey = "matches@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- 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(") {
- result0 = ":matches(";
- pos += 9;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":matches(\"");
- }
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_selectors();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsefield() {
+ var s0, s1, s2, s3, s4, s5, s6;
+
+ var key = peg$currPos * 30 + 21,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s1 = peg$c42;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c43); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parseidentifierName();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ s4 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s5 = peg$c42;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c43); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parseidentifierName();
+ if (s6 !== peg$FAILED) {
+ s5 = [s5, s6];
+ s4 = s5;
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s4;
+ s4 = peg$FAILED;
+ }
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ s4 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 46) {
+ s5 = peg$c42;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c43); }
+ }
+ if (s5 !== peg$FAILED) {
+ s6 = peg$parseidentifierName();
+ if (s6 !== peg$FAILED) {
+ s5 = [s5, s6];
+ s4 = s5;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s4;
+ s4 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s4;
+ s4 = peg$FAILED;
}
+ }
+ if (s3 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c77(s2, s3);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, ss) { return { type: 'matches', selectors: ss }; })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_has() {
- var cacheKey = "has@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1, result2, result3, result4;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.substr(pos, 5) === ":has(") {
- result0 = ":has(";
- pos += 5;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":has(\"");
- }
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- result2 = parse_selectors();
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenegation() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 22,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 5) === peg$c78) {
+ s1 = peg$c78;
+ peg$currPos += 5;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c79); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseselectors();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c80(s3);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 !== null) {
- result0 = (function(offset, ss) { return { type: 'has', selectors: ss }; })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_firstChild() {
- var cacheKey = "firstChild@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0;
- var pos0;
-
- pos0 = pos;
- if (input.substr(pos, 12) === ":first-child") {
- result0 = ":first-child";
- pos += 12;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":first-child\"");
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsematches() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 23,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 9) === peg$c81) {
+ s1 = peg$c81;
+ peg$currPos += 9;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c82); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseselectors();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c83(s3);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- }
- if (result0 !== null) {
- result0 = (function(offset) { return nth(1); })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_lastChild() {
- var cacheKey = "lastChild@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0;
- var pos0;
-
- pos0 = pos;
- if (input.substr(pos, 11) === ":last-child") {
- result0 = ":last-child";
- pos += 11;
} else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":last-child\"");
- }
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 !== null) {
- result0 = (function(offset) { return nthLast(1); })(pos0);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_nthChild() {
- var cacheKey = "nthChild@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- 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(") {
- result0 = ":nth-child(";
- pos += 11;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":nth-child(\"");
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsehas() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 24,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 5) === peg$c84) {
+ s1 = peg$c84;
+ peg$currPos += 5;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c85); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = peg$parseselectors();
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c68); }
+ }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c86(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;
}
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- if (/^[0-9]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsefirstChild() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 25,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 12) === peg$c87) {
+ s1 = peg$c87;
+ peg$currPos += 12;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c88); }
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c89();
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parselastChild() {
+ var s0, s1;
+
+ var key = peg$currPos * 30 + 26,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 11) === peg$c90) {
+ s1 = peg$c90;
+ peg$currPos += 11;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c91); }
+ }
+ if (s1 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c92();
+ }
+ s0 = s1;
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenthChild() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 27,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 11) === peg$c93) {
+ s1 = peg$c93;
+ peg$currPos += 11;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c94); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
+ }
+ if (s4 !== peg$FAILED) {
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
}
}
- if (result3 !== null) {
- result2 = [];
- while (result3 !== null) {
- result2.push(result3);
- if (/^[0-9]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
+ } else {
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c68); }
}
- } else {
- result2 = null;
- }
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c95(s3);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, n) { return nth(parseInt(n.join(''), 10)); })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
- }
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_nthLastChild() {
- var cacheKey = "nthLastChild@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- 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(") {
- result0 = ":nth-last-child(";
- pos += 16;
- } else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":nth-last-child(\"");
- }
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
- if (result0 !== null) {
- result1 = parse__();
- if (result1 !== null) {
- if (/^[0-9]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parsenthLastChild() {
+ var s0, s1, s2, s3, s4, s5;
+
+ var key = peg$currPos * 30 + 28,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.substr(peg$currPos, 16) === peg$c96) {
+ s1 = peg$c96;
+ peg$currPos += 16;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c97); }
+ }
+ if (s1 !== peg$FAILED) {
+ s2 = peg$parse_();
+ if (s2 !== peg$FAILED) {
+ s3 = [];
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
+ }
+ if (s4 !== peg$FAILED) {
+ while (s4 !== peg$FAILED) {
+ s3.push(s4);
+ if (peg$c59.test(input.charAt(peg$currPos))) {
+ s4 = input.charAt(peg$currPos);
+ peg$currPos++;
+ } else {
+ s4 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
}
}
- if (result3 !== null) {
- result2 = [];
- while (result3 !== null) {
- result2.push(result3);
- if (/^[0-9]/.test(input.charAt(pos))) {
- result3 = input.charAt(pos);
- pos++;
- } else {
- result3 = null;
- if (reportFailures === 0) {
- matchFailed("[0-9]");
- }
- }
+ } else {
+ s3 = peg$FAILED;
+ }
+ if (s3 !== peg$FAILED) {
+ s4 = peg$parse_();
+ if (s4 !== peg$FAILED) {
+ if (input.charCodeAt(peg$currPos) === 41) {
+ s5 = peg$c67;
+ peg$currPos++;
+ } else {
+ s5 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c68); }
}
- } else {
- result2 = null;
- }
- if (result2 !== null) {
- result3 = parse__();
- if (result3 !== null) {
- if (input.charCodeAt(pos) === 41) {
- result4 = ")";
- pos++;
- } else {
- result4 = null;
- if (reportFailures === 0) {
- matchFailed("\")\"");
- }
- }
- if (result4 !== null) {
- result0 = [result0, result1, result2, result3, result4];
- } else {
- result0 = null;
- pos = pos1;
- }
+ if (s5 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c98(s3);
+ s0 = s1;
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
} else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, n) { return nthLast(parseInt(n.join(''), 10)); })(pos0, result0[2]);
- }
- if (result0 === null) {
- pos = pos0;
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
-
- cache[cacheKey] = {
- nextPos: pos,
- result: result0
- };
- return result0;
- }
-
- function parse_class() {
- var cacheKey = "class@" + pos;
- var cachedResult = cache[cacheKey];
- if (cachedResult) {
- pos = cachedResult.nextPos;
- return cachedResult.result;
- }
-
- var result0, result1;
- var pos0, pos1;
-
- pos0 = pos;
- pos1 = pos;
- if (input.charCodeAt(pos) === 58) {
- result0 = ":";
- pos++;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
+ }
+
+ function peg$parseclass() {
+ var s0, s1, s2;
+
+ var key = peg$currPos * 30 + 29,
+ cached = peg$resultsCache[key];
+
+ if (cached) {
+ peg$currPos = cached.nextPos;
+
+ return cached.result;
+ }
+
+ s0 = peg$currPos;
+ if (input.charCodeAt(peg$currPos) === 58) {
+ s1 = peg$c99;
+ peg$currPos++;
+ } else {
+ s1 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c100); }
+ }
+ if (s1 !== peg$FAILED) {
+ if (input.substr(peg$currPos, 9).toLowerCase() === peg$c101) {
+ s2 = input.substr(peg$currPos, 9);
+ peg$currPos += 9;
} else {
- result0 = null;
- if (reportFailures === 0) {
- matchFailed("\":\"");
- }
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c102); }
}
- if (result0 !== null) {
- if (input.substr(pos, 9).toLowerCase() === "statement") {
- result1 = input.substr(pos, 9);
- pos += 9;
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 10).toLowerCase() === peg$c103) {
+ s2 = input.substr(peg$currPos, 10);
+ peg$currPos += 10;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"statement\"");
- }
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c104); }
}
- if (result1 === null) {
- if (input.substr(pos, 10).toLowerCase() === "expression") {
- result1 = input.substr(pos, 10);
- pos += 10;
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 11).toLowerCase() === peg$c105) {
+ s2 = input.substr(peg$currPos, 11);
+ peg$currPos += 11;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"expression\"");
- }
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c106); }
}
- if (result1 === null) {
- if (input.substr(pos, 11).toLowerCase() === "declaration") {
- result1 = input.substr(pos, 11);
- pos += 11;
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 8).toLowerCase() === peg$c107) {
+ s2 = input.substr(peg$currPos, 8);
+ peg$currPos += 8;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"declaration\"");
- }
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c108); }
}
- if (result1 === null) {
- if (input.substr(pos, 8).toLowerCase() === "function") {
- result1 = input.substr(pos, 8);
- pos += 8;
+ if (s2 === peg$FAILED) {
+ if (input.substr(peg$currPos, 7).toLowerCase() === peg$c109) {
+ s2 = input.substr(peg$currPos, 7);
+ peg$currPos += 7;
} else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"function\"");
- }
- }
- if (result1 === null) {
- if (input.substr(pos, 7).toLowerCase() === "pattern") {
- result1 = input.substr(pos, 7);
- pos += 7;
- } else {
- result1 = null;
- if (reportFailures === 0) {
- matchFailed("\"pattern\"");
- }
- }
+ s2 = peg$FAILED;
+ if (peg$silentFails === 0) { peg$fail(peg$c110); }
}
}
}
}
- if (result1 !== null) {
- result0 = [result0, result1];
- } else {
- result0 = null;
- pos = pos1;
- }
- } else {
- result0 = null;
- pos = pos1;
- }
- if (result0 !== null) {
- result0 = (function(offset, c) {
- return { type: 'class', name: c };
- })(pos0, result0[1]);
- }
- 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++) {
- if (expected[i] !== lastExpected) {
- cleanExpected.push(expected[i]);
- lastExpected = expected[i];
- }
- }
- return cleanExpected;
- }
-
- function computeErrorPosition() {
- /*
- * The first idea was to use |String.split| to break the input up to the
- * error position along newlines and derive the line and column from
- * 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") {
- if (!seenCR) { line++; }
- column = 1;
- seenCR = false;
- } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
- line++;
- column = 1;
- seenCR = true;
- } else {
- column++;
- 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) {
- return s.replace(/\\(.)/g, function(match, ch) {
- switch(ch) {
- case 'a': return '\a';
- case 'b': return '\b';
- case 'f': return '\f';
- case 'n': return '\n';
- case 'r': return '\r';
- case 't': return '\t';
- case 'v': return '\v';
- default: return ch;
- }
- });
+ if (s2 !== peg$FAILED) {
+ peg$savedPos = s0;
+ s1 = peg$c111(s2);
+ s0 = s1;
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
}
-
-
- var result = parseFunctions[startRule]();
-
- /*
- * The parser is now in one of the following three states:
- *
- * 1. The parser successfully parsed the whole input.
- *
- * - |result !== null|
- * - |pos === input.length|
- * - |rightmostFailuresExpected| may or may not contain something
- *
- * 2. The parser successfully parsed only a part of the input.
- *
- * - |result !== null|
- * - |pos < input.length|
- * - |rightmostFailuresExpected| may or may not contain something
- *
- * 3. The parser did not successfully parse any part of the input.
- *
- * - |result === null|
- * - |pos === 0|
- * - |rightmostFailuresExpected| contains at least one failure
- *
- * All code following this comment (including called functions) must
- * handle these states.
- */
- if (result === null || pos !== input.length) {
- 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,
- offset,
- errorPosition.line,
- 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";
- break;
- case 1:
- expectedHumanized = expected[0];
- break;
- default:
- expectedHumanized = expected.slice(0, expected.length - 1).join(", ")
- + " or "
- + expected[expected.length - 1];
- }
-
- foundHumanized = found ? quote(found) : "end of input";
-
- return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";
+ } else {
+ peg$currPos = s0;
+ s0 = peg$FAILED;
+ }
+
+ peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
+
+ return s0;
}
-
- this.name = "SyntaxError";
- this.expected = expected;
- this.found = found;
- this.message = buildMessage(expected, found);
- this.offset = offset;
- this.line = line;
- this.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) {
+ return s.replace(/\\(.)/g, function(match, ch) {
+ switch(ch) {
+ case 'b': return '\b';
+ case 'f': return '\f';
+ case 'n': return '\n';
+ case 'r': return '\r';
+ case 't': return '\t';
+ case 'v': return '\v';
+ default: return ch;
+ }
+ });
+ }
+
+
+ peg$result = peg$startRuleFunction();
+
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
+ return peg$result;
+ } else {
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
+ peg$fail(peg$endExpectation());
+ }
+
+ 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: peg$SyntaxError,
+ parse: peg$parse
};
-
- 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; }
+});
diff --git a/tools/node_modules/eslint/node_modules/glob-parent/index.js b/tools/node_modules/eslint/node_modules/glob-parent/index.js
index 2ded6ea7e63ba0..789dbbf2ff09ef 100644
--- a/tools/node_modules/eslint/node_modules/glob-parent/index.js
+++ b/tools/node_modules/eslint/node_modules/glob-parent/index.js
@@ -8,7 +8,7 @@ var slash = '/';
var backslash = /\\/g;
var enclosure = /[\{\[].*[\/]*.*[\}\]]$/;
var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
-var escaped = /\\([\*\?\|\[\]\(\)\{\}])/g;
+var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
/**
* @param {string} str
diff --git a/tools/node_modules/eslint/node_modules/glob-parent/package.json b/tools/node_modules/eslint/node_modules/glob-parent/package.json
index af850b522587b3..4d6f2f6dd4bf4b 100644
--- a/tools/node_modules/eslint/node_modules/glob-parent/package.json
+++ b/tools/node_modules/eslint/node_modules/glob-parent/package.json
@@ -24,7 +24,7 @@
"deprecated": false,
"description": "Extract the non-magic parent path from a glob string.",
"devDependencies": {
- "coveralls": "github:phated/node-coveralls#2.x",
+ "coveralls": "^3.0.11",
"eslint": "^2.13.1",
"eslint-config-gulp": "^3.0.1",
"expect": "^1.20.2",
@@ -63,5 +63,5 @@
"pretest": "npm run lint",
"test": "nyc mocha --async-only"
},
- "version": "5.1.0"
+ "version": "5.1.1"
}
\ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/globals/globals.json b/tools/node_modules/eslint/node_modules/globals/globals.json
index b33f0431b544e9..b85dc3f80d5148 100644
--- a/tools/node_modules/eslint/node_modules/globals/globals.json
+++ b/tools/node_modules/eslint/node_modules/globals/globals.json
@@ -1027,6 +1027,24 @@
"URL": false,
"URLSearchParams": false
},
+ "nodeBuiltin": {
+ "Buffer": false,
+ "clearImmediate": false,
+ "clearInterval": false,
+ "clearTimeout": false,
+ "console": false,
+ "global": false,
+ "Intl": false,
+ "process": false,
+ "queueMicrotask": false,
+ "setImmediate": false,
+ "setInterval": false,
+ "setTimeout": false,
+ "TextDecoder": false,
+ "TextEncoder": false,
+ "URL": false,
+ "URLSearchParams": false
+ },
"commonjs": {
"exports": true,
"global": false,
diff --git a/tools/node_modules/eslint/node_modules/globals/license b/tools/node_modules/eslint/node_modules/globals/license
index e7af2f77107d73..fa7ceba3eb4a96 100644
--- a/tools/node_modules/eslint/node_modules/globals/license
+++ b/tools/node_modules/eslint/node_modules/globals/license
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) Sindre Sorhus (sindresorhus.com)
+Copyright (c) Sindre Sorhus (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
diff --git a/tools/node_modules/eslint/node_modules/globals/package.json b/tools/node_modules/eslint/node_modules/globals/package.json
index de6b8926f166d9..66435a6834e8f4 100644
--- a/tools/node_modules/eslint/node_modules/globals/package.json
+++ b/tools/node_modules/eslint/node_modules/globals/package.json
@@ -2,7 +2,7 @@
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
+ "url": "https://sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/globals/issues"
@@ -26,6 +26,7 @@
"index.d.ts",
"globals.json"
],
+ "funding": "https://github.com/sponsors/sindresorhus",
"homepage": "https://github.com/sindresorhus/globals#readme",
"keywords": [
"globals",
@@ -51,7 +52,7 @@
"resolveJsonModule": true
}
},
- "version": "12.3.0",
+ "version": "12.4.0",
"xo": {
"ignores": [
"get-browser-globals.js"
diff --git a/tools/node_modules/eslint/node_modules/globals/readme.md b/tools/node_modules/eslint/node_modules/globals/readme.md
index 96ce28347a8de0..fdcfa087ab1107 100644
--- a/tools/node_modules/eslint/node_modules/globals/readme.md
+++ b/tools/node_modules/eslint/node_modules/globals/readme.md
@@ -8,14 +8,12 @@ It's just a [JSON file](globals.json), so use it in whatever environment you lik
**This module [no longer accepts](https://github.com/sindresorhus/globals/issues/82) new environments. If you need it for ESLint, just [create a plugin](http://eslint.org/docs/developer-guide/working-with-plugins#environments-in-plugins).**
-
## Install
```
$ npm install globals
```
-
## Usage
```js
@@ -28,13 +26,22 @@ console.log(globals.browser);
applicationCache: false,
ArrayBuffer: false,
atob: false,
- ...
+ …
}
*/
```
Each global is given a value of `true` or `false`. A value of `true` indicates that the variable may be overwritten. A value of `false` indicates that the variable should be considered read-only. This information is used by static analysis tools to flag incorrect behavior. We assume all variables should be `false` unless we hear otherwise.
+For Node.js this package provides two sets of globals:
+
+- `globals.nodeBuiltin`: Globals available to all code running in Node.js.
+ These will usually be available as properties on the `global` object and include `process`, `Buffer`, but not CommonJS arguments like `require`.
+ See: https://nodejs.org/api/globals.html
+- `globals.node`: A combination of the globals from `nodeBuiltin` plus all CommonJS arguments ("CommonJS module scope").
+ See: https://nodejs.org/api/modules.html#modules_the_module_scope
+
+When analyzing code that is known to run outside of a CommonJS wrapper, for example, JavaScript modules, `nodeBuiltin` can find accidental CommonJS references.
---
diff --git a/tools/node_modules/eslint/node_modules/inquirer/README.md b/tools/node_modules/eslint/node_modules/inquirer/README.md
index 8fb61ba6a18d62..7fa511995ea730 100644
--- a/tools/node_modules/eslint/node_modules/inquirer/README.md
+++ b/tools/node_modules/eslint/node_modules/inquirer/README.md
@@ -23,6 +23,7 @@ A collection of common interactive command line user interfaces.
2. [User Interfaces and Layouts](#layouts)
1. [Reactive Interface](#reactive)
3. [Support](#support)
+4. [Known issues](#issues)
4. [News](#news)
5. [Contributing](#contributing)
6. [License](#license)
@@ -62,6 +63,13 @@ inquirer
])
.then(answers => {
// Use user feedback for... whatever!!
+ })
+ .catch(error => {
+ if(error.isTtyError) {
+ // Prompt couldn't be rendered in the current environment
+ } else {
+ // Something else when wrong
+ }
});
```
@@ -128,6 +136,7 @@ A question object is a `hash` containing question related values:
- **pageSize**: (Number) Change the number of lines that will be rendered when using `list`, `rawList`, `expand` or `checkbox`.
- **prefix**: (String) Change the default _prefix_ message.
- **suffix**: (String) Change the default _suffix_ message.
+- **askAnswered**: (Boolean) Force to prompt the question if the answer already exists.
`default`, `choices`(if defined as functions), `validate`, `filter` and `when` functions can be called asynchronously. Either return a promise or use `this.async()` to get a callback you'll call with the final value.
@@ -283,6 +292,10 @@ Launches an instance of the users preferred editor on a temporary file. Once the
+### Use in Non-Interactive Environments
+`prompt()` requires that it is run in an interactive environment. (I.e. [One where `process.stdin.isTTY` is `true`](https://nodejs.org/docs/latest-v12.x/api/process.html#process_a_note_on_process_i_o)). If `prompt()` is invoked outside of such an environment, then `prompt()` will return a rejected promise with an error. For convenience, the error will have a `isTtyError` property to programmatically indicate the cause.
+
+
## User Interfaces and layouts
Along with the prompts, Inquirer offers some basic text UI.
@@ -346,7 +359,7 @@ look at issues found on other command line - feel free to report any!
- **Mac OS**:
- Terminal.app
- iTerm
-- **Windows**:
+- **Windows ([Known issues](#issues))**:
- [ConEmu](https://conemu.github.io/)
- cmd.exe
- Powershell
@@ -355,6 +368,14 @@ look at issues found on other command line - feel free to report any!
- gnome-terminal (Terminal GNOME)
- konsole
+## Know issues
+
+
+
+Running Inquirer together with network streams in Windows platform inside some terminals can result in process hang.
+Workaround: run inside another terminal.
+Please refer to the https://github.com/nodejs/node/issues/21771
+
## News on the march (Release notes)
diff --git a/tools/node_modules/eslint/node_modules/inquirer/lib/inquirer.js b/tools/node_modules/eslint/node_modules/inquirer/lib/inquirer.js
index 820e2525c2f77c..aa8b2a17e9153d 100644
--- a/tools/node_modules/eslint/node_modules/inquirer/lib/inquirer.js
+++ b/tools/node_modules/eslint/node_modules/inquirer/lib/inquirer.js
@@ -23,9 +23,14 @@ inquirer.ui = {
* Create a new self-contained prompt module.
*/
inquirer.createPromptModule = function(opt) {
- var promptModule = function(questions) {
- var ui = new inquirer.ui.Prompt(promptModule.prompts, opt);
- var promise = ui.run(questions);
+ var promptModule = function(questions, answers) {
+ var ui;
+ try {
+ ui = new inquirer.ui.Prompt(promptModule.prompts, opt);
+ } catch (error) {
+ return Promise.reject(error);
+ }
+ var promise = ui.run(questions, answers);
// Monkey patch the UI on the promise object so
// that it remains publicly accessible.
diff --git a/tools/node_modules/eslint/node_modules/inquirer/lib/objects/choice.js b/tools/node_modules/eslint/node_modules/inquirer/lib/objects/choice.js
index 76f93293329244..1bc1acdcddac60 100644
--- a/tools/node_modules/eslint/node_modules/inquirer/lib/objects/choice.js
+++ b/tools/node_modules/eslint/node_modules/inquirer/lib/objects/choice.js
@@ -13,6 +13,7 @@ module.exports = class Choice {
constructor(val, answers) {
// Don't process Choice and Separator object
if (val instanceof Choice || val.type === 'separator') {
+ // eslint-disable-next-line no-constructor-return
return val;
}
diff --git a/tools/node_modules/eslint/node_modules/inquirer/lib/prompts/confirm.js b/tools/node_modules/eslint/node_modules/inquirer/lib/prompts/confirm.js
index ee66d9b80af08f..1ede6b8951d973 100644
--- a/tools/node_modules/eslint/node_modules/inquirer/lib/prompts/confirm.js
+++ b/tools/node_modules/eslint/node_modules/inquirer/lib/prompts/confirm.js
@@ -31,8 +31,6 @@ class ConfirmPrompt extends Base {
}
this.opt.default = rawDefault ? 'Y/n' : 'y/N';
-
- return this;
}
/**
diff --git a/tools/node_modules/eslint/node_modules/inquirer/lib/ui/baseUI.js b/tools/node_modules/eslint/node_modules/inquirer/lib/ui/baseUI.js
index 0903e9af565dba..45248eff5a9bcc 100644
--- a/tools/node_modules/eslint/node_modules/inquirer/lib/ui/baseUI.js
+++ b/tools/node_modules/eslint/node_modules/inquirer/lib/ui/baseUI.js
@@ -55,20 +55,29 @@ class UI {
// Close the readline
this.rl.output.end();
this.rl.pause();
-
- // @see https://github.com/nodejs/node/issues/21771
- if (!/^win/i.test(process.platform)) {
- this.rl.close();
- }
+ this.rl.close();
}
}
function setupReadlineOptions(opt) {
opt = opt || {};
+ // Inquirer 8.x:
+ // opt.skipTTYChecks = opt.skipTTYChecks === undefined ? opt.input !== undefined : opt.skipTTYChecks;
+ opt.skipTTYChecks = opt.skipTTYChecks === undefined ? true : opt.skipTTYChecks;
// Default `input` to stdin
var input = opt.input || process.stdin;
+ // Check if prompt is being called in TTY environment
+ // If it isn't return a failed promise
+ if (!opt.skipTTYChecks && !input.isTTY) {
+ const nonTtyError = new Error(
+ 'Prompts can not be meaningfully rendered in non-TTY environments'
+ );
+ nonTtyError.isTtyError = true;
+ throw nonTtyError;
+ }
+
// Add mute capabilities to the output
var ms = new MuteStream();
ms.pipe(opt.output || process.stdout);
diff --git a/tools/node_modules/eslint/node_modules/inquirer/lib/ui/prompt.js b/tools/node_modules/eslint/node_modules/inquirer/lib/ui/prompt.js
index bc1ee9eb86a290..9735c999f342a3 100644
--- a/tools/node_modules/eslint/node_modules/inquirer/lib/ui/prompt.js
+++ b/tools/node_modules/eslint/node_modules/inquirer/lib/ui/prompt.js
@@ -16,9 +16,13 @@ class PromptUI extends Base {
this.prompts = prompts;
}
- run(questions) {
+ run(questions, answers) {
// Keep global reference to the answers
- this.answers = {};
+ if (_.isPlainObject(answers)) {
+ this.answers = _.clone(answers);
+ } else {
+ this.answers = {};
+ }
// Make sure questions is an array.
if (_.isPlainObject(questions)) {
@@ -40,9 +44,9 @@ class PromptUI extends Base {
return this.process
.pipe(
reduce((answers, answer) => {
- _.set(this.answers, answer.name, answer.answer);
- return this.answers;
- }, {})
+ _.set(answers, answer.name, answer.answer);
+ return answers;
+ }, this.answers)
)
.toPromise(Promise)
.then(this.onCompletion.bind(this));
@@ -100,6 +104,10 @@ class PromptUI extends Base {
}
filterIfRunnable(question) {
+ if (question.askAnswered !== true && this.answers[question.name] !== undefined) {
+ return empty();
+ }
+
if (question.when === false) {
return empty();
}
diff --git a/tools/node_modules/eslint/node_modules/inquirer/node_modules/ansi-regex/index.js b/tools/node_modules/eslint/node_modules/inquirer/node_modules/ansi-regex/index.js
deleted file mode 100644
index c25448009f304d..00000000000000
--- a/tools/node_modules/eslint/node_modules/inquirer/node_modules/ansi-regex/index.js
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-module.exports = options => {
- options = Object.assign({
- onlyFirst: false
- }, options);
-
- const pattern = [
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
- ].join('|');
-
- return new RegExp(pattern, options.onlyFirst ? undefined : 'g');
-};
diff --git a/tools/node_modules/eslint/node_modules/inquirer/node_modules/ansi-regex/package.json b/tools/node_modules/eslint/node_modules/inquirer/node_modules/ansi-regex/package.json
deleted file mode 100644
index db8f3cc8c7d14e..00000000000000
--- a/tools/node_modules/eslint/node_modules/inquirer/node_modules/ansi-regex/package.json
+++ /dev/null
@@ -1,62 +0,0 @@
-{
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "bugs": {
- "url": "https://github.com/chalk/ansi-regex/issues"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "Regular expression for matching ANSI escape codes",
- "devDependencies": {
- "ava": "^0.25.0",
- "xo": "^0.23.0"
- },
- "engines": {
- "node": ">=6"
- },
- "files": [
- "index.js"
- ],
- "homepage": "https://github.com/chalk/ansi-regex#readme",
- "keywords": [
- "ansi",
- "styles",
- "color",
- "colour",
- "colors",
- "terminal",
- "console",
- "cli",
- "string",
- "tty",
- "escape",
- "formatting",
- "rgb",
- "256",
- "shell",
- "xterm",
- "command-line",
- "text",
- "regex",
- "regexp",
- "re",
- "match",
- "test",
- "find",
- "pattern"
- ],
- "license": "MIT",
- "name": "ansi-regex",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/chalk/ansi-regex.git"
- },
- "scripts": {
- "test": "xo && ava",
- "view-supported": "node fixtures/view-codes.js"
- },
- "version": "4.1.0"
-}
\ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/inquirer/node_modules/ansi-regex/readme.md b/tools/node_modules/eslint/node_modules/inquirer/node_modules/ansi-regex/readme.md
deleted file mode 100644
index d19c44667e704b..00000000000000
--- a/tools/node_modules/eslint/node_modules/inquirer/node_modules/ansi-regex/readme.md
+++ /dev/null
@@ -1,87 +0,0 @@
-# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex)
-
-> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
-
----
-
-
-
----
-
-
-## Install
-
-```
-$ npm install ansi-regex
-```
-
-
-## Usage
-
-```js
-const ansiRegex = require('ansi-regex');
-
-ansiRegex().test('\u001B[4mcake\u001B[0m');
-//=> true
-
-ansiRegex().test('cake');
-//=> false
-
-'\u001B[4mcake\u001B[0m'.match(ansiRegex());
-//=> ['\u001B[4m', '\u001B[0m']
-
-'\u001B[4mcake\u001B[0m'.match(ansiRegex({onlyFirst: true}));
-//=> ['\u001B[4m']
-
-'\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'.match(ansiRegex());
-//=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
-```
-
-
-## API
-
-### ansiRegex([options])
-
-Returns a regex for matching ANSI escape codes.
-
-#### options
-
-##### onlyFirst
-
-Type: `boolean`
-Default: `false` *(Matches any ANSI escape codes in a string)*
-
-Match only the first ANSI escape.
-
-
-## FAQ
-
-### Why do you test for codes not in the ECMA 48 standard?
-
-Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them.
-
-On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out.
-
-
-## Security
-
-To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
-
-
-## Maintainers
-
-- [Sindre Sorhus](https://github.com/sindresorhus)
-- [Josh Junon](https://github.com/qix-)
-
-
-## License
-
-MIT
diff --git a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/index.js b/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/index.js
deleted file mode 100644
index 1cc5fa89a95159..00000000000000
--- a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/index.js
+++ /dev/null
@@ -1,228 +0,0 @@
-'use strict';
-const escapeStringRegexp = require('escape-string-regexp');
-const ansiStyles = require('ansi-styles');
-const stdoutColor = require('supports-color').stdout;
-
-const template = require('./templates.js');
-
-const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
-
-// `supportsColor.level` → `ansiStyles.color[name]` mapping
-const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
-
-// `color-convert` models to exclude from the Chalk API due to conflicts and such
-const skipModels = new Set(['gray']);
-
-const styles = Object.create(null);
-
-function applyOptions(obj, options) {
- options = options || {};
-
- // Detect level if not set manually
- const scLevel = stdoutColor ? stdoutColor.level : 0;
- obj.level = options.level === undefined ? scLevel : options.level;
- obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
-}
-
-function Chalk(options) {
- // We check for this.template here since calling `chalk.constructor()`
- // by itself will have a `this` of a previously constructed chalk object
- if (!this || !(this instanceof Chalk) || this.template) {
- const chalk = {};
- applyOptions(chalk, options);
-
- chalk.template = function () {
- const args = [].slice.call(arguments);
- return chalkTag.apply(null, [chalk.template].concat(args));
- };
-
- Object.setPrototypeOf(chalk, Chalk.prototype);
- Object.setPrototypeOf(chalk.template, chalk);
-
- chalk.template.constructor = Chalk;
-
- return chalk.template;
- }
-
- applyOptions(this, options);
-}
-
-// Use bright blue on Windows as the normal blue color is illegible
-if (isSimpleWindowsTerm) {
- ansiStyles.blue.open = '\u001B[94m';
-}
-
-for (const key of Object.keys(ansiStyles)) {
- ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
-
- styles[key] = {
- get() {
- const codes = ansiStyles[key];
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
- }
- };
-}
-
-styles.visible = {
- get() {
- return build.call(this, this._styles || [], true, 'visible');
- }
-};
-
-ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
-for (const model of Object.keys(ansiStyles.color.ansi)) {
- if (skipModels.has(model)) {
- continue;
- }
-
- styles[model] = {
- get() {
- const level = this.level;
- return function () {
- const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
- const codes = {
- open,
- close: ansiStyles.color.close,
- closeRe: ansiStyles.color.closeRe
- };
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
- };
- }
- };
-}
-
-ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
-for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
- if (skipModels.has(model)) {
- continue;
- }
-
- const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
- styles[bgModel] = {
- get() {
- const level = this.level;
- return function () {
- const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
- const codes = {
- open,
- close: ansiStyles.bgColor.close,
- closeRe: ansiStyles.bgColor.closeRe
- };
- return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
- };
- }
- };
-}
-
-const proto = Object.defineProperties(() => {}, styles);
-
-function build(_styles, _empty, key) {
- const builder = function () {
- return applyStyle.apply(builder, arguments);
- };
-
- builder._styles = _styles;
- builder._empty = _empty;
-
- const self = this;
-
- Object.defineProperty(builder, 'level', {
- enumerable: true,
- get() {
- return self.level;
- },
- set(level) {
- self.level = level;
- }
- });
-
- Object.defineProperty(builder, 'enabled', {
- enumerable: true,
- get() {
- return self.enabled;
- },
- set(enabled) {
- self.enabled = enabled;
- }
- });
-
- // See below for fix regarding invisible grey/dim combination on Windows
- builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
-
- // `__proto__` is used because we must return a function, but there is
- // no way to create a function with a different prototype
- builder.__proto__ = proto; // eslint-disable-line no-proto
-
- return builder;
-}
-
-function applyStyle() {
- // Support varags, but simply cast to string in case there's only one arg
- const args = arguments;
- const argsLen = args.length;
- let str = String(arguments[0]);
-
- if (argsLen === 0) {
- return '';
- }
-
- if (argsLen > 1) {
- // Don't slice `arguments`, it prevents V8 optimizations
- for (let a = 1; a < argsLen; a++) {
- str += ' ' + args[a];
- }
- }
-
- if (!this.enabled || this.level <= 0 || !str) {
- return this._empty ? '' : str;
- }
-
- // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
- // see https://github.com/chalk/chalk/issues/58
- // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
- const originalDim = ansiStyles.dim.open;
- if (isSimpleWindowsTerm && this.hasGrey) {
- ansiStyles.dim.open = '';
- }
-
- for (const code of this._styles.slice().reverse()) {
- // Replace any instances already present with a re-opening code
- // otherwise only the part of the string until said closing code
- // will be colored, and the rest will simply be 'plain'.
- str = code.open + str.replace(code.closeRe, code.open) + code.close;
-
- // Close the styling before a linebreak and reopen
- // after next line to fix a bleed issue on macOS
- // https://github.com/chalk/chalk/pull/92
- str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
- }
-
- // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
- ansiStyles.dim.open = originalDim;
-
- return str;
-}
-
-function chalkTag(chalk, strings) {
- if (!Array.isArray(strings)) {
- // If chalk() was called by itself or with a string,
- // return the string itself as a string.
- return [].slice.call(arguments, 1).join(' ');
- }
-
- const args = [].slice.call(arguments, 2);
- const parts = [strings.raw[0]];
-
- for (let i = 1; i < strings.length; i++) {
- parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
- parts.push(String(strings.raw[i]));
- }
-
- return template(chalk, parts.join(''));
-}
-
-Object.defineProperties(Chalk.prototype, styles);
-
-module.exports = Chalk(); // eslint-disable-line new-cap
-module.exports.supportsColor = stdoutColor;
-module.exports.default = module.exports; // For TypeScript
diff --git a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/index.js.flow b/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/index.js.flow
deleted file mode 100644
index 622caaa2e803f3..00000000000000
--- a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/index.js.flow
+++ /dev/null
@@ -1,93 +0,0 @@
-// @flow strict
-
-type TemplateStringsArray = $ReadOnlyArray;
-
-export type Level = $Values<{
- None: 0,
- Basic: 1,
- Ansi256: 2,
- TrueColor: 3
-}>;
-
-export type ChalkOptions = {|
- enabled?: boolean,
- level?: Level
-|};
-
-export type ColorSupport = {|
- level: Level,
- hasBasic: boolean,
- has256: boolean,
- has16m: boolean
-|};
-
-export interface Chalk {
- (...text: string[]): string,
- (text: TemplateStringsArray, ...placeholders: string[]): string,
- constructor(options?: ChalkOptions): Chalk,
- enabled: boolean,
- level: Level,
- rgb(r: number, g: number, b: number): Chalk,
- hsl(h: number, s: number, l: number): Chalk,
- hsv(h: number, s: number, v: number): Chalk,
- hwb(h: number, w: number, b: number): Chalk,
- bgHex(color: string): Chalk,
- bgKeyword(color: string): Chalk,
- bgRgb(r: number, g: number, b: number): Chalk,
- bgHsl(h: number, s: number, l: number): Chalk,
- bgHsv(h: number, s: number, v: number): Chalk,
- bgHwb(h: number, w: number, b: number): Chalk,
- hex(color: string): Chalk,
- keyword(color: string): Chalk,
-
- +reset: Chalk,
- +bold: Chalk,
- +dim: Chalk,
- +italic: Chalk,
- +underline: Chalk,
- +inverse: Chalk,
- +hidden: Chalk,
- +strikethrough: Chalk,
-
- +visible: Chalk,
-
- +black: Chalk,
- +red: Chalk,
- +green: Chalk,
- +yellow: Chalk,
- +blue: Chalk,
- +magenta: Chalk,
- +cyan: Chalk,
- +white: Chalk,
- +gray: Chalk,
- +grey: Chalk,
- +blackBright: Chalk,
- +redBright: Chalk,
- +greenBright: Chalk,
- +yellowBright: Chalk,
- +blueBright: Chalk,
- +magentaBright: Chalk,
- +cyanBright: Chalk,
- +whiteBright: Chalk,
-
- +bgBlack: Chalk,
- +bgRed: Chalk,
- +bgGreen: Chalk,
- +bgYellow: Chalk,
- +bgBlue: Chalk,
- +bgMagenta: Chalk,
- +bgCyan: Chalk,
- +bgWhite: Chalk,
- +bgBlackBright: Chalk,
- +bgRedBright: Chalk,
- +bgGreenBright: Chalk,
- +bgYellowBright: Chalk,
- +bgBlueBright: Chalk,
- +bgMagentaBright: Chalk,
- +bgCyanBright: Chalk,
- +bgWhiteBrigh: Chalk,
-
- supportsColor: ColorSupport
-};
-
-declare module.exports: Chalk;
diff --git a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/license b/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/license
deleted file mode 100644
index e7af2f77107d73..00000000000000
--- a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/license
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT License
-
-Copyright (c) Sindre Sorhus (sindresorhus.com)
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/package.json b/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/package.json
deleted file mode 100644
index 270fecdc347d42..00000000000000
--- a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/package.json
+++ /dev/null
@@ -1,80 +0,0 @@
-{
- "bugs": {
- "url": "https://github.com/chalk/chalk/issues"
- },
- "bundleDependencies": false,
- "dependencies": {
- "ansi-styles": "^3.2.1",
- "escape-string-regexp": "^1.0.5",
- "supports-color": "^5.3.0"
- },
- "deprecated": false,
- "description": "Terminal string styling done right",
- "devDependencies": {
- "ava": "*",
- "coveralls": "^3.0.0",
- "execa": "^0.9.0",
- "flow-bin": "^0.68.0",
- "import-fresh": "^2.0.0",
- "matcha": "^0.7.0",
- "nyc": "^11.0.2",
- "resolve-from": "^4.0.0",
- "typescript": "^2.5.3",
- "xo": "*"
- },
- "engines": {
- "node": ">=4"
- },
- "files": [
- "index.js",
- "templates.js",
- "types/index.d.ts",
- "index.js.flow"
- ],
- "homepage": "https://github.com/chalk/chalk#readme",
- "keywords": [
- "color",
- "colour",
- "colors",
- "terminal",
- "console",
- "cli",
- "string",
- "str",
- "ansi",
- "style",
- "styles",
- "tty",
- "formatting",
- "rgb",
- "256",
- "shell",
- "xterm",
- "log",
- "logging",
- "command-line",
- "text"
- ],
- "license": "MIT",
- "name": "chalk",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/chalk/chalk.git"
- },
- "scripts": {
- "bench": "matcha benchmark.js",
- "coveralls": "nyc report --reporter=text-lcov | coveralls",
- "test": "xo && tsc --project types && flow --max-warnings=0 && nyc ava"
- },
- "types": "types/index.d.ts",
- "version": "2.4.2",
- "xo": {
- "envs": [
- "node",
- "mocha"
- ],
- "ignores": [
- "test/_flow.js"
- ]
- }
-}
\ No newline at end of file
diff --git a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/readme.md b/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/readme.md
deleted file mode 100644
index d298e2c48d64a0..00000000000000
--- a/tools/node_modules/eslint/node_modules/inquirer/node_modules/chalk/readme.md
+++ /dev/null
@@ -1,314 +0,0 @@
-
-
-
-
-
-
-
-
-
-> Terminal string styling done right
-
-[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![Mentioned in Awesome Node.js](https://awesome.re/mentioned-badge.svg)](https://github.com/sindresorhus/awesome-nodejs)
-
-### [See what's new in Chalk 2](https://github.com/chalk/chalk/releases/tag/v2.0.0)
-
-
-
-
-## Highlights
-
-- Expressive API
-- Highly performant
-- Ability to nest styles
-- [256/Truecolor color support](#256-and-truecolor-color-support)
-- Auto-detects color support
-- Doesn't extend `String.prototype`
-- Clean and focused
-- Actively maintained
-- [Used by ~23,000 packages](https://www.npmjs.com/browse/depended/chalk) as of December 31, 2017
-
-
-## Install
-
-```console
-$ npm install chalk
-```
-
-
-
-
-
-
-## Usage
-
-```js
-const chalk = require('chalk');
-
-console.log(chalk.blue('Hello world!'));
-```
-
-Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
-
-```js
-const chalk = require('chalk');
-const log = console.log;
-
-// Combine styled and normal strings
-log(chalk.blue('Hello') + ' World' + chalk.red('!'));
-
-// Compose multiple styles using the chainable API
-log(chalk.blue.bgRed.bold('Hello world!'));
-
-// Pass in multiple arguments
-log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
-
-// Nest styles
-log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
-
-// Nest styles of the same type even (color, underline, background)
-log(chalk.green(
- 'I am a green line ' +
- chalk.blue.underline.bold('with a blue substring') +
- ' that becomes green again!'
-));
-
-// ES2015 template literal
-log(`
-CPU: ${chalk.red('90%')}
-RAM: ${chalk.green('40%')}
-DISK: ${chalk.yellow('70%')}
-`);
-
-// ES2015 tagged template literal
-log(chalk`
-CPU: {red ${cpu.totalPercent}%}
-RAM: {green ${ram.used / ram.total * 100}%}
-DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
-`);
-
-// Use RGB colors in terminal emulators that support it.
-log(chalk.keyword('orange')('Yay for orange colored text!'));
-log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
-log(chalk.hex('#DEADED').bold('Bold gray!'));
-```
-
-Easily define your own themes:
-
-```js
-const chalk = require('chalk');
-
-const error = chalk.bold.red;
-const warning = chalk.keyword('orange');
-
-console.log(error('Error!'));
-console.log(warning('Warning!'));
-```
-
-Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
-
-```js
-const name = 'Sindre';
-console.log(chalk.green('Hello %s'), name);
-//=> 'Hello Sindre'
-```
-
-
-## API
-
-### chalk.`