| [9af201e] | 1 | (function (global, factory) {
|
|---|
| 2 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|---|
| 3 | typeof define === 'function' && define.amd ? define(factory) :
|
|---|
| 4 | (global = global || self, global.esquery = factory());
|
|---|
| 5 | }(this, (function () { 'use strict';
|
|---|
| 6 |
|
|---|
| 7 | function _arrayLikeToArray(r, a) {
|
|---|
| 8 | (null == a || a > r.length) && (a = r.length);
|
|---|
| 9 | for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|---|
| 10 | return n;
|
|---|
| 11 | }
|
|---|
| 12 | function _arrayWithHoles(r) {
|
|---|
| 13 | if (Array.isArray(r)) return r;
|
|---|
| 14 | }
|
|---|
| 15 | function _arrayWithoutHoles(r) {
|
|---|
| 16 | if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|---|
| 17 | }
|
|---|
| 18 | function _iterableToArray(r) {
|
|---|
| 19 | if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|---|
| 20 | }
|
|---|
| 21 | function _iterableToArrayLimit(r, l) {
|
|---|
| 22 | var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|---|
| 23 | if (null != t) {
|
|---|
| 24 | var e,
|
|---|
| 25 | n,
|
|---|
| 26 | i,
|
|---|
| 27 | u,
|
|---|
| 28 | a = [],
|
|---|
| 29 | f = !0,
|
|---|
| 30 | o = !1;
|
|---|
| 31 | try {
|
|---|
| 32 | if (i = (t = t.call(r)).next, 0 === l) {
|
|---|
| 33 | if (Object(t) !== t) return;
|
|---|
| 34 | f = !1;
|
|---|
| 35 | } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|---|
| 36 | } catch (r) {
|
|---|
| 37 | o = !0, n = r;
|
|---|
| 38 | } finally {
|
|---|
| 39 | try {
|
|---|
| 40 | if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|---|
| 41 | } finally {
|
|---|
| 42 | if (o) throw n;
|
|---|
| 43 | }
|
|---|
| 44 | }
|
|---|
| 45 | return a;
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|
| 48 | function _nonIterableRest() {
|
|---|
| 49 | throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|---|
| 50 | }
|
|---|
| 51 | function _nonIterableSpread() {
|
|---|
| 52 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|---|
| 53 | }
|
|---|
| 54 | function _slicedToArray(r, e) {
|
|---|
| 55 | return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|---|
| 56 | }
|
|---|
| 57 | function _toConsumableArray(r) {
|
|---|
| 58 | return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|---|
| 59 | }
|
|---|
| 60 | function _typeof(o) {
|
|---|
| 61 | "@babel/helpers - typeof";
|
|---|
| 62 |
|
|---|
| 63 | return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|---|
| 64 | return typeof o;
|
|---|
| 65 | } : function (o) {
|
|---|
| 66 | return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|---|
| 67 | }, _typeof(o);
|
|---|
| 68 | }
|
|---|
| 69 | function _unsupportedIterableToArray(r, a) {
|
|---|
| 70 | if (r) {
|
|---|
| 71 | if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|---|
| 72 | var t = {}.toString.call(r).slice(8, -1);
|
|---|
| 73 | return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|---|
| 74 | }
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|---|
| 78 |
|
|---|
| 79 | function createCommonjsModule(fn, module) {
|
|---|
| 80 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | var estraverse = createCommonjsModule(function (module, exports) {
|
|---|
| 84 | /*
|
|---|
| 85 | Copyright (C) 2012-2013 Yusuke Suzuki <utatane.tea@gmail.com>
|
|---|
| 86 | Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
|
|---|
| 87 |
|
|---|
| 88 | Redistribution and use in source and binary forms, with or without
|
|---|
| 89 | modification, are permitted provided that the following conditions are met:
|
|---|
| 90 |
|
|---|
| 91 | * Redistributions of source code must retain the above copyright
|
|---|
| 92 | notice, this list of conditions and the following disclaimer.
|
|---|
| 93 | * Redistributions in binary form must reproduce the above copyright
|
|---|
| 94 | notice, this list of conditions and the following disclaimer in the
|
|---|
| 95 | documentation and/or other materials provided with the distribution.
|
|---|
| 96 |
|
|---|
| 97 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|---|
| 98 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|---|
| 99 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|---|
| 100 | ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
|---|
| 101 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|---|
| 102 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|---|
| 103 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|---|
| 104 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 105 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 106 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 107 | */
|
|---|
| 108 | /*jslint vars:false, bitwise:true*/
|
|---|
| 109 | /*jshint indent:4*/
|
|---|
| 110 | /*global exports:true*/
|
|---|
| 111 | (function clone(exports) {
|
|---|
| 112 |
|
|---|
| 113 | var Syntax, VisitorOption, VisitorKeys, BREAK, SKIP, REMOVE;
|
|---|
| 114 | function deepCopy(obj) {
|
|---|
| 115 | var ret = {},
|
|---|
| 116 | key,
|
|---|
| 117 | val;
|
|---|
| 118 | for (key in obj) {
|
|---|
| 119 | if (obj.hasOwnProperty(key)) {
|
|---|
| 120 | val = obj[key];
|
|---|
| 121 | if (typeof val === 'object' && val !== null) {
|
|---|
| 122 | ret[key] = deepCopy(val);
|
|---|
| 123 | } else {
|
|---|
| 124 | ret[key] = val;
|
|---|
| 125 | }
|
|---|
| 126 | }
|
|---|
| 127 | }
|
|---|
| 128 | return ret;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | // based on LLVM libc++ upper_bound / lower_bound
|
|---|
| 132 | // MIT License
|
|---|
| 133 |
|
|---|
| 134 | function upperBound(array, func) {
|
|---|
| 135 | var diff, len, i, current;
|
|---|
| 136 | len = array.length;
|
|---|
| 137 | i = 0;
|
|---|
| 138 | while (len) {
|
|---|
| 139 | diff = len >>> 1;
|
|---|
| 140 | current = i + diff;
|
|---|
| 141 | if (func(array[current])) {
|
|---|
| 142 | len = diff;
|
|---|
| 143 | } else {
|
|---|
| 144 | i = current + 1;
|
|---|
| 145 | len -= diff + 1;
|
|---|
| 146 | }
|
|---|
| 147 | }
|
|---|
| 148 | return i;
|
|---|
| 149 | }
|
|---|
| 150 | Syntax = {
|
|---|
| 151 | AssignmentExpression: 'AssignmentExpression',
|
|---|
| 152 | AssignmentPattern: 'AssignmentPattern',
|
|---|
| 153 | ArrayExpression: 'ArrayExpression',
|
|---|
| 154 | ArrayPattern: 'ArrayPattern',
|
|---|
| 155 | ArrowFunctionExpression: 'ArrowFunctionExpression',
|
|---|
| 156 | AwaitExpression: 'AwaitExpression',
|
|---|
| 157 | // CAUTION: It's deferred to ES7.
|
|---|
| 158 | BlockStatement: 'BlockStatement',
|
|---|
| 159 | BinaryExpression: 'BinaryExpression',
|
|---|
| 160 | BreakStatement: 'BreakStatement',
|
|---|
| 161 | CallExpression: 'CallExpression',
|
|---|
| 162 | CatchClause: 'CatchClause',
|
|---|
| 163 | ChainExpression: 'ChainExpression',
|
|---|
| 164 | ClassBody: 'ClassBody',
|
|---|
| 165 | ClassDeclaration: 'ClassDeclaration',
|
|---|
| 166 | ClassExpression: 'ClassExpression',
|
|---|
| 167 | ComprehensionBlock: 'ComprehensionBlock',
|
|---|
| 168 | // CAUTION: It's deferred to ES7.
|
|---|
| 169 | ComprehensionExpression: 'ComprehensionExpression',
|
|---|
| 170 | // CAUTION: It's deferred to ES7.
|
|---|
| 171 | ConditionalExpression: 'ConditionalExpression',
|
|---|
| 172 | ContinueStatement: 'ContinueStatement',
|
|---|
| 173 | DebuggerStatement: 'DebuggerStatement',
|
|---|
| 174 | DirectiveStatement: 'DirectiveStatement',
|
|---|
| 175 | DoWhileStatement: 'DoWhileStatement',
|
|---|
| 176 | EmptyStatement: 'EmptyStatement',
|
|---|
| 177 | ExportAllDeclaration: 'ExportAllDeclaration',
|
|---|
| 178 | ExportDefaultDeclaration: 'ExportDefaultDeclaration',
|
|---|
| 179 | ExportNamedDeclaration: 'ExportNamedDeclaration',
|
|---|
| 180 | ExportSpecifier: 'ExportSpecifier',
|
|---|
| 181 | ExpressionStatement: 'ExpressionStatement',
|
|---|
| 182 | ForStatement: 'ForStatement',
|
|---|
| 183 | ForInStatement: 'ForInStatement',
|
|---|
| 184 | ForOfStatement: 'ForOfStatement',
|
|---|
| 185 | FunctionDeclaration: 'FunctionDeclaration',
|
|---|
| 186 | FunctionExpression: 'FunctionExpression',
|
|---|
| 187 | GeneratorExpression: 'GeneratorExpression',
|
|---|
| 188 | // CAUTION: It's deferred to ES7.
|
|---|
| 189 | Identifier: 'Identifier',
|
|---|
| 190 | IfStatement: 'IfStatement',
|
|---|
| 191 | ImportExpression: 'ImportExpression',
|
|---|
| 192 | ImportDeclaration: 'ImportDeclaration',
|
|---|
| 193 | ImportDefaultSpecifier: 'ImportDefaultSpecifier',
|
|---|
| 194 | ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
|
|---|
| 195 | ImportSpecifier: 'ImportSpecifier',
|
|---|
| 196 | Literal: 'Literal',
|
|---|
| 197 | LabeledStatement: 'LabeledStatement',
|
|---|
| 198 | LogicalExpression: 'LogicalExpression',
|
|---|
| 199 | MemberExpression: 'MemberExpression',
|
|---|
| 200 | MetaProperty: 'MetaProperty',
|
|---|
| 201 | MethodDefinition: 'MethodDefinition',
|
|---|
| 202 | ModuleSpecifier: 'ModuleSpecifier',
|
|---|
| 203 | NewExpression: 'NewExpression',
|
|---|
| 204 | ObjectExpression: 'ObjectExpression',
|
|---|
| 205 | ObjectPattern: 'ObjectPattern',
|
|---|
| 206 | PrivateIdentifier: 'PrivateIdentifier',
|
|---|
| 207 | Program: 'Program',
|
|---|
| 208 | Property: 'Property',
|
|---|
| 209 | PropertyDefinition: 'PropertyDefinition',
|
|---|
| 210 | RestElement: 'RestElement',
|
|---|
| 211 | ReturnStatement: 'ReturnStatement',
|
|---|
| 212 | SequenceExpression: 'SequenceExpression',
|
|---|
| 213 | SpreadElement: 'SpreadElement',
|
|---|
| 214 | Super: 'Super',
|
|---|
| 215 | SwitchStatement: 'SwitchStatement',
|
|---|
| 216 | SwitchCase: 'SwitchCase',
|
|---|
| 217 | TaggedTemplateExpression: 'TaggedTemplateExpression',
|
|---|
| 218 | TemplateElement: 'TemplateElement',
|
|---|
| 219 | TemplateLiteral: 'TemplateLiteral',
|
|---|
| 220 | ThisExpression: 'ThisExpression',
|
|---|
| 221 | ThrowStatement: 'ThrowStatement',
|
|---|
| 222 | TryStatement: 'TryStatement',
|
|---|
| 223 | UnaryExpression: 'UnaryExpression',
|
|---|
| 224 | UpdateExpression: 'UpdateExpression',
|
|---|
| 225 | VariableDeclaration: 'VariableDeclaration',
|
|---|
| 226 | VariableDeclarator: 'VariableDeclarator',
|
|---|
| 227 | WhileStatement: 'WhileStatement',
|
|---|
| 228 | WithStatement: 'WithStatement',
|
|---|
| 229 | YieldExpression: 'YieldExpression'
|
|---|
| 230 | };
|
|---|
| 231 | VisitorKeys = {
|
|---|
| 232 | AssignmentExpression: ['left', 'right'],
|
|---|
| 233 | AssignmentPattern: ['left', 'right'],
|
|---|
| 234 | ArrayExpression: ['elements'],
|
|---|
| 235 | ArrayPattern: ['elements'],
|
|---|
| 236 | ArrowFunctionExpression: ['params', 'body'],
|
|---|
| 237 | AwaitExpression: ['argument'],
|
|---|
| 238 | // CAUTION: It's deferred to ES7.
|
|---|
| 239 | BlockStatement: ['body'],
|
|---|
| 240 | BinaryExpression: ['left', 'right'],
|
|---|
| 241 | BreakStatement: ['label'],
|
|---|
| 242 | CallExpression: ['callee', 'arguments'],
|
|---|
| 243 | CatchClause: ['param', 'body'],
|
|---|
| 244 | ChainExpression: ['expression'],
|
|---|
| 245 | ClassBody: ['body'],
|
|---|
| 246 | ClassDeclaration: ['id', 'superClass', 'body'],
|
|---|
| 247 | ClassExpression: ['id', 'superClass', 'body'],
|
|---|
| 248 | ComprehensionBlock: ['left', 'right'],
|
|---|
| 249 | // CAUTION: It's deferred to ES7.
|
|---|
| 250 | ComprehensionExpression: ['blocks', 'filter', 'body'],
|
|---|
| 251 | // CAUTION: It's deferred to ES7.
|
|---|
| 252 | ConditionalExpression: ['test', 'consequent', 'alternate'],
|
|---|
| 253 | ContinueStatement: ['label'],
|
|---|
| 254 | DebuggerStatement: [],
|
|---|
| 255 | DirectiveStatement: [],
|
|---|
| 256 | DoWhileStatement: ['body', 'test'],
|
|---|
| 257 | EmptyStatement: [],
|
|---|
| 258 | ExportAllDeclaration: ['source'],
|
|---|
| 259 | ExportDefaultDeclaration: ['declaration'],
|
|---|
| 260 | ExportNamedDeclaration: ['declaration', 'specifiers', 'source'],
|
|---|
| 261 | ExportSpecifier: ['exported', 'local'],
|
|---|
| 262 | ExpressionStatement: ['expression'],
|
|---|
| 263 | ForStatement: ['init', 'test', 'update', 'body'],
|
|---|
| 264 | ForInStatement: ['left', 'right', 'body'],
|
|---|
| 265 | ForOfStatement: ['left', 'right', 'body'],
|
|---|
| 266 | FunctionDeclaration: ['id', 'params', 'body'],
|
|---|
| 267 | FunctionExpression: ['id', 'params', 'body'],
|
|---|
| 268 | GeneratorExpression: ['blocks', 'filter', 'body'],
|
|---|
| 269 | // CAUTION: It's deferred to ES7.
|
|---|
| 270 | Identifier: [],
|
|---|
| 271 | IfStatement: ['test', 'consequent', 'alternate'],
|
|---|
| 272 | ImportExpression: ['source'],
|
|---|
| 273 | ImportDeclaration: ['specifiers', 'source'],
|
|---|
| 274 | ImportDefaultSpecifier: ['local'],
|
|---|
| 275 | ImportNamespaceSpecifier: ['local'],
|
|---|
| 276 | ImportSpecifier: ['imported', 'local'],
|
|---|
| 277 | Literal: [],
|
|---|
| 278 | LabeledStatement: ['label', 'body'],
|
|---|
| 279 | LogicalExpression: ['left', 'right'],
|
|---|
| 280 | MemberExpression: ['object', 'property'],
|
|---|
| 281 | MetaProperty: ['meta', 'property'],
|
|---|
| 282 | MethodDefinition: ['key', 'value'],
|
|---|
| 283 | ModuleSpecifier: [],
|
|---|
| 284 | NewExpression: ['callee', 'arguments'],
|
|---|
| 285 | ObjectExpression: ['properties'],
|
|---|
| 286 | ObjectPattern: ['properties'],
|
|---|
| 287 | PrivateIdentifier: [],
|
|---|
| 288 | Program: ['body'],
|
|---|
| 289 | Property: ['key', 'value'],
|
|---|
| 290 | PropertyDefinition: ['key', 'value'],
|
|---|
| 291 | RestElement: ['argument'],
|
|---|
| 292 | ReturnStatement: ['argument'],
|
|---|
| 293 | SequenceExpression: ['expressions'],
|
|---|
| 294 | SpreadElement: ['argument'],
|
|---|
| 295 | Super: [],
|
|---|
| 296 | SwitchStatement: ['discriminant', 'cases'],
|
|---|
| 297 | SwitchCase: ['test', 'consequent'],
|
|---|
| 298 | TaggedTemplateExpression: ['tag', 'quasi'],
|
|---|
| 299 | TemplateElement: [],
|
|---|
| 300 | TemplateLiteral: ['quasis', 'expressions'],
|
|---|
| 301 | ThisExpression: [],
|
|---|
| 302 | ThrowStatement: ['argument'],
|
|---|
| 303 | TryStatement: ['block', 'handler', 'finalizer'],
|
|---|
| 304 | UnaryExpression: ['argument'],
|
|---|
| 305 | UpdateExpression: ['argument'],
|
|---|
| 306 | VariableDeclaration: ['declarations'],
|
|---|
| 307 | VariableDeclarator: ['id', 'init'],
|
|---|
| 308 | WhileStatement: ['test', 'body'],
|
|---|
| 309 | WithStatement: ['object', 'body'],
|
|---|
| 310 | YieldExpression: ['argument']
|
|---|
| 311 | };
|
|---|
| 312 |
|
|---|
| 313 | // unique id
|
|---|
| 314 | BREAK = {};
|
|---|
| 315 | SKIP = {};
|
|---|
| 316 | REMOVE = {};
|
|---|
| 317 | VisitorOption = {
|
|---|
| 318 | Break: BREAK,
|
|---|
| 319 | Skip: SKIP,
|
|---|
| 320 | Remove: REMOVE
|
|---|
| 321 | };
|
|---|
| 322 | function Reference(parent, key) {
|
|---|
| 323 | this.parent = parent;
|
|---|
| 324 | this.key = key;
|
|---|
| 325 | }
|
|---|
| 326 | Reference.prototype.replace = function replace(node) {
|
|---|
| 327 | this.parent[this.key] = node;
|
|---|
| 328 | };
|
|---|
| 329 | Reference.prototype.remove = function remove() {
|
|---|
| 330 | if (Array.isArray(this.parent)) {
|
|---|
| 331 | this.parent.splice(this.key, 1);
|
|---|
| 332 | return true;
|
|---|
| 333 | } else {
|
|---|
| 334 | this.replace(null);
|
|---|
| 335 | return false;
|
|---|
| 336 | }
|
|---|
| 337 | };
|
|---|
| 338 | function Element(node, path, wrap, ref) {
|
|---|
| 339 | this.node = node;
|
|---|
| 340 | this.path = path;
|
|---|
| 341 | this.wrap = wrap;
|
|---|
| 342 | this.ref = ref;
|
|---|
| 343 | }
|
|---|
| 344 | function Controller() {}
|
|---|
| 345 |
|
|---|
| 346 | // API:
|
|---|
| 347 | // return property path array from root to current node
|
|---|
| 348 | Controller.prototype.path = function path() {
|
|---|
| 349 | var i, iz, j, jz, result, element;
|
|---|
| 350 | function addToPath(result, path) {
|
|---|
| 351 | if (Array.isArray(path)) {
|
|---|
| 352 | for (j = 0, jz = path.length; j < jz; ++j) {
|
|---|
| 353 | result.push(path[j]);
|
|---|
| 354 | }
|
|---|
| 355 | } else {
|
|---|
| 356 | result.push(path);
|
|---|
| 357 | }
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 | // root node
|
|---|
| 361 | if (!this.__current.path) {
|
|---|
| 362 | return null;
|
|---|
| 363 | }
|
|---|
| 364 |
|
|---|
| 365 | // first node is sentinel, second node is root element
|
|---|
| 366 | result = [];
|
|---|
| 367 | for (i = 2, iz = this.__leavelist.length; i < iz; ++i) {
|
|---|
| 368 | element = this.__leavelist[i];
|
|---|
| 369 | addToPath(result, element.path);
|
|---|
| 370 | }
|
|---|
| 371 | addToPath(result, this.__current.path);
|
|---|
| 372 | return result;
|
|---|
| 373 | };
|
|---|
| 374 |
|
|---|
| 375 | // API:
|
|---|
| 376 | // return type of current node
|
|---|
| 377 | Controller.prototype.type = function () {
|
|---|
| 378 | var node = this.current();
|
|---|
| 379 | return node.type || this.__current.wrap;
|
|---|
| 380 | };
|
|---|
| 381 |
|
|---|
| 382 | // API:
|
|---|
| 383 | // return array of parent elements
|
|---|
| 384 | Controller.prototype.parents = function parents() {
|
|---|
| 385 | var i, iz, result;
|
|---|
| 386 |
|
|---|
| 387 | // first node is sentinel
|
|---|
| 388 | result = [];
|
|---|
| 389 | for (i = 1, iz = this.__leavelist.length; i < iz; ++i) {
|
|---|
| 390 | result.push(this.__leavelist[i].node);
|
|---|
| 391 | }
|
|---|
| 392 | return result;
|
|---|
| 393 | };
|
|---|
| 394 |
|
|---|
| 395 | // API:
|
|---|
| 396 | // return current node
|
|---|
| 397 | Controller.prototype.current = function current() {
|
|---|
| 398 | return this.__current.node;
|
|---|
| 399 | };
|
|---|
| 400 | Controller.prototype.__execute = function __execute(callback, element) {
|
|---|
| 401 | var previous, result;
|
|---|
| 402 | result = undefined;
|
|---|
| 403 | previous = this.__current;
|
|---|
| 404 | this.__current = element;
|
|---|
| 405 | this.__state = null;
|
|---|
| 406 | if (callback) {
|
|---|
| 407 | result = callback.call(this, element.node, this.__leavelist[this.__leavelist.length - 1].node);
|
|---|
| 408 | }
|
|---|
| 409 | this.__current = previous;
|
|---|
| 410 | return result;
|
|---|
| 411 | };
|
|---|
| 412 |
|
|---|
| 413 | // API:
|
|---|
| 414 | // notify control skip / break
|
|---|
| 415 | Controller.prototype.notify = function notify(flag) {
|
|---|
| 416 | this.__state = flag;
|
|---|
| 417 | };
|
|---|
| 418 |
|
|---|
| 419 | // API:
|
|---|
| 420 | // skip child nodes of current node
|
|---|
| 421 | Controller.prototype.skip = function () {
|
|---|
| 422 | this.notify(SKIP);
|
|---|
| 423 | };
|
|---|
| 424 |
|
|---|
| 425 | // API:
|
|---|
| 426 | // break traversals
|
|---|
| 427 | Controller.prototype['break'] = function () {
|
|---|
| 428 | this.notify(BREAK);
|
|---|
| 429 | };
|
|---|
| 430 |
|
|---|
| 431 | // API:
|
|---|
| 432 | // remove node
|
|---|
| 433 | Controller.prototype.remove = function () {
|
|---|
| 434 | this.notify(REMOVE);
|
|---|
| 435 | };
|
|---|
| 436 | Controller.prototype.__initialize = function (root, visitor) {
|
|---|
| 437 | this.visitor = visitor;
|
|---|
| 438 | this.root = root;
|
|---|
| 439 | this.__worklist = [];
|
|---|
| 440 | this.__leavelist = [];
|
|---|
| 441 | this.__current = null;
|
|---|
| 442 | this.__state = null;
|
|---|
| 443 | this.__fallback = null;
|
|---|
| 444 | if (visitor.fallback === 'iteration') {
|
|---|
| 445 | this.__fallback = Object.keys;
|
|---|
| 446 | } else if (typeof visitor.fallback === 'function') {
|
|---|
| 447 | this.__fallback = visitor.fallback;
|
|---|
| 448 | }
|
|---|
| 449 | this.__keys = VisitorKeys;
|
|---|
| 450 | if (visitor.keys) {
|
|---|
| 451 | this.__keys = Object.assign(Object.create(this.__keys), visitor.keys);
|
|---|
| 452 | }
|
|---|
| 453 | };
|
|---|
| 454 | function isNode(node) {
|
|---|
| 455 | if (node == null) {
|
|---|
| 456 | return false;
|
|---|
| 457 | }
|
|---|
| 458 | return typeof node === 'object' && typeof node.type === 'string';
|
|---|
| 459 | }
|
|---|
| 460 | function isProperty(nodeType, key) {
|
|---|
| 461 | return (nodeType === Syntax.ObjectExpression || nodeType === Syntax.ObjectPattern) && 'properties' === key;
|
|---|
| 462 | }
|
|---|
| 463 | function candidateExistsInLeaveList(leavelist, candidate) {
|
|---|
| 464 | for (var i = leavelist.length - 1; i >= 0; --i) {
|
|---|
| 465 | if (leavelist[i].node === candidate) {
|
|---|
| 466 | return true;
|
|---|
| 467 | }
|
|---|
| 468 | }
|
|---|
| 469 | return false;
|
|---|
| 470 | }
|
|---|
| 471 | Controller.prototype.traverse = function traverse(root, visitor) {
|
|---|
| 472 | var worklist, leavelist, element, node, nodeType, ret, key, current, current2, candidates, candidate, sentinel;
|
|---|
| 473 | this.__initialize(root, visitor);
|
|---|
| 474 | sentinel = {};
|
|---|
| 475 |
|
|---|
| 476 | // reference
|
|---|
| 477 | worklist = this.__worklist;
|
|---|
| 478 | leavelist = this.__leavelist;
|
|---|
| 479 |
|
|---|
| 480 | // initialize
|
|---|
| 481 | worklist.push(new Element(root, null, null, null));
|
|---|
| 482 | leavelist.push(new Element(null, null, null, null));
|
|---|
| 483 | while (worklist.length) {
|
|---|
| 484 | element = worklist.pop();
|
|---|
| 485 | if (element === sentinel) {
|
|---|
| 486 | element = leavelist.pop();
|
|---|
| 487 | ret = this.__execute(visitor.leave, element);
|
|---|
| 488 | if (this.__state === BREAK || ret === BREAK) {
|
|---|
| 489 | return;
|
|---|
| 490 | }
|
|---|
| 491 | continue;
|
|---|
| 492 | }
|
|---|
| 493 | if (element.node) {
|
|---|
| 494 | ret = this.__execute(visitor.enter, element);
|
|---|
| 495 | if (this.__state === BREAK || ret === BREAK) {
|
|---|
| 496 | return;
|
|---|
| 497 | }
|
|---|
| 498 | worklist.push(sentinel);
|
|---|
| 499 | leavelist.push(element);
|
|---|
| 500 | if (this.__state === SKIP || ret === SKIP) {
|
|---|
| 501 | continue;
|
|---|
| 502 | }
|
|---|
| 503 | node = element.node;
|
|---|
| 504 | nodeType = node.type || element.wrap;
|
|---|
| 505 | candidates = this.__keys[nodeType];
|
|---|
| 506 | if (!candidates) {
|
|---|
| 507 | if (this.__fallback) {
|
|---|
| 508 | candidates = this.__fallback(node);
|
|---|
| 509 | } else {
|
|---|
| 510 | throw new Error('Unknown node type ' + nodeType + '.');
|
|---|
| 511 | }
|
|---|
| 512 | }
|
|---|
| 513 | current = candidates.length;
|
|---|
| 514 | while ((current -= 1) >= 0) {
|
|---|
| 515 | key = candidates[current];
|
|---|
| 516 | candidate = node[key];
|
|---|
| 517 | if (!candidate) {
|
|---|
| 518 | continue;
|
|---|
| 519 | }
|
|---|
| 520 | if (Array.isArray(candidate)) {
|
|---|
| 521 | current2 = candidate.length;
|
|---|
| 522 | while ((current2 -= 1) >= 0) {
|
|---|
| 523 | if (!candidate[current2]) {
|
|---|
| 524 | continue;
|
|---|
| 525 | }
|
|---|
| 526 | if (candidateExistsInLeaveList(leavelist, candidate[current2])) {
|
|---|
| 527 | continue;
|
|---|
| 528 | }
|
|---|
| 529 | if (isProperty(nodeType, candidates[current])) {
|
|---|
| 530 | element = new Element(candidate[current2], [key, current2], 'Property', null);
|
|---|
| 531 | } else if (isNode(candidate[current2])) {
|
|---|
| 532 | element = new Element(candidate[current2], [key, current2], null, null);
|
|---|
| 533 | } else {
|
|---|
| 534 | continue;
|
|---|
| 535 | }
|
|---|
| 536 | worklist.push(element);
|
|---|
| 537 | }
|
|---|
| 538 | } else if (isNode(candidate)) {
|
|---|
| 539 | if (candidateExistsInLeaveList(leavelist, candidate)) {
|
|---|
| 540 | continue;
|
|---|
| 541 | }
|
|---|
| 542 | worklist.push(new Element(candidate, key, null, null));
|
|---|
| 543 | }
|
|---|
| 544 | }
|
|---|
| 545 | }
|
|---|
| 546 | }
|
|---|
| 547 | };
|
|---|
| 548 | Controller.prototype.replace = function replace(root, visitor) {
|
|---|
| 549 | var worklist, leavelist, node, nodeType, target, element, current, current2, candidates, candidate, sentinel, outer, key;
|
|---|
| 550 | function removeElem(element) {
|
|---|
| 551 | var i, key, nextElem, parent;
|
|---|
| 552 | if (element.ref.remove()) {
|
|---|
| 553 | // When the reference is an element of an array.
|
|---|
| 554 | key = element.ref.key;
|
|---|
| 555 | parent = element.ref.parent;
|
|---|
| 556 |
|
|---|
| 557 | // If removed from array, then decrease following items' keys.
|
|---|
| 558 | i = worklist.length;
|
|---|
| 559 | while (i--) {
|
|---|
| 560 | nextElem = worklist[i];
|
|---|
| 561 | if (nextElem.ref && nextElem.ref.parent === parent) {
|
|---|
| 562 | if (nextElem.ref.key < key) {
|
|---|
| 563 | break;
|
|---|
| 564 | }
|
|---|
| 565 | --nextElem.ref.key;
|
|---|
| 566 | }
|
|---|
| 567 | }
|
|---|
| 568 | }
|
|---|
| 569 | }
|
|---|
| 570 | this.__initialize(root, visitor);
|
|---|
| 571 | sentinel = {};
|
|---|
| 572 |
|
|---|
| 573 | // reference
|
|---|
| 574 | worklist = this.__worklist;
|
|---|
| 575 | leavelist = this.__leavelist;
|
|---|
| 576 |
|
|---|
| 577 | // initialize
|
|---|
| 578 | outer = {
|
|---|
| 579 | root: root
|
|---|
| 580 | };
|
|---|
| 581 | element = new Element(root, null, null, new Reference(outer, 'root'));
|
|---|
| 582 | worklist.push(element);
|
|---|
| 583 | leavelist.push(element);
|
|---|
| 584 | while (worklist.length) {
|
|---|
| 585 | element = worklist.pop();
|
|---|
| 586 | if (element === sentinel) {
|
|---|
| 587 | element = leavelist.pop();
|
|---|
| 588 | target = this.__execute(visitor.leave, element);
|
|---|
| 589 |
|
|---|
| 590 | // node may be replaced with null,
|
|---|
| 591 | // so distinguish between undefined and null in this place
|
|---|
| 592 | if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
|
|---|
| 593 | // replace
|
|---|
| 594 | element.ref.replace(target);
|
|---|
| 595 | }
|
|---|
| 596 | if (this.__state === REMOVE || target === REMOVE) {
|
|---|
| 597 | removeElem(element);
|
|---|
| 598 | }
|
|---|
| 599 | if (this.__state === BREAK || target === BREAK) {
|
|---|
| 600 | return outer.root;
|
|---|
| 601 | }
|
|---|
| 602 | continue;
|
|---|
| 603 | }
|
|---|
| 604 | target = this.__execute(visitor.enter, element);
|
|---|
| 605 |
|
|---|
| 606 | // node may be replaced with null,
|
|---|
| 607 | // so distinguish between undefined and null in this place
|
|---|
| 608 | if (target !== undefined && target !== BREAK && target !== SKIP && target !== REMOVE) {
|
|---|
| 609 | // replace
|
|---|
| 610 | element.ref.replace(target);
|
|---|
| 611 | element.node = target;
|
|---|
| 612 | }
|
|---|
| 613 | if (this.__state === REMOVE || target === REMOVE) {
|
|---|
| 614 | removeElem(element);
|
|---|
| 615 | element.node = null;
|
|---|
| 616 | }
|
|---|
| 617 | if (this.__state === BREAK || target === BREAK) {
|
|---|
| 618 | return outer.root;
|
|---|
| 619 | }
|
|---|
| 620 |
|
|---|
| 621 | // node may be null
|
|---|
| 622 | node = element.node;
|
|---|
| 623 | if (!node) {
|
|---|
| 624 | continue;
|
|---|
| 625 | }
|
|---|
| 626 | worklist.push(sentinel);
|
|---|
| 627 | leavelist.push(element);
|
|---|
| 628 | if (this.__state === SKIP || target === SKIP) {
|
|---|
| 629 | continue;
|
|---|
| 630 | }
|
|---|
| 631 | nodeType = node.type || element.wrap;
|
|---|
| 632 | candidates = this.__keys[nodeType];
|
|---|
| 633 | if (!candidates) {
|
|---|
| 634 | if (this.__fallback) {
|
|---|
| 635 | candidates = this.__fallback(node);
|
|---|
| 636 | } else {
|
|---|
| 637 | throw new Error('Unknown node type ' + nodeType + '.');
|
|---|
| 638 | }
|
|---|
| 639 | }
|
|---|
| 640 | current = candidates.length;
|
|---|
| 641 | while ((current -= 1) >= 0) {
|
|---|
| 642 | key = candidates[current];
|
|---|
| 643 | candidate = node[key];
|
|---|
| 644 | if (!candidate) {
|
|---|
| 645 | continue;
|
|---|
| 646 | }
|
|---|
| 647 | if (Array.isArray(candidate)) {
|
|---|
| 648 | current2 = candidate.length;
|
|---|
| 649 | while ((current2 -= 1) >= 0) {
|
|---|
| 650 | if (!candidate[current2]) {
|
|---|
| 651 | continue;
|
|---|
| 652 | }
|
|---|
| 653 | if (isProperty(nodeType, candidates[current])) {
|
|---|
| 654 | element = new Element(candidate[current2], [key, current2], 'Property', new Reference(candidate, current2));
|
|---|
| 655 | } else if (isNode(candidate[current2])) {
|
|---|
| 656 | element = new Element(candidate[current2], [key, current2], null, new Reference(candidate, current2));
|
|---|
| 657 | } else {
|
|---|
| 658 | continue;
|
|---|
| 659 | }
|
|---|
| 660 | worklist.push(element);
|
|---|
| 661 | }
|
|---|
| 662 | } else if (isNode(candidate)) {
|
|---|
| 663 | worklist.push(new Element(candidate, key, null, new Reference(node, key)));
|
|---|
| 664 | }
|
|---|
| 665 | }
|
|---|
| 666 | }
|
|---|
| 667 | return outer.root;
|
|---|
| 668 | };
|
|---|
| 669 | function traverse(root, visitor) {
|
|---|
| 670 | var controller = new Controller();
|
|---|
| 671 | return controller.traverse(root, visitor);
|
|---|
| 672 | }
|
|---|
| 673 | function replace(root, visitor) {
|
|---|
| 674 | var controller = new Controller();
|
|---|
| 675 | return controller.replace(root, visitor);
|
|---|
| 676 | }
|
|---|
| 677 | function extendCommentRange(comment, tokens) {
|
|---|
| 678 | var target;
|
|---|
| 679 | target = upperBound(tokens, function search(token) {
|
|---|
| 680 | return token.range[0] > comment.range[0];
|
|---|
| 681 | });
|
|---|
| 682 | comment.extendedRange = [comment.range[0], comment.range[1]];
|
|---|
| 683 | if (target !== tokens.length) {
|
|---|
| 684 | comment.extendedRange[1] = tokens[target].range[0];
|
|---|
| 685 | }
|
|---|
| 686 | target -= 1;
|
|---|
| 687 | if (target >= 0) {
|
|---|
| 688 | comment.extendedRange[0] = tokens[target].range[1];
|
|---|
| 689 | }
|
|---|
| 690 | return comment;
|
|---|
| 691 | }
|
|---|
| 692 | function attachComments(tree, providedComments, tokens) {
|
|---|
| 693 | // At first, we should calculate extended comment ranges.
|
|---|
| 694 | var comments = [],
|
|---|
| 695 | comment,
|
|---|
| 696 | len,
|
|---|
| 697 | i,
|
|---|
| 698 | cursor;
|
|---|
| 699 | if (!tree.range) {
|
|---|
| 700 | throw new Error('attachComments needs range information');
|
|---|
| 701 | }
|
|---|
| 702 |
|
|---|
| 703 | // tokens array is empty, we attach comments to tree as 'leadingComments'
|
|---|
| 704 | if (!tokens.length) {
|
|---|
| 705 | if (providedComments.length) {
|
|---|
| 706 | for (i = 0, len = providedComments.length; i < len; i += 1) {
|
|---|
| 707 | comment = deepCopy(providedComments[i]);
|
|---|
| 708 | comment.extendedRange = [0, tree.range[0]];
|
|---|
| 709 | comments.push(comment);
|
|---|
| 710 | }
|
|---|
| 711 | tree.leadingComments = comments;
|
|---|
| 712 | }
|
|---|
| 713 | return tree;
|
|---|
| 714 | }
|
|---|
| 715 | for (i = 0, len = providedComments.length; i < len; i += 1) {
|
|---|
| 716 | comments.push(extendCommentRange(deepCopy(providedComments[i]), tokens));
|
|---|
| 717 | }
|
|---|
| 718 |
|
|---|
| 719 | // This is based on John Freeman's implementation.
|
|---|
| 720 | cursor = 0;
|
|---|
| 721 | traverse(tree, {
|
|---|
| 722 | enter: function (node) {
|
|---|
| 723 | var comment;
|
|---|
| 724 | while (cursor < comments.length) {
|
|---|
| 725 | comment = comments[cursor];
|
|---|
| 726 | if (comment.extendedRange[1] > node.range[0]) {
|
|---|
| 727 | break;
|
|---|
| 728 | }
|
|---|
| 729 | if (comment.extendedRange[1] === node.range[0]) {
|
|---|
| 730 | if (!node.leadingComments) {
|
|---|
| 731 | node.leadingComments = [];
|
|---|
| 732 | }
|
|---|
| 733 | node.leadingComments.push(comment);
|
|---|
| 734 | comments.splice(cursor, 1);
|
|---|
| 735 | } else {
|
|---|
| 736 | cursor += 1;
|
|---|
| 737 | }
|
|---|
| 738 | }
|
|---|
| 739 |
|
|---|
| 740 | // already out of owned node
|
|---|
| 741 | if (cursor === comments.length) {
|
|---|
| 742 | return VisitorOption.Break;
|
|---|
| 743 | }
|
|---|
| 744 | if (comments[cursor].extendedRange[0] > node.range[1]) {
|
|---|
| 745 | return VisitorOption.Skip;
|
|---|
| 746 | }
|
|---|
| 747 | }
|
|---|
| 748 | });
|
|---|
| 749 | cursor = 0;
|
|---|
| 750 | traverse(tree, {
|
|---|
| 751 | leave: function (node) {
|
|---|
| 752 | var comment;
|
|---|
| 753 | while (cursor < comments.length) {
|
|---|
| 754 | comment = comments[cursor];
|
|---|
| 755 | if (node.range[1] < comment.extendedRange[0]) {
|
|---|
| 756 | break;
|
|---|
| 757 | }
|
|---|
| 758 | if (node.range[1] === comment.extendedRange[0]) {
|
|---|
| 759 | if (!node.trailingComments) {
|
|---|
| 760 | node.trailingComments = [];
|
|---|
| 761 | }
|
|---|
| 762 | node.trailingComments.push(comment);
|
|---|
| 763 | comments.splice(cursor, 1);
|
|---|
| 764 | } else {
|
|---|
| 765 | cursor += 1;
|
|---|
| 766 | }
|
|---|
| 767 | }
|
|---|
| 768 |
|
|---|
| 769 | // already out of owned node
|
|---|
| 770 | if (cursor === comments.length) {
|
|---|
| 771 | return VisitorOption.Break;
|
|---|
| 772 | }
|
|---|
| 773 | if (comments[cursor].extendedRange[0] > node.range[1]) {
|
|---|
| 774 | return VisitorOption.Skip;
|
|---|
| 775 | }
|
|---|
| 776 | }
|
|---|
| 777 | });
|
|---|
| 778 | return tree;
|
|---|
| 779 | }
|
|---|
| 780 | exports.Syntax = Syntax;
|
|---|
| 781 | exports.traverse = traverse;
|
|---|
| 782 | exports.replace = replace;
|
|---|
| 783 | exports.attachComments = attachComments;
|
|---|
| 784 | exports.VisitorKeys = VisitorKeys;
|
|---|
| 785 | exports.VisitorOption = VisitorOption;
|
|---|
| 786 | exports.Controller = Controller;
|
|---|
| 787 | exports.cloneEnvironment = function () {
|
|---|
| 788 | return clone({});
|
|---|
| 789 | };
|
|---|
| 790 | return exports;
|
|---|
| 791 | })(exports);
|
|---|
| 792 | /* vim: set sw=4 ts=4 et tw=80 : */
|
|---|
| 793 | });
|
|---|
| 794 |
|
|---|
| 795 | var parser = createCommonjsModule(function (module) {
|
|---|
| 796 | /*
|
|---|
| 797 | * Generated by PEG.js 0.10.0.
|
|---|
| 798 | *
|
|---|
| 799 | * http://pegjs.org/
|
|---|
| 800 | */
|
|---|
| 801 | (function (root, factory) {
|
|---|
| 802 | if ( module.exports) {
|
|---|
| 803 | module.exports = factory();
|
|---|
| 804 | }
|
|---|
| 805 | })(commonjsGlobal, function () {
|
|---|
| 806 |
|
|---|
| 807 | function peg$subclass(child, parent) {
|
|---|
| 808 | function ctor() {
|
|---|
| 809 | this.constructor = child;
|
|---|
| 810 | }
|
|---|
| 811 | ctor.prototype = parent.prototype;
|
|---|
| 812 | child.prototype = new ctor();
|
|---|
| 813 | }
|
|---|
| 814 | function peg$SyntaxError(message, expected, found, location) {
|
|---|
| 815 | this.message = message;
|
|---|
| 816 | this.expected = expected;
|
|---|
| 817 | this.found = found;
|
|---|
| 818 | this.location = location;
|
|---|
| 819 | this.name = "SyntaxError";
|
|---|
| 820 | if (typeof Error.captureStackTrace === "function") {
|
|---|
| 821 | Error.captureStackTrace(this, peg$SyntaxError);
|
|---|
| 822 | }
|
|---|
| 823 | }
|
|---|
| 824 | peg$subclass(peg$SyntaxError, Error);
|
|---|
| 825 | peg$SyntaxError.buildMessage = function (expected, found) {
|
|---|
| 826 | var DESCRIBE_EXPECTATION_FNS = {
|
|---|
| 827 | literal: function literal(expectation) {
|
|---|
| 828 | return "\"" + literalEscape(expectation.text) + "\"";
|
|---|
| 829 | },
|
|---|
| 830 | "class": function _class(expectation) {
|
|---|
| 831 | var escapedParts = "",
|
|---|
| 832 | i;
|
|---|
| 833 | for (i = 0; i < expectation.parts.length; i++) {
|
|---|
| 834 | escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]);
|
|---|
| 835 | }
|
|---|
| 836 | return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
|
|---|
| 837 | },
|
|---|
| 838 | any: function any(expectation) {
|
|---|
| 839 | return "any character";
|
|---|
| 840 | },
|
|---|
| 841 | end: function end(expectation) {
|
|---|
| 842 | return "end of input";
|
|---|
| 843 | },
|
|---|
| 844 | other: function other(expectation) {
|
|---|
| 845 | return expectation.description;
|
|---|
| 846 | }
|
|---|
| 847 | };
|
|---|
| 848 | function hex(ch) {
|
|---|
| 849 | return ch.charCodeAt(0).toString(16).toUpperCase();
|
|---|
| 850 | }
|
|---|
| 851 | function literalEscape(s) {
|
|---|
| 852 | 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) {
|
|---|
| 853 | return '\\x0' + hex(ch);
|
|---|
| 854 | }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
|
|---|
| 855 | return '\\x' + hex(ch);
|
|---|
| 856 | });
|
|---|
| 857 | }
|
|---|
| 858 | function classEscape(s) {
|
|---|
| 859 | 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) {
|
|---|
| 860 | return '\\x0' + hex(ch);
|
|---|
| 861 | }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
|
|---|
| 862 | return '\\x' + hex(ch);
|
|---|
| 863 | });
|
|---|
| 864 | }
|
|---|
| 865 | function describeExpectation(expectation) {
|
|---|
| 866 | return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|---|
| 867 | }
|
|---|
| 868 | function describeExpected(expected) {
|
|---|
| 869 | var descriptions = new Array(expected.length),
|
|---|
| 870 | i,
|
|---|
| 871 | j;
|
|---|
| 872 | for (i = 0; i < expected.length; i++) {
|
|---|
| 873 | descriptions[i] = describeExpectation(expected[i]);
|
|---|
| 874 | }
|
|---|
| 875 | descriptions.sort();
|
|---|
| 876 | if (descriptions.length > 0) {
|
|---|
| 877 | for (i = 1, j = 1; i < descriptions.length; i++) {
|
|---|
| 878 | if (descriptions[i - 1] !== descriptions[i]) {
|
|---|
| 879 | descriptions[j] = descriptions[i];
|
|---|
| 880 | j++;
|
|---|
| 881 | }
|
|---|
| 882 | }
|
|---|
| 883 | descriptions.length = j;
|
|---|
| 884 | }
|
|---|
| 885 | switch (descriptions.length) {
|
|---|
| 886 | case 1:
|
|---|
| 887 | return descriptions[0];
|
|---|
| 888 | case 2:
|
|---|
| 889 | return descriptions[0] + " or " + descriptions[1];
|
|---|
| 890 | default:
|
|---|
| 891 | return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|---|
| 892 | }
|
|---|
| 893 | }
|
|---|
| 894 | function describeFound(found) {
|
|---|
| 895 | return found ? "\"" + literalEscape(found) + "\"" : "end of input";
|
|---|
| 896 | }
|
|---|
| 897 | return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|---|
| 898 | };
|
|---|
| 899 | function peg$parse(input, options) {
|
|---|
| 900 | options = options !== void 0 ? options : {};
|
|---|
| 901 | var peg$FAILED = {},
|
|---|
| 902 | peg$startRuleFunctions = {
|
|---|
| 903 | start: peg$parsestart
|
|---|
| 904 | },
|
|---|
| 905 | peg$startRuleFunction = peg$parsestart,
|
|---|
| 906 | peg$c0 = function peg$c0(ss) {
|
|---|
| 907 | return ss.length === 1 ? ss[0] : {
|
|---|
| 908 | type: 'matches',
|
|---|
| 909 | selectors: ss
|
|---|
| 910 | };
|
|---|
| 911 | },
|
|---|
| 912 | peg$c1 = function peg$c1() {
|
|---|
| 913 | return void 0;
|
|---|
| 914 | },
|
|---|
| 915 | peg$c2 = " ",
|
|---|
| 916 | peg$c3 = peg$literalExpectation(" ", false),
|
|---|
| 917 | peg$c4 = /^[^ [\],():#!=><~+.]/,
|
|---|
| 918 | peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false),
|
|---|
| 919 | peg$c6 = function peg$c6(i) {
|
|---|
| 920 | return i.join('');
|
|---|
| 921 | },
|
|---|
| 922 | peg$c7 = ">",
|
|---|
| 923 | peg$c8 = peg$literalExpectation(">", false),
|
|---|
| 924 | peg$c9 = function peg$c9() {
|
|---|
| 925 | return 'child';
|
|---|
| 926 | },
|
|---|
| 927 | peg$c10 = "~",
|
|---|
| 928 | peg$c11 = peg$literalExpectation("~", false),
|
|---|
| 929 | peg$c12 = function peg$c12() {
|
|---|
| 930 | return 'sibling';
|
|---|
| 931 | },
|
|---|
| 932 | peg$c13 = "+",
|
|---|
| 933 | peg$c14 = peg$literalExpectation("+", false),
|
|---|
| 934 | peg$c15 = function peg$c15() {
|
|---|
| 935 | return 'adjacent';
|
|---|
| 936 | },
|
|---|
| 937 | peg$c16 = function peg$c16() {
|
|---|
| 938 | return 'descendant';
|
|---|
| 939 | },
|
|---|
| 940 | peg$c17 = ",",
|
|---|
| 941 | peg$c18 = peg$literalExpectation(",", false),
|
|---|
| 942 | peg$c19 = function peg$c19(s, ss) {
|
|---|
| 943 | return [s].concat(ss.map(function (s) {
|
|---|
| 944 | return s[3];
|
|---|
| 945 | }));
|
|---|
| 946 | },
|
|---|
| 947 | peg$c20 = function peg$c20(op, s) {
|
|---|
| 948 | if (!op) return s;
|
|---|
| 949 | return {
|
|---|
| 950 | type: op,
|
|---|
| 951 | left: {
|
|---|
| 952 | type: 'exactNode'
|
|---|
| 953 | },
|
|---|
| 954 | right: s
|
|---|
| 955 | };
|
|---|
| 956 | },
|
|---|
| 957 | peg$c21 = function peg$c21(a, ops) {
|
|---|
| 958 | return ops.reduce(function (memo, rhs) {
|
|---|
| 959 | return {
|
|---|
| 960 | type: rhs[0],
|
|---|
| 961 | left: memo,
|
|---|
| 962 | right: rhs[1]
|
|---|
| 963 | };
|
|---|
| 964 | }, a);
|
|---|
| 965 | },
|
|---|
| 966 | peg$c22 = "!",
|
|---|
| 967 | peg$c23 = peg$literalExpectation("!", false),
|
|---|
| 968 | peg$c24 = function peg$c24(subject, as) {
|
|---|
| 969 | var b = as.length === 1 ? as[0] : {
|
|---|
| 970 | type: 'compound',
|
|---|
| 971 | selectors: as
|
|---|
| 972 | };
|
|---|
| 973 | if (subject) b.subject = true;
|
|---|
| 974 | return b;
|
|---|
| 975 | },
|
|---|
| 976 | peg$c25 = "*",
|
|---|
| 977 | peg$c26 = peg$literalExpectation("*", false),
|
|---|
| 978 | peg$c27 = function peg$c27(a) {
|
|---|
| 979 | return {
|
|---|
| 980 | type: 'wildcard',
|
|---|
| 981 | value: a
|
|---|
| 982 | };
|
|---|
| 983 | },
|
|---|
| 984 | peg$c28 = "#",
|
|---|
| 985 | peg$c29 = peg$literalExpectation("#", false),
|
|---|
| 986 | peg$c30 = function peg$c30(i) {
|
|---|
| 987 | return {
|
|---|
| 988 | type: 'identifier',
|
|---|
| 989 | value: i
|
|---|
| 990 | };
|
|---|
| 991 | },
|
|---|
| 992 | peg$c31 = "[",
|
|---|
| 993 | peg$c32 = peg$literalExpectation("[", false),
|
|---|
| 994 | peg$c33 = "]",
|
|---|
| 995 | peg$c34 = peg$literalExpectation("]", false),
|
|---|
| 996 | peg$c35 = function peg$c35(v) {
|
|---|
| 997 | return v;
|
|---|
| 998 | },
|
|---|
| 999 | peg$c36 = /^[><!]/,
|
|---|
| 1000 | peg$c37 = peg$classExpectation([">", "<", "!"], false, false),
|
|---|
| 1001 | peg$c38 = "=",
|
|---|
| 1002 | peg$c39 = peg$literalExpectation("=", false),
|
|---|
| 1003 | peg$c40 = function peg$c40(a) {
|
|---|
| 1004 | return (a || '') + '=';
|
|---|
| 1005 | },
|
|---|
| 1006 | peg$c41 = /^[><]/,
|
|---|
| 1007 | peg$c42 = peg$classExpectation([">", "<"], false, false),
|
|---|
| 1008 | peg$c43 = ".",
|
|---|
| 1009 | peg$c44 = peg$literalExpectation(".", false),
|
|---|
| 1010 | peg$c45 = function peg$c45(a, as) {
|
|---|
| 1011 | return [].concat.apply([a], as).join('');
|
|---|
| 1012 | },
|
|---|
| 1013 | peg$c46 = function peg$c46(name, op, value) {
|
|---|
| 1014 | return {
|
|---|
| 1015 | type: 'attribute',
|
|---|
| 1016 | name: name,
|
|---|
| 1017 | operator: op,
|
|---|
| 1018 | value: value
|
|---|
| 1019 | };
|
|---|
| 1020 | },
|
|---|
| 1021 | peg$c47 = function peg$c47(name) {
|
|---|
| 1022 | return {
|
|---|
| 1023 | type: 'attribute',
|
|---|
| 1024 | name: name
|
|---|
| 1025 | };
|
|---|
| 1026 | },
|
|---|
| 1027 | peg$c48 = "\"",
|
|---|
| 1028 | peg$c49 = peg$literalExpectation("\"", false),
|
|---|
| 1029 | peg$c50 = /^[^\\"]/,
|
|---|
| 1030 | peg$c51 = peg$classExpectation(["\\", "\""], true, false),
|
|---|
| 1031 | peg$c52 = "\\",
|
|---|
| 1032 | peg$c53 = peg$literalExpectation("\\", false),
|
|---|
| 1033 | peg$c54 = peg$anyExpectation(),
|
|---|
| 1034 | peg$c55 = function peg$c55(a, b) {
|
|---|
| 1035 | return a + b;
|
|---|
| 1036 | },
|
|---|
| 1037 | peg$c56 = function peg$c56(d) {
|
|---|
| 1038 | return {
|
|---|
| 1039 | type: 'literal',
|
|---|
| 1040 | value: strUnescape(d.join(''))
|
|---|
| 1041 | };
|
|---|
| 1042 | },
|
|---|
| 1043 | peg$c57 = "'",
|
|---|
| 1044 | peg$c58 = peg$literalExpectation("'", false),
|
|---|
| 1045 | peg$c59 = /^[^\\']/,
|
|---|
| 1046 | peg$c60 = peg$classExpectation(["\\", "'"], true, false),
|
|---|
| 1047 | peg$c61 = /^[0-9]/,
|
|---|
| 1048 | peg$c62 = peg$classExpectation([["0", "9"]], false, false),
|
|---|
| 1049 | peg$c63 = function peg$c63(a, b) {
|
|---|
| 1050 | // Can use `a.flat().join('')` once supported
|
|---|
| 1051 | var leadingDecimals = a ? [].concat.apply([], a).join('') : '';
|
|---|
| 1052 | return {
|
|---|
| 1053 | type: 'literal',
|
|---|
| 1054 | value: parseFloat(leadingDecimals + b.join(''))
|
|---|
| 1055 | };
|
|---|
| 1056 | },
|
|---|
| 1057 | peg$c64 = function peg$c64(i) {
|
|---|
| 1058 | return {
|
|---|
| 1059 | type: 'literal',
|
|---|
| 1060 | value: i
|
|---|
| 1061 | };
|
|---|
| 1062 | },
|
|---|
| 1063 | peg$c65 = "type(",
|
|---|
| 1064 | peg$c66 = peg$literalExpectation("type(", false),
|
|---|
| 1065 | peg$c67 = /^[^ )]/,
|
|---|
| 1066 | peg$c68 = peg$classExpectation([" ", ")"], true, false),
|
|---|
| 1067 | peg$c69 = ")",
|
|---|
| 1068 | peg$c70 = peg$literalExpectation(")", false),
|
|---|
| 1069 | peg$c71 = function peg$c71(t) {
|
|---|
| 1070 | return {
|
|---|
| 1071 | type: 'type',
|
|---|
| 1072 | value: t.join('')
|
|---|
| 1073 | };
|
|---|
| 1074 | },
|
|---|
| 1075 | peg$c72 = /^[imsu]/,
|
|---|
| 1076 | peg$c73 = peg$classExpectation(["i", "m", "s", "u"], false, false),
|
|---|
| 1077 | peg$c74 = "/",
|
|---|
| 1078 | peg$c75 = peg$literalExpectation("/", false),
|
|---|
| 1079 | peg$c76 = function peg$c76(pattern, flgs) {
|
|---|
| 1080 | return {
|
|---|
| 1081 | type: 'regexp',
|
|---|
| 1082 | value: new RegExp(pattern.join(''), flgs ? flgs.join('') : '')
|
|---|
| 1083 | };
|
|---|
| 1084 | },
|
|---|
| 1085 | peg$c77 = /^[^\]\\]/,
|
|---|
| 1086 | peg$c78 = peg$classExpectation(["]", "\\"], true, false),
|
|---|
| 1087 | peg$c79 = function peg$c79(cs) {
|
|---|
| 1088 | return '[' + cs.join('') + ']';
|
|---|
| 1089 | },
|
|---|
| 1090 | peg$c80 = function peg$c80(a) {
|
|---|
| 1091 | return '\\' + a;
|
|---|
| 1092 | },
|
|---|
| 1093 | peg$c81 = /^[^\/\\[]/,
|
|---|
| 1094 | peg$c82 = peg$classExpectation(["/", "\\", "["], true, false),
|
|---|
| 1095 | peg$c83 = function peg$c83(cs) {
|
|---|
| 1096 | return cs.join('');
|
|---|
| 1097 | },
|
|---|
| 1098 | peg$c84 = function peg$c84(i, is) {
|
|---|
| 1099 | return {
|
|---|
| 1100 | type: 'field',
|
|---|
| 1101 | name: is.reduce(function (memo, p) {
|
|---|
| 1102 | return memo + p[0] + p[1];
|
|---|
| 1103 | }, i)
|
|---|
| 1104 | };
|
|---|
| 1105 | },
|
|---|
| 1106 | peg$c85 = ":not(",
|
|---|
| 1107 | peg$c86 = peg$literalExpectation(":not(", false),
|
|---|
| 1108 | peg$c87 = function peg$c87(ss) {
|
|---|
| 1109 | return {
|
|---|
| 1110 | type: 'not',
|
|---|
| 1111 | selectors: ss
|
|---|
| 1112 | };
|
|---|
| 1113 | },
|
|---|
| 1114 | peg$c88 = ":matches(",
|
|---|
| 1115 | peg$c89 = peg$literalExpectation(":matches(", false),
|
|---|
| 1116 | peg$c90 = function peg$c90(ss) {
|
|---|
| 1117 | return {
|
|---|
| 1118 | type: 'matches',
|
|---|
| 1119 | selectors: ss
|
|---|
| 1120 | };
|
|---|
| 1121 | },
|
|---|
| 1122 | peg$c91 = ":is(",
|
|---|
| 1123 | peg$c92 = peg$literalExpectation(":is(", false),
|
|---|
| 1124 | peg$c93 = ":has(",
|
|---|
| 1125 | peg$c94 = peg$literalExpectation(":has(", false),
|
|---|
| 1126 | peg$c95 = function peg$c95(ss) {
|
|---|
| 1127 | return {
|
|---|
| 1128 | type: 'has',
|
|---|
| 1129 | selectors: ss
|
|---|
| 1130 | };
|
|---|
| 1131 | },
|
|---|
| 1132 | peg$c96 = ":first-child",
|
|---|
| 1133 | peg$c97 = peg$literalExpectation(":first-child", false),
|
|---|
| 1134 | peg$c98 = function peg$c98() {
|
|---|
| 1135 | return nth(1);
|
|---|
| 1136 | },
|
|---|
| 1137 | peg$c99 = ":last-child",
|
|---|
| 1138 | peg$c100 = peg$literalExpectation(":last-child", false),
|
|---|
| 1139 | peg$c101 = function peg$c101() {
|
|---|
| 1140 | return nthLast(1);
|
|---|
| 1141 | },
|
|---|
| 1142 | peg$c102 = ":nth-child(",
|
|---|
| 1143 | peg$c103 = peg$literalExpectation(":nth-child(", false),
|
|---|
| 1144 | peg$c104 = function peg$c104(n) {
|
|---|
| 1145 | return nth(parseInt(n.join(''), 10));
|
|---|
| 1146 | },
|
|---|
| 1147 | peg$c105 = ":nth-last-child(",
|
|---|
| 1148 | peg$c106 = peg$literalExpectation(":nth-last-child(", false),
|
|---|
| 1149 | peg$c107 = function peg$c107(n) {
|
|---|
| 1150 | return nthLast(parseInt(n.join(''), 10));
|
|---|
| 1151 | },
|
|---|
| 1152 | peg$c108 = ":",
|
|---|
| 1153 | peg$c109 = peg$literalExpectation(":", false),
|
|---|
| 1154 | peg$c110 = function peg$c110(c) {
|
|---|
| 1155 | return {
|
|---|
| 1156 | type: 'class',
|
|---|
| 1157 | name: c
|
|---|
| 1158 | };
|
|---|
| 1159 | },
|
|---|
| 1160 | peg$currPos = 0,
|
|---|
| 1161 | peg$posDetailsCache = [{
|
|---|
| 1162 | line: 1,
|
|---|
| 1163 | column: 1
|
|---|
| 1164 | }],
|
|---|
| 1165 | peg$maxFailPos = 0,
|
|---|
| 1166 | peg$maxFailExpected = [],
|
|---|
| 1167 | peg$resultsCache = {},
|
|---|
| 1168 | peg$result;
|
|---|
| 1169 | if ("startRule" in options) {
|
|---|
| 1170 | if (!(options.startRule in peg$startRuleFunctions)) {
|
|---|
| 1171 | throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
|
|---|
| 1172 | }
|
|---|
| 1173 | peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
|
|---|
| 1174 | }
|
|---|
| 1175 | function peg$literalExpectation(text, ignoreCase) {
|
|---|
| 1176 | return {
|
|---|
| 1177 | type: "literal",
|
|---|
| 1178 | text: text,
|
|---|
| 1179 | ignoreCase: ignoreCase
|
|---|
| 1180 | };
|
|---|
| 1181 | }
|
|---|
| 1182 | function peg$classExpectation(parts, inverted, ignoreCase) {
|
|---|
| 1183 | return {
|
|---|
| 1184 | type: "class",
|
|---|
| 1185 | parts: parts,
|
|---|
| 1186 | inverted: inverted,
|
|---|
| 1187 | ignoreCase: ignoreCase
|
|---|
| 1188 | };
|
|---|
| 1189 | }
|
|---|
| 1190 | function peg$anyExpectation() {
|
|---|
| 1191 | return {
|
|---|
| 1192 | type: "any"
|
|---|
| 1193 | };
|
|---|
| 1194 | }
|
|---|
| 1195 | function peg$endExpectation() {
|
|---|
| 1196 | return {
|
|---|
| 1197 | type: "end"
|
|---|
| 1198 | };
|
|---|
| 1199 | }
|
|---|
| 1200 | function peg$computePosDetails(pos) {
|
|---|
| 1201 | var details = peg$posDetailsCache[pos],
|
|---|
| 1202 | p;
|
|---|
| 1203 | if (details) {
|
|---|
| 1204 | return details;
|
|---|
| 1205 | } else {
|
|---|
| 1206 | p = pos - 1;
|
|---|
| 1207 | while (!peg$posDetailsCache[p]) {
|
|---|
| 1208 | p--;
|
|---|
| 1209 | }
|
|---|
| 1210 | details = peg$posDetailsCache[p];
|
|---|
| 1211 | details = {
|
|---|
| 1212 | line: details.line,
|
|---|
| 1213 | column: details.column
|
|---|
| 1214 | };
|
|---|
| 1215 | while (p < pos) {
|
|---|
| 1216 | if (input.charCodeAt(p) === 10) {
|
|---|
| 1217 | details.line++;
|
|---|
| 1218 | details.column = 1;
|
|---|
| 1219 | } else {
|
|---|
| 1220 | details.column++;
|
|---|
| 1221 | }
|
|---|
| 1222 | p++;
|
|---|
| 1223 | }
|
|---|
| 1224 | peg$posDetailsCache[pos] = details;
|
|---|
| 1225 | return details;
|
|---|
| 1226 | }
|
|---|
| 1227 | }
|
|---|
| 1228 | function peg$computeLocation(startPos, endPos) {
|
|---|
| 1229 | var startPosDetails = peg$computePosDetails(startPos),
|
|---|
| 1230 | endPosDetails = peg$computePosDetails(endPos);
|
|---|
| 1231 | return {
|
|---|
| 1232 | start: {
|
|---|
| 1233 | offset: startPos,
|
|---|
| 1234 | line: startPosDetails.line,
|
|---|
| 1235 | column: startPosDetails.column
|
|---|
| 1236 | },
|
|---|
| 1237 | end: {
|
|---|
| 1238 | offset: endPos,
|
|---|
| 1239 | line: endPosDetails.line,
|
|---|
| 1240 | column: endPosDetails.column
|
|---|
| 1241 | }
|
|---|
| 1242 | };
|
|---|
| 1243 | }
|
|---|
| 1244 | function peg$fail(expected) {
|
|---|
| 1245 | if (peg$currPos < peg$maxFailPos) {
|
|---|
| 1246 | return;
|
|---|
| 1247 | }
|
|---|
| 1248 | if (peg$currPos > peg$maxFailPos) {
|
|---|
| 1249 | peg$maxFailPos = peg$currPos;
|
|---|
| 1250 | peg$maxFailExpected = [];
|
|---|
| 1251 | }
|
|---|
| 1252 | peg$maxFailExpected.push(expected);
|
|---|
| 1253 | }
|
|---|
| 1254 | function peg$buildStructuredError(expected, found, location) {
|
|---|
| 1255 | return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
|
|---|
| 1256 | }
|
|---|
| 1257 | function peg$parsestart() {
|
|---|
| 1258 | var s0, s1, s2, s3;
|
|---|
| 1259 | var key = peg$currPos * 36 + 0,
|
|---|
| 1260 | cached = peg$resultsCache[key];
|
|---|
| 1261 | if (cached) {
|
|---|
| 1262 | peg$currPos = cached.nextPos;
|
|---|
| 1263 | return cached.result;
|
|---|
| 1264 | }
|
|---|
| 1265 | s0 = peg$currPos;
|
|---|
| 1266 | s1 = peg$parse_();
|
|---|
| 1267 | if (s1 !== peg$FAILED) {
|
|---|
| 1268 | s2 = peg$parseselectors();
|
|---|
| 1269 | if (s2 !== peg$FAILED) {
|
|---|
| 1270 | s3 = peg$parse_();
|
|---|
| 1271 | if (s3 !== peg$FAILED) {
|
|---|
| 1272 | s1 = peg$c0(s2);
|
|---|
| 1273 | s0 = s1;
|
|---|
| 1274 | } else {
|
|---|
| 1275 | peg$currPos = s0;
|
|---|
| 1276 | s0 = peg$FAILED;
|
|---|
| 1277 | }
|
|---|
| 1278 | } else {
|
|---|
| 1279 | peg$currPos = s0;
|
|---|
| 1280 | s0 = peg$FAILED;
|
|---|
| 1281 | }
|
|---|
| 1282 | } else {
|
|---|
| 1283 | peg$currPos = s0;
|
|---|
| 1284 | s0 = peg$FAILED;
|
|---|
| 1285 | }
|
|---|
| 1286 | if (s0 === peg$FAILED) {
|
|---|
| 1287 | s0 = peg$currPos;
|
|---|
| 1288 | s1 = peg$parse_();
|
|---|
| 1289 | if (s1 !== peg$FAILED) {
|
|---|
| 1290 | s1 = peg$c1();
|
|---|
| 1291 | }
|
|---|
| 1292 | s0 = s1;
|
|---|
| 1293 | }
|
|---|
| 1294 | peg$resultsCache[key] = {
|
|---|
| 1295 | nextPos: peg$currPos,
|
|---|
| 1296 | result: s0
|
|---|
| 1297 | };
|
|---|
| 1298 | return s0;
|
|---|
| 1299 | }
|
|---|
| 1300 | function peg$parse_() {
|
|---|
| 1301 | var s0, s1;
|
|---|
| 1302 | var key = peg$currPos * 36 + 1,
|
|---|
| 1303 | cached = peg$resultsCache[key];
|
|---|
| 1304 | if (cached) {
|
|---|
| 1305 | peg$currPos = cached.nextPos;
|
|---|
| 1306 | return cached.result;
|
|---|
| 1307 | }
|
|---|
| 1308 | s0 = [];
|
|---|
| 1309 | if (input.charCodeAt(peg$currPos) === 32) {
|
|---|
| 1310 | s1 = peg$c2;
|
|---|
| 1311 | peg$currPos++;
|
|---|
| 1312 | } else {
|
|---|
| 1313 | s1 = peg$FAILED;
|
|---|
| 1314 | {
|
|---|
| 1315 | peg$fail(peg$c3);
|
|---|
| 1316 | }
|
|---|
| 1317 | }
|
|---|
| 1318 | while (s1 !== peg$FAILED) {
|
|---|
| 1319 | s0.push(s1);
|
|---|
| 1320 | if (input.charCodeAt(peg$currPos) === 32) {
|
|---|
| 1321 | s1 = peg$c2;
|
|---|
| 1322 | peg$currPos++;
|
|---|
| 1323 | } else {
|
|---|
| 1324 | s1 = peg$FAILED;
|
|---|
| 1325 | {
|
|---|
| 1326 | peg$fail(peg$c3);
|
|---|
| 1327 | }
|
|---|
| 1328 | }
|
|---|
| 1329 | }
|
|---|
| 1330 | peg$resultsCache[key] = {
|
|---|
| 1331 | nextPos: peg$currPos,
|
|---|
| 1332 | result: s0
|
|---|
| 1333 | };
|
|---|
| 1334 | return s0;
|
|---|
| 1335 | }
|
|---|
| 1336 | function peg$parseidentifierName() {
|
|---|
| 1337 | var s0, s1, s2;
|
|---|
| 1338 | var key = peg$currPos * 36 + 2,
|
|---|
| 1339 | cached = peg$resultsCache[key];
|
|---|
| 1340 | if (cached) {
|
|---|
| 1341 | peg$currPos = cached.nextPos;
|
|---|
| 1342 | return cached.result;
|
|---|
| 1343 | }
|
|---|
| 1344 | s0 = peg$currPos;
|
|---|
| 1345 | s1 = [];
|
|---|
| 1346 | if (peg$c4.test(input.charAt(peg$currPos))) {
|
|---|
| 1347 | s2 = input.charAt(peg$currPos);
|
|---|
| 1348 | peg$currPos++;
|
|---|
| 1349 | } else {
|
|---|
| 1350 | s2 = peg$FAILED;
|
|---|
| 1351 | {
|
|---|
| 1352 | peg$fail(peg$c5);
|
|---|
| 1353 | }
|
|---|
| 1354 | }
|
|---|
| 1355 | if (s2 !== peg$FAILED) {
|
|---|
| 1356 | while (s2 !== peg$FAILED) {
|
|---|
| 1357 | s1.push(s2);
|
|---|
| 1358 | if (peg$c4.test(input.charAt(peg$currPos))) {
|
|---|
| 1359 | s2 = input.charAt(peg$currPos);
|
|---|
| 1360 | peg$currPos++;
|
|---|
| 1361 | } else {
|
|---|
| 1362 | s2 = peg$FAILED;
|
|---|
| 1363 | {
|
|---|
| 1364 | peg$fail(peg$c5);
|
|---|
| 1365 | }
|
|---|
| 1366 | }
|
|---|
| 1367 | }
|
|---|
| 1368 | } else {
|
|---|
| 1369 | s1 = peg$FAILED;
|
|---|
| 1370 | }
|
|---|
| 1371 | if (s1 !== peg$FAILED) {
|
|---|
| 1372 | s1 = peg$c6(s1);
|
|---|
| 1373 | }
|
|---|
| 1374 | s0 = s1;
|
|---|
| 1375 | peg$resultsCache[key] = {
|
|---|
| 1376 | nextPos: peg$currPos,
|
|---|
| 1377 | result: s0
|
|---|
| 1378 | };
|
|---|
| 1379 | return s0;
|
|---|
| 1380 | }
|
|---|
| 1381 | function peg$parsebinaryOp() {
|
|---|
| 1382 | var s0, s1, s2, s3;
|
|---|
| 1383 | var key = peg$currPos * 36 + 3,
|
|---|
| 1384 | cached = peg$resultsCache[key];
|
|---|
| 1385 | if (cached) {
|
|---|
| 1386 | peg$currPos = cached.nextPos;
|
|---|
| 1387 | return cached.result;
|
|---|
| 1388 | }
|
|---|
| 1389 | s0 = peg$currPos;
|
|---|
| 1390 | s1 = peg$parse_();
|
|---|
| 1391 | if (s1 !== peg$FAILED) {
|
|---|
| 1392 | if (input.charCodeAt(peg$currPos) === 62) {
|
|---|
| 1393 | s2 = peg$c7;
|
|---|
| 1394 | peg$currPos++;
|
|---|
| 1395 | } else {
|
|---|
| 1396 | s2 = peg$FAILED;
|
|---|
| 1397 | {
|
|---|
| 1398 | peg$fail(peg$c8);
|
|---|
| 1399 | }
|
|---|
| 1400 | }
|
|---|
| 1401 | if (s2 !== peg$FAILED) {
|
|---|
| 1402 | s3 = peg$parse_();
|
|---|
| 1403 | if (s3 !== peg$FAILED) {
|
|---|
| 1404 | s1 = peg$c9();
|
|---|
| 1405 | s0 = s1;
|
|---|
| 1406 | } else {
|
|---|
| 1407 | peg$currPos = s0;
|
|---|
| 1408 | s0 = peg$FAILED;
|
|---|
| 1409 | }
|
|---|
| 1410 | } else {
|
|---|
| 1411 | peg$currPos = s0;
|
|---|
| 1412 | s0 = peg$FAILED;
|
|---|
| 1413 | }
|
|---|
| 1414 | } else {
|
|---|
| 1415 | peg$currPos = s0;
|
|---|
| 1416 | s0 = peg$FAILED;
|
|---|
| 1417 | }
|
|---|
| 1418 | if (s0 === peg$FAILED) {
|
|---|
| 1419 | s0 = peg$currPos;
|
|---|
| 1420 | s1 = peg$parse_();
|
|---|
| 1421 | if (s1 !== peg$FAILED) {
|
|---|
| 1422 | if (input.charCodeAt(peg$currPos) === 126) {
|
|---|
| 1423 | s2 = peg$c10;
|
|---|
| 1424 | peg$currPos++;
|
|---|
| 1425 | } else {
|
|---|
| 1426 | s2 = peg$FAILED;
|
|---|
| 1427 | {
|
|---|
| 1428 | peg$fail(peg$c11);
|
|---|
| 1429 | }
|
|---|
| 1430 | }
|
|---|
| 1431 | if (s2 !== peg$FAILED) {
|
|---|
| 1432 | s3 = peg$parse_();
|
|---|
| 1433 | if (s3 !== peg$FAILED) {
|
|---|
| 1434 | s1 = peg$c12();
|
|---|
| 1435 | s0 = s1;
|
|---|
| 1436 | } else {
|
|---|
| 1437 | peg$currPos = s0;
|
|---|
| 1438 | s0 = peg$FAILED;
|
|---|
| 1439 | }
|
|---|
| 1440 | } else {
|
|---|
| 1441 | peg$currPos = s0;
|
|---|
| 1442 | s0 = peg$FAILED;
|
|---|
| 1443 | }
|
|---|
| 1444 | } else {
|
|---|
| 1445 | peg$currPos = s0;
|
|---|
| 1446 | s0 = peg$FAILED;
|
|---|
| 1447 | }
|
|---|
| 1448 | if (s0 === peg$FAILED) {
|
|---|
| 1449 | s0 = peg$currPos;
|
|---|
| 1450 | s1 = peg$parse_();
|
|---|
| 1451 | if (s1 !== peg$FAILED) {
|
|---|
| 1452 | if (input.charCodeAt(peg$currPos) === 43) {
|
|---|
| 1453 | s2 = peg$c13;
|
|---|
| 1454 | peg$currPos++;
|
|---|
| 1455 | } else {
|
|---|
| 1456 | s2 = peg$FAILED;
|
|---|
| 1457 | {
|
|---|
| 1458 | peg$fail(peg$c14);
|
|---|
| 1459 | }
|
|---|
| 1460 | }
|
|---|
| 1461 | if (s2 !== peg$FAILED) {
|
|---|
| 1462 | s3 = peg$parse_();
|
|---|
| 1463 | if (s3 !== peg$FAILED) {
|
|---|
| 1464 | s1 = peg$c15();
|
|---|
| 1465 | s0 = s1;
|
|---|
| 1466 | } else {
|
|---|
| 1467 | peg$currPos = s0;
|
|---|
| 1468 | s0 = peg$FAILED;
|
|---|
| 1469 | }
|
|---|
| 1470 | } else {
|
|---|
| 1471 | peg$currPos = s0;
|
|---|
| 1472 | s0 = peg$FAILED;
|
|---|
| 1473 | }
|
|---|
| 1474 | } else {
|
|---|
| 1475 | peg$currPos = s0;
|
|---|
| 1476 | s0 = peg$FAILED;
|
|---|
| 1477 | }
|
|---|
| 1478 | if (s0 === peg$FAILED) {
|
|---|
| 1479 | s0 = peg$currPos;
|
|---|
| 1480 | if (input.charCodeAt(peg$currPos) === 32) {
|
|---|
| 1481 | s1 = peg$c2;
|
|---|
| 1482 | peg$currPos++;
|
|---|
| 1483 | } else {
|
|---|
| 1484 | s1 = peg$FAILED;
|
|---|
| 1485 | {
|
|---|
| 1486 | peg$fail(peg$c3);
|
|---|
| 1487 | }
|
|---|
| 1488 | }
|
|---|
| 1489 | if (s1 !== peg$FAILED) {
|
|---|
| 1490 | s2 = peg$parse_();
|
|---|
| 1491 | if (s2 !== peg$FAILED) {
|
|---|
| 1492 | s1 = peg$c16();
|
|---|
| 1493 | s0 = s1;
|
|---|
| 1494 | } else {
|
|---|
| 1495 | peg$currPos = s0;
|
|---|
| 1496 | s0 = peg$FAILED;
|
|---|
| 1497 | }
|
|---|
| 1498 | } else {
|
|---|
| 1499 | peg$currPos = s0;
|
|---|
| 1500 | s0 = peg$FAILED;
|
|---|
| 1501 | }
|
|---|
| 1502 | }
|
|---|
| 1503 | }
|
|---|
| 1504 | }
|
|---|
| 1505 | peg$resultsCache[key] = {
|
|---|
| 1506 | nextPos: peg$currPos,
|
|---|
| 1507 | result: s0
|
|---|
| 1508 | };
|
|---|
| 1509 | return s0;
|
|---|
| 1510 | }
|
|---|
| 1511 | function peg$parsehasSelectors() {
|
|---|
| 1512 | var s0, s1, s2, s3, s4, s5, s6, s7;
|
|---|
| 1513 | var key = peg$currPos * 36 + 4,
|
|---|
| 1514 | cached = peg$resultsCache[key];
|
|---|
| 1515 | if (cached) {
|
|---|
| 1516 | peg$currPos = cached.nextPos;
|
|---|
| 1517 | return cached.result;
|
|---|
| 1518 | }
|
|---|
| 1519 | s0 = peg$currPos;
|
|---|
| 1520 | s1 = peg$parsehasSelector();
|
|---|
| 1521 | if (s1 !== peg$FAILED) {
|
|---|
| 1522 | s2 = [];
|
|---|
| 1523 | s3 = peg$currPos;
|
|---|
| 1524 | s4 = peg$parse_();
|
|---|
| 1525 | if (s4 !== peg$FAILED) {
|
|---|
| 1526 | if (input.charCodeAt(peg$currPos) === 44) {
|
|---|
| 1527 | s5 = peg$c17;
|
|---|
| 1528 | peg$currPos++;
|
|---|
| 1529 | } else {
|
|---|
| 1530 | s5 = peg$FAILED;
|
|---|
| 1531 | {
|
|---|
| 1532 | peg$fail(peg$c18);
|
|---|
| 1533 | }
|
|---|
| 1534 | }
|
|---|
| 1535 | if (s5 !== peg$FAILED) {
|
|---|
| 1536 | s6 = peg$parse_();
|
|---|
| 1537 | if (s6 !== peg$FAILED) {
|
|---|
| 1538 | s7 = peg$parsehasSelector();
|
|---|
| 1539 | if (s7 !== peg$FAILED) {
|
|---|
| 1540 | s4 = [s4, s5, s6, s7];
|
|---|
| 1541 | s3 = s4;
|
|---|
| 1542 | } else {
|
|---|
| 1543 | peg$currPos = s3;
|
|---|
| 1544 | s3 = peg$FAILED;
|
|---|
| 1545 | }
|
|---|
| 1546 | } else {
|
|---|
| 1547 | peg$currPos = s3;
|
|---|
| 1548 | s3 = peg$FAILED;
|
|---|
| 1549 | }
|
|---|
| 1550 | } else {
|
|---|
| 1551 | peg$currPos = s3;
|
|---|
| 1552 | s3 = peg$FAILED;
|
|---|
| 1553 | }
|
|---|
| 1554 | } else {
|
|---|
| 1555 | peg$currPos = s3;
|
|---|
| 1556 | s3 = peg$FAILED;
|
|---|
| 1557 | }
|
|---|
| 1558 | while (s3 !== peg$FAILED) {
|
|---|
| 1559 | s2.push(s3);
|
|---|
| 1560 | s3 = peg$currPos;
|
|---|
| 1561 | s4 = peg$parse_();
|
|---|
| 1562 | if (s4 !== peg$FAILED) {
|
|---|
| 1563 | if (input.charCodeAt(peg$currPos) === 44) {
|
|---|
| 1564 | s5 = peg$c17;
|
|---|
| 1565 | peg$currPos++;
|
|---|
| 1566 | } else {
|
|---|
| 1567 | s5 = peg$FAILED;
|
|---|
| 1568 | {
|
|---|
| 1569 | peg$fail(peg$c18);
|
|---|
| 1570 | }
|
|---|
| 1571 | }
|
|---|
| 1572 | if (s5 !== peg$FAILED) {
|
|---|
| 1573 | s6 = peg$parse_();
|
|---|
| 1574 | if (s6 !== peg$FAILED) {
|
|---|
| 1575 | s7 = peg$parsehasSelector();
|
|---|
| 1576 | if (s7 !== peg$FAILED) {
|
|---|
| 1577 | s4 = [s4, s5, s6, s7];
|
|---|
| 1578 | s3 = s4;
|
|---|
| 1579 | } else {
|
|---|
| 1580 | peg$currPos = s3;
|
|---|
| 1581 | s3 = peg$FAILED;
|
|---|
| 1582 | }
|
|---|
| 1583 | } else {
|
|---|
| 1584 | peg$currPos = s3;
|
|---|
| 1585 | s3 = peg$FAILED;
|
|---|
| 1586 | }
|
|---|
| 1587 | } else {
|
|---|
| 1588 | peg$currPos = s3;
|
|---|
| 1589 | s3 = peg$FAILED;
|
|---|
| 1590 | }
|
|---|
| 1591 | } else {
|
|---|
| 1592 | peg$currPos = s3;
|
|---|
| 1593 | s3 = peg$FAILED;
|
|---|
| 1594 | }
|
|---|
| 1595 | }
|
|---|
| 1596 | if (s2 !== peg$FAILED) {
|
|---|
| 1597 | s1 = peg$c19(s1, s2);
|
|---|
| 1598 | s0 = s1;
|
|---|
| 1599 | } else {
|
|---|
| 1600 | peg$currPos = s0;
|
|---|
| 1601 | s0 = peg$FAILED;
|
|---|
| 1602 | }
|
|---|
| 1603 | } else {
|
|---|
| 1604 | peg$currPos = s0;
|
|---|
| 1605 | s0 = peg$FAILED;
|
|---|
| 1606 | }
|
|---|
| 1607 | peg$resultsCache[key] = {
|
|---|
| 1608 | nextPos: peg$currPos,
|
|---|
| 1609 | result: s0
|
|---|
| 1610 | };
|
|---|
| 1611 | return s0;
|
|---|
| 1612 | }
|
|---|
| 1613 | function peg$parseselectors() {
|
|---|
| 1614 | var s0, s1, s2, s3, s4, s5, s6, s7;
|
|---|
| 1615 | var key = peg$currPos * 36 + 5,
|
|---|
| 1616 | cached = peg$resultsCache[key];
|
|---|
| 1617 | if (cached) {
|
|---|
| 1618 | peg$currPos = cached.nextPos;
|
|---|
| 1619 | return cached.result;
|
|---|
| 1620 | }
|
|---|
| 1621 | s0 = peg$currPos;
|
|---|
| 1622 | s1 = peg$parseselector();
|
|---|
| 1623 | if (s1 !== peg$FAILED) {
|
|---|
| 1624 | s2 = [];
|
|---|
| 1625 | s3 = peg$currPos;
|
|---|
| 1626 | s4 = peg$parse_();
|
|---|
| 1627 | if (s4 !== peg$FAILED) {
|
|---|
| 1628 | if (input.charCodeAt(peg$currPos) === 44) {
|
|---|
| 1629 | s5 = peg$c17;
|
|---|
| 1630 | peg$currPos++;
|
|---|
| 1631 | } else {
|
|---|
| 1632 | s5 = peg$FAILED;
|
|---|
| 1633 | {
|
|---|
| 1634 | peg$fail(peg$c18);
|
|---|
| 1635 | }
|
|---|
| 1636 | }
|
|---|
| 1637 | if (s5 !== peg$FAILED) {
|
|---|
| 1638 | s6 = peg$parse_();
|
|---|
| 1639 | if (s6 !== peg$FAILED) {
|
|---|
| 1640 | s7 = peg$parseselector();
|
|---|
| 1641 | if (s7 !== peg$FAILED) {
|
|---|
| 1642 | s4 = [s4, s5, s6, s7];
|
|---|
| 1643 | s3 = s4;
|
|---|
| 1644 | } else {
|
|---|
| 1645 | peg$currPos = s3;
|
|---|
| 1646 | s3 = peg$FAILED;
|
|---|
| 1647 | }
|
|---|
| 1648 | } else {
|
|---|
| 1649 | peg$currPos = s3;
|
|---|
| 1650 | s3 = peg$FAILED;
|
|---|
| 1651 | }
|
|---|
| 1652 | } else {
|
|---|
| 1653 | peg$currPos = s3;
|
|---|
| 1654 | s3 = peg$FAILED;
|
|---|
| 1655 | }
|
|---|
| 1656 | } else {
|
|---|
| 1657 | peg$currPos = s3;
|
|---|
| 1658 | s3 = peg$FAILED;
|
|---|
| 1659 | }
|
|---|
| 1660 | while (s3 !== peg$FAILED) {
|
|---|
| 1661 | s2.push(s3);
|
|---|
| 1662 | s3 = peg$currPos;
|
|---|
| 1663 | s4 = peg$parse_();
|
|---|
| 1664 | if (s4 !== peg$FAILED) {
|
|---|
| 1665 | if (input.charCodeAt(peg$currPos) === 44) {
|
|---|
| 1666 | s5 = peg$c17;
|
|---|
| 1667 | peg$currPos++;
|
|---|
| 1668 | } else {
|
|---|
| 1669 | s5 = peg$FAILED;
|
|---|
| 1670 | {
|
|---|
| 1671 | peg$fail(peg$c18);
|
|---|
| 1672 | }
|
|---|
| 1673 | }
|
|---|
| 1674 | if (s5 !== peg$FAILED) {
|
|---|
| 1675 | s6 = peg$parse_();
|
|---|
| 1676 | if (s6 !== peg$FAILED) {
|
|---|
| 1677 | s7 = peg$parseselector();
|
|---|
| 1678 | if (s7 !== peg$FAILED) {
|
|---|
| 1679 | s4 = [s4, s5, s6, s7];
|
|---|
| 1680 | s3 = s4;
|
|---|
| 1681 | } else {
|
|---|
| 1682 | peg$currPos = s3;
|
|---|
| 1683 | s3 = peg$FAILED;
|
|---|
| 1684 | }
|
|---|
| 1685 | } else {
|
|---|
| 1686 | peg$currPos = s3;
|
|---|
| 1687 | s3 = peg$FAILED;
|
|---|
| 1688 | }
|
|---|
| 1689 | } else {
|
|---|
| 1690 | peg$currPos = s3;
|
|---|
| 1691 | s3 = peg$FAILED;
|
|---|
| 1692 | }
|
|---|
| 1693 | } else {
|
|---|
| 1694 | peg$currPos = s3;
|
|---|
| 1695 | s3 = peg$FAILED;
|
|---|
| 1696 | }
|
|---|
| 1697 | }
|
|---|
| 1698 | if (s2 !== peg$FAILED) {
|
|---|
| 1699 | s1 = peg$c19(s1, s2);
|
|---|
| 1700 | s0 = s1;
|
|---|
| 1701 | } else {
|
|---|
| 1702 | peg$currPos = s0;
|
|---|
| 1703 | s0 = peg$FAILED;
|
|---|
| 1704 | }
|
|---|
| 1705 | } else {
|
|---|
| 1706 | peg$currPos = s0;
|
|---|
| 1707 | s0 = peg$FAILED;
|
|---|
| 1708 | }
|
|---|
| 1709 | peg$resultsCache[key] = {
|
|---|
| 1710 | nextPos: peg$currPos,
|
|---|
| 1711 | result: s0
|
|---|
| 1712 | };
|
|---|
| 1713 | return s0;
|
|---|
| 1714 | }
|
|---|
| 1715 | function peg$parsehasSelector() {
|
|---|
| 1716 | var s0, s1, s2;
|
|---|
| 1717 | var key = peg$currPos * 36 + 6,
|
|---|
| 1718 | cached = peg$resultsCache[key];
|
|---|
| 1719 | if (cached) {
|
|---|
| 1720 | peg$currPos = cached.nextPos;
|
|---|
| 1721 | return cached.result;
|
|---|
| 1722 | }
|
|---|
| 1723 | s0 = peg$currPos;
|
|---|
| 1724 | s1 = peg$parsebinaryOp();
|
|---|
| 1725 | if (s1 === peg$FAILED) {
|
|---|
| 1726 | s1 = null;
|
|---|
| 1727 | }
|
|---|
| 1728 | if (s1 !== peg$FAILED) {
|
|---|
| 1729 | s2 = peg$parseselector();
|
|---|
| 1730 | if (s2 !== peg$FAILED) {
|
|---|
| 1731 | s1 = peg$c20(s1, s2);
|
|---|
| 1732 | s0 = s1;
|
|---|
| 1733 | } else {
|
|---|
| 1734 | peg$currPos = s0;
|
|---|
| 1735 | s0 = peg$FAILED;
|
|---|
| 1736 | }
|
|---|
| 1737 | } else {
|
|---|
| 1738 | peg$currPos = s0;
|
|---|
| 1739 | s0 = peg$FAILED;
|
|---|
| 1740 | }
|
|---|
| 1741 | peg$resultsCache[key] = {
|
|---|
| 1742 | nextPos: peg$currPos,
|
|---|
| 1743 | result: s0
|
|---|
| 1744 | };
|
|---|
| 1745 | return s0;
|
|---|
| 1746 | }
|
|---|
| 1747 | function peg$parseselector() {
|
|---|
| 1748 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 1749 | var key = peg$currPos * 36 + 7,
|
|---|
| 1750 | cached = peg$resultsCache[key];
|
|---|
| 1751 | if (cached) {
|
|---|
| 1752 | peg$currPos = cached.nextPos;
|
|---|
| 1753 | return cached.result;
|
|---|
| 1754 | }
|
|---|
| 1755 | s0 = peg$currPos;
|
|---|
| 1756 | s1 = peg$parsesequence();
|
|---|
| 1757 | if (s1 !== peg$FAILED) {
|
|---|
| 1758 | s2 = [];
|
|---|
| 1759 | s3 = peg$currPos;
|
|---|
| 1760 | s4 = peg$parsebinaryOp();
|
|---|
| 1761 | if (s4 !== peg$FAILED) {
|
|---|
| 1762 | s5 = peg$parsesequence();
|
|---|
| 1763 | if (s5 !== peg$FAILED) {
|
|---|
| 1764 | s4 = [s4, s5];
|
|---|
| 1765 | s3 = s4;
|
|---|
| 1766 | } else {
|
|---|
| 1767 | peg$currPos = s3;
|
|---|
| 1768 | s3 = peg$FAILED;
|
|---|
| 1769 | }
|
|---|
| 1770 | } else {
|
|---|
| 1771 | peg$currPos = s3;
|
|---|
| 1772 | s3 = peg$FAILED;
|
|---|
| 1773 | }
|
|---|
| 1774 | while (s3 !== peg$FAILED) {
|
|---|
| 1775 | s2.push(s3);
|
|---|
| 1776 | s3 = peg$currPos;
|
|---|
| 1777 | s4 = peg$parsebinaryOp();
|
|---|
| 1778 | if (s4 !== peg$FAILED) {
|
|---|
| 1779 | s5 = peg$parsesequence();
|
|---|
| 1780 | if (s5 !== peg$FAILED) {
|
|---|
| 1781 | s4 = [s4, s5];
|
|---|
| 1782 | s3 = s4;
|
|---|
| 1783 | } else {
|
|---|
| 1784 | peg$currPos = s3;
|
|---|
| 1785 | s3 = peg$FAILED;
|
|---|
| 1786 | }
|
|---|
| 1787 | } else {
|
|---|
| 1788 | peg$currPos = s3;
|
|---|
| 1789 | s3 = peg$FAILED;
|
|---|
| 1790 | }
|
|---|
| 1791 | }
|
|---|
| 1792 | if (s2 !== peg$FAILED) {
|
|---|
| 1793 | s1 = peg$c21(s1, s2);
|
|---|
| 1794 | s0 = s1;
|
|---|
| 1795 | } else {
|
|---|
| 1796 | peg$currPos = s0;
|
|---|
| 1797 | s0 = peg$FAILED;
|
|---|
| 1798 | }
|
|---|
| 1799 | } else {
|
|---|
| 1800 | peg$currPos = s0;
|
|---|
| 1801 | s0 = peg$FAILED;
|
|---|
| 1802 | }
|
|---|
| 1803 | peg$resultsCache[key] = {
|
|---|
| 1804 | nextPos: peg$currPos,
|
|---|
| 1805 | result: s0
|
|---|
| 1806 | };
|
|---|
| 1807 | return s0;
|
|---|
| 1808 | }
|
|---|
| 1809 | function peg$parsesequence() {
|
|---|
| 1810 | var s0, s1, s2, s3;
|
|---|
| 1811 | var key = peg$currPos * 36 + 8,
|
|---|
| 1812 | cached = peg$resultsCache[key];
|
|---|
| 1813 | if (cached) {
|
|---|
| 1814 | peg$currPos = cached.nextPos;
|
|---|
| 1815 | return cached.result;
|
|---|
| 1816 | }
|
|---|
| 1817 | s0 = peg$currPos;
|
|---|
| 1818 | if (input.charCodeAt(peg$currPos) === 33) {
|
|---|
| 1819 | s1 = peg$c22;
|
|---|
| 1820 | peg$currPos++;
|
|---|
| 1821 | } else {
|
|---|
| 1822 | s1 = peg$FAILED;
|
|---|
| 1823 | {
|
|---|
| 1824 | peg$fail(peg$c23);
|
|---|
| 1825 | }
|
|---|
| 1826 | }
|
|---|
| 1827 | if (s1 === peg$FAILED) {
|
|---|
| 1828 | s1 = null;
|
|---|
| 1829 | }
|
|---|
| 1830 | if (s1 !== peg$FAILED) {
|
|---|
| 1831 | s2 = [];
|
|---|
| 1832 | s3 = peg$parseatom();
|
|---|
| 1833 | if (s3 !== peg$FAILED) {
|
|---|
| 1834 | while (s3 !== peg$FAILED) {
|
|---|
| 1835 | s2.push(s3);
|
|---|
| 1836 | s3 = peg$parseatom();
|
|---|
| 1837 | }
|
|---|
| 1838 | } else {
|
|---|
| 1839 | s2 = peg$FAILED;
|
|---|
| 1840 | }
|
|---|
| 1841 | if (s2 !== peg$FAILED) {
|
|---|
| 1842 | s1 = peg$c24(s1, s2);
|
|---|
| 1843 | s0 = s1;
|
|---|
| 1844 | } else {
|
|---|
| 1845 | peg$currPos = s0;
|
|---|
| 1846 | s0 = peg$FAILED;
|
|---|
| 1847 | }
|
|---|
| 1848 | } else {
|
|---|
| 1849 | peg$currPos = s0;
|
|---|
| 1850 | s0 = peg$FAILED;
|
|---|
| 1851 | }
|
|---|
| 1852 | peg$resultsCache[key] = {
|
|---|
| 1853 | nextPos: peg$currPos,
|
|---|
| 1854 | result: s0
|
|---|
| 1855 | };
|
|---|
| 1856 | return s0;
|
|---|
| 1857 | }
|
|---|
| 1858 | function peg$parseatom() {
|
|---|
| 1859 | var s0;
|
|---|
| 1860 | var key = peg$currPos * 36 + 9,
|
|---|
| 1861 | cached = peg$resultsCache[key];
|
|---|
| 1862 | if (cached) {
|
|---|
| 1863 | peg$currPos = cached.nextPos;
|
|---|
| 1864 | return cached.result;
|
|---|
| 1865 | }
|
|---|
| 1866 | s0 = peg$parsewildcard();
|
|---|
| 1867 | if (s0 === peg$FAILED) {
|
|---|
| 1868 | s0 = peg$parseidentifier();
|
|---|
| 1869 | if (s0 === peg$FAILED) {
|
|---|
| 1870 | s0 = peg$parseattr();
|
|---|
| 1871 | if (s0 === peg$FAILED) {
|
|---|
| 1872 | s0 = peg$parsefield();
|
|---|
| 1873 | if (s0 === peg$FAILED) {
|
|---|
| 1874 | s0 = peg$parsenegation();
|
|---|
| 1875 | if (s0 === peg$FAILED) {
|
|---|
| 1876 | s0 = peg$parsematches();
|
|---|
| 1877 | if (s0 === peg$FAILED) {
|
|---|
| 1878 | s0 = peg$parseis();
|
|---|
| 1879 | if (s0 === peg$FAILED) {
|
|---|
| 1880 | s0 = peg$parsehas();
|
|---|
| 1881 | if (s0 === peg$FAILED) {
|
|---|
| 1882 | s0 = peg$parsefirstChild();
|
|---|
| 1883 | if (s0 === peg$FAILED) {
|
|---|
| 1884 | s0 = peg$parselastChild();
|
|---|
| 1885 | if (s0 === peg$FAILED) {
|
|---|
| 1886 | s0 = peg$parsenthChild();
|
|---|
| 1887 | if (s0 === peg$FAILED) {
|
|---|
| 1888 | s0 = peg$parsenthLastChild();
|
|---|
| 1889 | if (s0 === peg$FAILED) {
|
|---|
| 1890 | s0 = peg$parseclass();
|
|---|
| 1891 | }
|
|---|
| 1892 | }
|
|---|
| 1893 | }
|
|---|
| 1894 | }
|
|---|
| 1895 | }
|
|---|
| 1896 | }
|
|---|
| 1897 | }
|
|---|
| 1898 | }
|
|---|
| 1899 | }
|
|---|
| 1900 | }
|
|---|
| 1901 | }
|
|---|
| 1902 | }
|
|---|
| 1903 | peg$resultsCache[key] = {
|
|---|
| 1904 | nextPos: peg$currPos,
|
|---|
| 1905 | result: s0
|
|---|
| 1906 | };
|
|---|
| 1907 | return s0;
|
|---|
| 1908 | }
|
|---|
| 1909 | function peg$parsewildcard() {
|
|---|
| 1910 | var s0, s1;
|
|---|
| 1911 | var key = peg$currPos * 36 + 10,
|
|---|
| 1912 | cached = peg$resultsCache[key];
|
|---|
| 1913 | if (cached) {
|
|---|
| 1914 | peg$currPos = cached.nextPos;
|
|---|
| 1915 | return cached.result;
|
|---|
| 1916 | }
|
|---|
| 1917 | s0 = peg$currPos;
|
|---|
| 1918 | if (input.charCodeAt(peg$currPos) === 42) {
|
|---|
| 1919 | s1 = peg$c25;
|
|---|
| 1920 | peg$currPos++;
|
|---|
| 1921 | } else {
|
|---|
| 1922 | s1 = peg$FAILED;
|
|---|
| 1923 | {
|
|---|
| 1924 | peg$fail(peg$c26);
|
|---|
| 1925 | }
|
|---|
| 1926 | }
|
|---|
| 1927 | if (s1 !== peg$FAILED) {
|
|---|
| 1928 | s1 = peg$c27(s1);
|
|---|
| 1929 | }
|
|---|
| 1930 | s0 = s1;
|
|---|
| 1931 | peg$resultsCache[key] = {
|
|---|
| 1932 | nextPos: peg$currPos,
|
|---|
| 1933 | result: s0
|
|---|
| 1934 | };
|
|---|
| 1935 | return s0;
|
|---|
| 1936 | }
|
|---|
| 1937 | function peg$parseidentifier() {
|
|---|
| 1938 | var s0, s1, s2;
|
|---|
| 1939 | var key = peg$currPos * 36 + 11,
|
|---|
| 1940 | cached = peg$resultsCache[key];
|
|---|
| 1941 | if (cached) {
|
|---|
| 1942 | peg$currPos = cached.nextPos;
|
|---|
| 1943 | return cached.result;
|
|---|
| 1944 | }
|
|---|
| 1945 | s0 = peg$currPos;
|
|---|
| 1946 | if (input.charCodeAt(peg$currPos) === 35) {
|
|---|
| 1947 | s1 = peg$c28;
|
|---|
| 1948 | peg$currPos++;
|
|---|
| 1949 | } else {
|
|---|
| 1950 | s1 = peg$FAILED;
|
|---|
| 1951 | {
|
|---|
| 1952 | peg$fail(peg$c29);
|
|---|
| 1953 | }
|
|---|
| 1954 | }
|
|---|
| 1955 | if (s1 === peg$FAILED) {
|
|---|
| 1956 | s1 = null;
|
|---|
| 1957 | }
|
|---|
| 1958 | if (s1 !== peg$FAILED) {
|
|---|
| 1959 | s2 = peg$parseidentifierName();
|
|---|
| 1960 | if (s2 !== peg$FAILED) {
|
|---|
| 1961 | s1 = peg$c30(s2);
|
|---|
| 1962 | s0 = s1;
|
|---|
| 1963 | } else {
|
|---|
| 1964 | peg$currPos = s0;
|
|---|
| 1965 | s0 = peg$FAILED;
|
|---|
| 1966 | }
|
|---|
| 1967 | } else {
|
|---|
| 1968 | peg$currPos = s0;
|
|---|
| 1969 | s0 = peg$FAILED;
|
|---|
| 1970 | }
|
|---|
| 1971 | peg$resultsCache[key] = {
|
|---|
| 1972 | nextPos: peg$currPos,
|
|---|
| 1973 | result: s0
|
|---|
| 1974 | };
|
|---|
| 1975 | return s0;
|
|---|
| 1976 | }
|
|---|
| 1977 | function peg$parseattr() {
|
|---|
| 1978 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 1979 | var key = peg$currPos * 36 + 12,
|
|---|
| 1980 | cached = peg$resultsCache[key];
|
|---|
| 1981 | if (cached) {
|
|---|
| 1982 | peg$currPos = cached.nextPos;
|
|---|
| 1983 | return cached.result;
|
|---|
| 1984 | }
|
|---|
| 1985 | s0 = peg$currPos;
|
|---|
| 1986 | if (input.charCodeAt(peg$currPos) === 91) {
|
|---|
| 1987 | s1 = peg$c31;
|
|---|
| 1988 | peg$currPos++;
|
|---|
| 1989 | } else {
|
|---|
| 1990 | s1 = peg$FAILED;
|
|---|
| 1991 | {
|
|---|
| 1992 | peg$fail(peg$c32);
|
|---|
| 1993 | }
|
|---|
| 1994 | }
|
|---|
| 1995 | if (s1 !== peg$FAILED) {
|
|---|
| 1996 | s2 = peg$parse_();
|
|---|
| 1997 | if (s2 !== peg$FAILED) {
|
|---|
| 1998 | s3 = peg$parseattrValue();
|
|---|
| 1999 | if (s3 !== peg$FAILED) {
|
|---|
| 2000 | s4 = peg$parse_();
|
|---|
| 2001 | if (s4 !== peg$FAILED) {
|
|---|
| 2002 | if (input.charCodeAt(peg$currPos) === 93) {
|
|---|
| 2003 | s5 = peg$c33;
|
|---|
| 2004 | peg$currPos++;
|
|---|
| 2005 | } else {
|
|---|
| 2006 | s5 = peg$FAILED;
|
|---|
| 2007 | {
|
|---|
| 2008 | peg$fail(peg$c34);
|
|---|
| 2009 | }
|
|---|
| 2010 | }
|
|---|
| 2011 | if (s5 !== peg$FAILED) {
|
|---|
| 2012 | s1 = peg$c35(s3);
|
|---|
| 2013 | s0 = s1;
|
|---|
| 2014 | } else {
|
|---|
| 2015 | peg$currPos = s0;
|
|---|
| 2016 | s0 = peg$FAILED;
|
|---|
| 2017 | }
|
|---|
| 2018 | } else {
|
|---|
| 2019 | peg$currPos = s0;
|
|---|
| 2020 | s0 = peg$FAILED;
|
|---|
| 2021 | }
|
|---|
| 2022 | } else {
|
|---|
| 2023 | peg$currPos = s0;
|
|---|
| 2024 | s0 = peg$FAILED;
|
|---|
| 2025 | }
|
|---|
| 2026 | } else {
|
|---|
| 2027 | peg$currPos = s0;
|
|---|
| 2028 | s0 = peg$FAILED;
|
|---|
| 2029 | }
|
|---|
| 2030 | } else {
|
|---|
| 2031 | peg$currPos = s0;
|
|---|
| 2032 | s0 = peg$FAILED;
|
|---|
| 2033 | }
|
|---|
| 2034 | peg$resultsCache[key] = {
|
|---|
| 2035 | nextPos: peg$currPos,
|
|---|
| 2036 | result: s0
|
|---|
| 2037 | };
|
|---|
| 2038 | return s0;
|
|---|
| 2039 | }
|
|---|
| 2040 | function peg$parseattrOps() {
|
|---|
| 2041 | var s0, s1, s2;
|
|---|
| 2042 | var key = peg$currPos * 36 + 13,
|
|---|
| 2043 | cached = peg$resultsCache[key];
|
|---|
| 2044 | if (cached) {
|
|---|
| 2045 | peg$currPos = cached.nextPos;
|
|---|
| 2046 | return cached.result;
|
|---|
| 2047 | }
|
|---|
| 2048 | s0 = peg$currPos;
|
|---|
| 2049 | if (peg$c36.test(input.charAt(peg$currPos))) {
|
|---|
| 2050 | s1 = input.charAt(peg$currPos);
|
|---|
| 2051 | peg$currPos++;
|
|---|
| 2052 | } else {
|
|---|
| 2053 | s1 = peg$FAILED;
|
|---|
| 2054 | {
|
|---|
| 2055 | peg$fail(peg$c37);
|
|---|
| 2056 | }
|
|---|
| 2057 | }
|
|---|
| 2058 | if (s1 === peg$FAILED) {
|
|---|
| 2059 | s1 = null;
|
|---|
| 2060 | }
|
|---|
| 2061 | if (s1 !== peg$FAILED) {
|
|---|
| 2062 | if (input.charCodeAt(peg$currPos) === 61) {
|
|---|
| 2063 | s2 = peg$c38;
|
|---|
| 2064 | peg$currPos++;
|
|---|
| 2065 | } else {
|
|---|
| 2066 | s2 = peg$FAILED;
|
|---|
| 2067 | {
|
|---|
| 2068 | peg$fail(peg$c39);
|
|---|
| 2069 | }
|
|---|
| 2070 | }
|
|---|
| 2071 | if (s2 !== peg$FAILED) {
|
|---|
| 2072 | s1 = peg$c40(s1);
|
|---|
| 2073 | s0 = s1;
|
|---|
| 2074 | } else {
|
|---|
| 2075 | peg$currPos = s0;
|
|---|
| 2076 | s0 = peg$FAILED;
|
|---|
| 2077 | }
|
|---|
| 2078 | } else {
|
|---|
| 2079 | peg$currPos = s0;
|
|---|
| 2080 | s0 = peg$FAILED;
|
|---|
| 2081 | }
|
|---|
| 2082 | if (s0 === peg$FAILED) {
|
|---|
| 2083 | if (peg$c41.test(input.charAt(peg$currPos))) {
|
|---|
| 2084 | s0 = input.charAt(peg$currPos);
|
|---|
| 2085 | peg$currPos++;
|
|---|
| 2086 | } else {
|
|---|
| 2087 | s0 = peg$FAILED;
|
|---|
| 2088 | {
|
|---|
| 2089 | peg$fail(peg$c42);
|
|---|
| 2090 | }
|
|---|
| 2091 | }
|
|---|
| 2092 | }
|
|---|
| 2093 | peg$resultsCache[key] = {
|
|---|
| 2094 | nextPos: peg$currPos,
|
|---|
| 2095 | result: s0
|
|---|
| 2096 | };
|
|---|
| 2097 | return s0;
|
|---|
| 2098 | }
|
|---|
| 2099 | function peg$parseattrEqOps() {
|
|---|
| 2100 | var s0, s1, s2;
|
|---|
| 2101 | var key = peg$currPos * 36 + 14,
|
|---|
| 2102 | cached = peg$resultsCache[key];
|
|---|
| 2103 | if (cached) {
|
|---|
| 2104 | peg$currPos = cached.nextPos;
|
|---|
| 2105 | return cached.result;
|
|---|
| 2106 | }
|
|---|
| 2107 | s0 = peg$currPos;
|
|---|
| 2108 | if (input.charCodeAt(peg$currPos) === 33) {
|
|---|
| 2109 | s1 = peg$c22;
|
|---|
| 2110 | peg$currPos++;
|
|---|
| 2111 | } else {
|
|---|
| 2112 | s1 = peg$FAILED;
|
|---|
| 2113 | {
|
|---|
| 2114 | peg$fail(peg$c23);
|
|---|
| 2115 | }
|
|---|
| 2116 | }
|
|---|
| 2117 | if (s1 === peg$FAILED) {
|
|---|
| 2118 | s1 = null;
|
|---|
| 2119 | }
|
|---|
| 2120 | if (s1 !== peg$FAILED) {
|
|---|
| 2121 | if (input.charCodeAt(peg$currPos) === 61) {
|
|---|
| 2122 | s2 = peg$c38;
|
|---|
| 2123 | peg$currPos++;
|
|---|
| 2124 | } else {
|
|---|
| 2125 | s2 = peg$FAILED;
|
|---|
| 2126 | {
|
|---|
| 2127 | peg$fail(peg$c39);
|
|---|
| 2128 | }
|
|---|
| 2129 | }
|
|---|
| 2130 | if (s2 !== peg$FAILED) {
|
|---|
| 2131 | s1 = peg$c40(s1);
|
|---|
| 2132 | s0 = s1;
|
|---|
| 2133 | } else {
|
|---|
| 2134 | peg$currPos = s0;
|
|---|
| 2135 | s0 = peg$FAILED;
|
|---|
| 2136 | }
|
|---|
| 2137 | } else {
|
|---|
| 2138 | peg$currPos = s0;
|
|---|
| 2139 | s0 = peg$FAILED;
|
|---|
| 2140 | }
|
|---|
| 2141 | peg$resultsCache[key] = {
|
|---|
| 2142 | nextPos: peg$currPos,
|
|---|
| 2143 | result: s0
|
|---|
| 2144 | };
|
|---|
| 2145 | return s0;
|
|---|
| 2146 | }
|
|---|
| 2147 | function peg$parseattrName() {
|
|---|
| 2148 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 2149 | var key = peg$currPos * 36 + 15,
|
|---|
| 2150 | cached = peg$resultsCache[key];
|
|---|
| 2151 | if (cached) {
|
|---|
| 2152 | peg$currPos = cached.nextPos;
|
|---|
| 2153 | return cached.result;
|
|---|
| 2154 | }
|
|---|
| 2155 | s0 = peg$currPos;
|
|---|
| 2156 | s1 = peg$parseidentifierName();
|
|---|
| 2157 | if (s1 !== peg$FAILED) {
|
|---|
| 2158 | s2 = [];
|
|---|
| 2159 | s3 = peg$currPos;
|
|---|
| 2160 | if (input.charCodeAt(peg$currPos) === 46) {
|
|---|
| 2161 | s4 = peg$c43;
|
|---|
| 2162 | peg$currPos++;
|
|---|
| 2163 | } else {
|
|---|
| 2164 | s4 = peg$FAILED;
|
|---|
| 2165 | {
|
|---|
| 2166 | peg$fail(peg$c44);
|
|---|
| 2167 | }
|
|---|
| 2168 | }
|
|---|
| 2169 | if (s4 !== peg$FAILED) {
|
|---|
| 2170 | s5 = peg$parseidentifierName();
|
|---|
| 2171 | if (s5 !== peg$FAILED) {
|
|---|
| 2172 | s4 = [s4, s5];
|
|---|
| 2173 | s3 = s4;
|
|---|
| 2174 | } else {
|
|---|
| 2175 | peg$currPos = s3;
|
|---|
| 2176 | s3 = peg$FAILED;
|
|---|
| 2177 | }
|
|---|
| 2178 | } else {
|
|---|
| 2179 | peg$currPos = s3;
|
|---|
| 2180 | s3 = peg$FAILED;
|
|---|
| 2181 | }
|
|---|
| 2182 | while (s3 !== peg$FAILED) {
|
|---|
| 2183 | s2.push(s3);
|
|---|
| 2184 | s3 = peg$currPos;
|
|---|
| 2185 | if (input.charCodeAt(peg$currPos) === 46) {
|
|---|
| 2186 | s4 = peg$c43;
|
|---|
| 2187 | peg$currPos++;
|
|---|
| 2188 | } else {
|
|---|
| 2189 | s4 = peg$FAILED;
|
|---|
| 2190 | {
|
|---|
| 2191 | peg$fail(peg$c44);
|
|---|
| 2192 | }
|
|---|
| 2193 | }
|
|---|
| 2194 | if (s4 !== peg$FAILED) {
|
|---|
| 2195 | s5 = peg$parseidentifierName();
|
|---|
| 2196 | if (s5 !== peg$FAILED) {
|
|---|
| 2197 | s4 = [s4, s5];
|
|---|
| 2198 | s3 = s4;
|
|---|
| 2199 | } else {
|
|---|
| 2200 | peg$currPos = s3;
|
|---|
| 2201 | s3 = peg$FAILED;
|
|---|
| 2202 | }
|
|---|
| 2203 | } else {
|
|---|
| 2204 | peg$currPos = s3;
|
|---|
| 2205 | s3 = peg$FAILED;
|
|---|
| 2206 | }
|
|---|
| 2207 | }
|
|---|
| 2208 | if (s2 !== peg$FAILED) {
|
|---|
| 2209 | s1 = peg$c45(s1, s2);
|
|---|
| 2210 | s0 = s1;
|
|---|
| 2211 | } else {
|
|---|
| 2212 | peg$currPos = s0;
|
|---|
| 2213 | s0 = peg$FAILED;
|
|---|
| 2214 | }
|
|---|
| 2215 | } else {
|
|---|
| 2216 | peg$currPos = s0;
|
|---|
| 2217 | s0 = peg$FAILED;
|
|---|
| 2218 | }
|
|---|
| 2219 | peg$resultsCache[key] = {
|
|---|
| 2220 | nextPos: peg$currPos,
|
|---|
| 2221 | result: s0
|
|---|
| 2222 | };
|
|---|
| 2223 | return s0;
|
|---|
| 2224 | }
|
|---|
| 2225 | function peg$parseattrValue() {
|
|---|
| 2226 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 2227 | var key = peg$currPos * 36 + 16,
|
|---|
| 2228 | cached = peg$resultsCache[key];
|
|---|
| 2229 | if (cached) {
|
|---|
| 2230 | peg$currPos = cached.nextPos;
|
|---|
| 2231 | return cached.result;
|
|---|
| 2232 | }
|
|---|
| 2233 | s0 = peg$currPos;
|
|---|
| 2234 | s1 = peg$parseattrName();
|
|---|
| 2235 | if (s1 !== peg$FAILED) {
|
|---|
| 2236 | s2 = peg$parse_();
|
|---|
| 2237 | if (s2 !== peg$FAILED) {
|
|---|
| 2238 | s3 = peg$parseattrEqOps();
|
|---|
| 2239 | if (s3 !== peg$FAILED) {
|
|---|
| 2240 | s4 = peg$parse_();
|
|---|
| 2241 | if (s4 !== peg$FAILED) {
|
|---|
| 2242 | s5 = peg$parsetype();
|
|---|
| 2243 | if (s5 === peg$FAILED) {
|
|---|
| 2244 | s5 = peg$parseregex();
|
|---|
| 2245 | }
|
|---|
| 2246 | if (s5 !== peg$FAILED) {
|
|---|
| 2247 | s1 = peg$c46(s1, s3, s5);
|
|---|
| 2248 | s0 = s1;
|
|---|
| 2249 | } else {
|
|---|
| 2250 | peg$currPos = s0;
|
|---|
| 2251 | s0 = peg$FAILED;
|
|---|
| 2252 | }
|
|---|
| 2253 | } else {
|
|---|
| 2254 | peg$currPos = s0;
|
|---|
| 2255 | s0 = peg$FAILED;
|
|---|
| 2256 | }
|
|---|
| 2257 | } else {
|
|---|
| 2258 | peg$currPos = s0;
|
|---|
| 2259 | s0 = peg$FAILED;
|
|---|
| 2260 | }
|
|---|
| 2261 | } else {
|
|---|
| 2262 | peg$currPos = s0;
|
|---|
| 2263 | s0 = peg$FAILED;
|
|---|
| 2264 | }
|
|---|
| 2265 | } else {
|
|---|
| 2266 | peg$currPos = s0;
|
|---|
| 2267 | s0 = peg$FAILED;
|
|---|
| 2268 | }
|
|---|
| 2269 | if (s0 === peg$FAILED) {
|
|---|
| 2270 | s0 = peg$currPos;
|
|---|
| 2271 | s1 = peg$parseattrName();
|
|---|
| 2272 | if (s1 !== peg$FAILED) {
|
|---|
| 2273 | s2 = peg$parse_();
|
|---|
| 2274 | if (s2 !== peg$FAILED) {
|
|---|
| 2275 | s3 = peg$parseattrOps();
|
|---|
| 2276 | if (s3 !== peg$FAILED) {
|
|---|
| 2277 | s4 = peg$parse_();
|
|---|
| 2278 | if (s4 !== peg$FAILED) {
|
|---|
| 2279 | s5 = peg$parsestring();
|
|---|
| 2280 | if (s5 === peg$FAILED) {
|
|---|
| 2281 | s5 = peg$parsenumber();
|
|---|
| 2282 | if (s5 === peg$FAILED) {
|
|---|
| 2283 | s5 = peg$parsepath();
|
|---|
| 2284 | }
|
|---|
| 2285 | }
|
|---|
| 2286 | if (s5 !== peg$FAILED) {
|
|---|
| 2287 | s1 = peg$c46(s1, s3, s5);
|
|---|
| 2288 | s0 = s1;
|
|---|
| 2289 | } else {
|
|---|
| 2290 | peg$currPos = s0;
|
|---|
| 2291 | s0 = peg$FAILED;
|
|---|
| 2292 | }
|
|---|
| 2293 | } else {
|
|---|
| 2294 | peg$currPos = s0;
|
|---|
| 2295 | s0 = peg$FAILED;
|
|---|
| 2296 | }
|
|---|
| 2297 | } else {
|
|---|
| 2298 | peg$currPos = s0;
|
|---|
| 2299 | s0 = peg$FAILED;
|
|---|
| 2300 | }
|
|---|
| 2301 | } else {
|
|---|
| 2302 | peg$currPos = s0;
|
|---|
| 2303 | s0 = peg$FAILED;
|
|---|
| 2304 | }
|
|---|
| 2305 | } else {
|
|---|
| 2306 | peg$currPos = s0;
|
|---|
| 2307 | s0 = peg$FAILED;
|
|---|
| 2308 | }
|
|---|
| 2309 | if (s0 === peg$FAILED) {
|
|---|
| 2310 | s0 = peg$currPos;
|
|---|
| 2311 | s1 = peg$parseattrName();
|
|---|
| 2312 | if (s1 !== peg$FAILED) {
|
|---|
| 2313 | s1 = peg$c47(s1);
|
|---|
| 2314 | }
|
|---|
| 2315 | s0 = s1;
|
|---|
| 2316 | }
|
|---|
| 2317 | }
|
|---|
| 2318 | peg$resultsCache[key] = {
|
|---|
| 2319 | nextPos: peg$currPos,
|
|---|
| 2320 | result: s0
|
|---|
| 2321 | };
|
|---|
| 2322 | return s0;
|
|---|
| 2323 | }
|
|---|
| 2324 | function peg$parsestring() {
|
|---|
| 2325 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 2326 | var key = peg$currPos * 36 + 17,
|
|---|
| 2327 | cached = peg$resultsCache[key];
|
|---|
| 2328 | if (cached) {
|
|---|
| 2329 | peg$currPos = cached.nextPos;
|
|---|
| 2330 | return cached.result;
|
|---|
| 2331 | }
|
|---|
| 2332 | s0 = peg$currPos;
|
|---|
| 2333 | if (input.charCodeAt(peg$currPos) === 34) {
|
|---|
| 2334 | s1 = peg$c48;
|
|---|
| 2335 | peg$currPos++;
|
|---|
| 2336 | } else {
|
|---|
| 2337 | s1 = peg$FAILED;
|
|---|
| 2338 | {
|
|---|
| 2339 | peg$fail(peg$c49);
|
|---|
| 2340 | }
|
|---|
| 2341 | }
|
|---|
| 2342 | if (s1 !== peg$FAILED) {
|
|---|
| 2343 | s2 = [];
|
|---|
| 2344 | if (peg$c50.test(input.charAt(peg$currPos))) {
|
|---|
| 2345 | s3 = input.charAt(peg$currPos);
|
|---|
| 2346 | peg$currPos++;
|
|---|
| 2347 | } else {
|
|---|
| 2348 | s3 = peg$FAILED;
|
|---|
| 2349 | {
|
|---|
| 2350 | peg$fail(peg$c51);
|
|---|
| 2351 | }
|
|---|
| 2352 | }
|
|---|
| 2353 | if (s3 === peg$FAILED) {
|
|---|
| 2354 | s3 = peg$currPos;
|
|---|
| 2355 | if (input.charCodeAt(peg$currPos) === 92) {
|
|---|
| 2356 | s4 = peg$c52;
|
|---|
| 2357 | peg$currPos++;
|
|---|
| 2358 | } else {
|
|---|
| 2359 | s4 = peg$FAILED;
|
|---|
| 2360 | {
|
|---|
| 2361 | peg$fail(peg$c53);
|
|---|
| 2362 | }
|
|---|
| 2363 | }
|
|---|
| 2364 | if (s4 !== peg$FAILED) {
|
|---|
| 2365 | if (input.length > peg$currPos) {
|
|---|
| 2366 | s5 = input.charAt(peg$currPos);
|
|---|
| 2367 | peg$currPos++;
|
|---|
| 2368 | } else {
|
|---|
| 2369 | s5 = peg$FAILED;
|
|---|
| 2370 | {
|
|---|
| 2371 | peg$fail(peg$c54);
|
|---|
| 2372 | }
|
|---|
| 2373 | }
|
|---|
| 2374 | if (s5 !== peg$FAILED) {
|
|---|
| 2375 | s4 = peg$c55(s4, s5);
|
|---|
| 2376 | s3 = s4;
|
|---|
| 2377 | } else {
|
|---|
| 2378 | peg$currPos = s3;
|
|---|
| 2379 | s3 = peg$FAILED;
|
|---|
| 2380 | }
|
|---|
| 2381 | } else {
|
|---|
| 2382 | peg$currPos = s3;
|
|---|
| 2383 | s3 = peg$FAILED;
|
|---|
| 2384 | }
|
|---|
| 2385 | }
|
|---|
| 2386 | while (s3 !== peg$FAILED) {
|
|---|
| 2387 | s2.push(s3);
|
|---|
| 2388 | if (peg$c50.test(input.charAt(peg$currPos))) {
|
|---|
| 2389 | s3 = input.charAt(peg$currPos);
|
|---|
| 2390 | peg$currPos++;
|
|---|
| 2391 | } else {
|
|---|
| 2392 | s3 = peg$FAILED;
|
|---|
| 2393 | {
|
|---|
| 2394 | peg$fail(peg$c51);
|
|---|
| 2395 | }
|
|---|
| 2396 | }
|
|---|
| 2397 | if (s3 === peg$FAILED) {
|
|---|
| 2398 | s3 = peg$currPos;
|
|---|
| 2399 | if (input.charCodeAt(peg$currPos) === 92) {
|
|---|
| 2400 | s4 = peg$c52;
|
|---|
| 2401 | peg$currPos++;
|
|---|
| 2402 | } else {
|
|---|
| 2403 | s4 = peg$FAILED;
|
|---|
| 2404 | {
|
|---|
| 2405 | peg$fail(peg$c53);
|
|---|
| 2406 | }
|
|---|
| 2407 | }
|
|---|
| 2408 | if (s4 !== peg$FAILED) {
|
|---|
| 2409 | if (input.length > peg$currPos) {
|
|---|
| 2410 | s5 = input.charAt(peg$currPos);
|
|---|
| 2411 | peg$currPos++;
|
|---|
| 2412 | } else {
|
|---|
| 2413 | s5 = peg$FAILED;
|
|---|
| 2414 | {
|
|---|
| 2415 | peg$fail(peg$c54);
|
|---|
| 2416 | }
|
|---|
| 2417 | }
|
|---|
| 2418 | if (s5 !== peg$FAILED) {
|
|---|
| 2419 | s4 = peg$c55(s4, s5);
|
|---|
| 2420 | s3 = s4;
|
|---|
| 2421 | } else {
|
|---|
| 2422 | peg$currPos = s3;
|
|---|
| 2423 | s3 = peg$FAILED;
|
|---|
| 2424 | }
|
|---|
| 2425 | } else {
|
|---|
| 2426 | peg$currPos = s3;
|
|---|
| 2427 | s3 = peg$FAILED;
|
|---|
| 2428 | }
|
|---|
| 2429 | }
|
|---|
| 2430 | }
|
|---|
| 2431 | if (s2 !== peg$FAILED) {
|
|---|
| 2432 | if (input.charCodeAt(peg$currPos) === 34) {
|
|---|
| 2433 | s3 = peg$c48;
|
|---|
| 2434 | peg$currPos++;
|
|---|
| 2435 | } else {
|
|---|
| 2436 | s3 = peg$FAILED;
|
|---|
| 2437 | {
|
|---|
| 2438 | peg$fail(peg$c49);
|
|---|
| 2439 | }
|
|---|
| 2440 | }
|
|---|
| 2441 | if (s3 !== peg$FAILED) {
|
|---|
| 2442 | s1 = peg$c56(s2);
|
|---|
| 2443 | s0 = s1;
|
|---|
| 2444 | } else {
|
|---|
| 2445 | peg$currPos = s0;
|
|---|
| 2446 | s0 = peg$FAILED;
|
|---|
| 2447 | }
|
|---|
| 2448 | } else {
|
|---|
| 2449 | peg$currPos = s0;
|
|---|
| 2450 | s0 = peg$FAILED;
|
|---|
| 2451 | }
|
|---|
| 2452 | } else {
|
|---|
| 2453 | peg$currPos = s0;
|
|---|
| 2454 | s0 = peg$FAILED;
|
|---|
| 2455 | }
|
|---|
| 2456 | if (s0 === peg$FAILED) {
|
|---|
| 2457 | s0 = peg$currPos;
|
|---|
| 2458 | if (input.charCodeAt(peg$currPos) === 39) {
|
|---|
| 2459 | s1 = peg$c57;
|
|---|
| 2460 | peg$currPos++;
|
|---|
| 2461 | } else {
|
|---|
| 2462 | s1 = peg$FAILED;
|
|---|
| 2463 | {
|
|---|
| 2464 | peg$fail(peg$c58);
|
|---|
| 2465 | }
|
|---|
| 2466 | }
|
|---|
| 2467 | if (s1 !== peg$FAILED) {
|
|---|
| 2468 | s2 = [];
|
|---|
| 2469 | if (peg$c59.test(input.charAt(peg$currPos))) {
|
|---|
| 2470 | s3 = input.charAt(peg$currPos);
|
|---|
| 2471 | peg$currPos++;
|
|---|
| 2472 | } else {
|
|---|
| 2473 | s3 = peg$FAILED;
|
|---|
| 2474 | {
|
|---|
| 2475 | peg$fail(peg$c60);
|
|---|
| 2476 | }
|
|---|
| 2477 | }
|
|---|
| 2478 | if (s3 === peg$FAILED) {
|
|---|
| 2479 | s3 = peg$currPos;
|
|---|
| 2480 | if (input.charCodeAt(peg$currPos) === 92) {
|
|---|
| 2481 | s4 = peg$c52;
|
|---|
| 2482 | peg$currPos++;
|
|---|
| 2483 | } else {
|
|---|
| 2484 | s4 = peg$FAILED;
|
|---|
| 2485 | {
|
|---|
| 2486 | peg$fail(peg$c53);
|
|---|
| 2487 | }
|
|---|
| 2488 | }
|
|---|
| 2489 | if (s4 !== peg$FAILED) {
|
|---|
| 2490 | if (input.length > peg$currPos) {
|
|---|
| 2491 | s5 = input.charAt(peg$currPos);
|
|---|
| 2492 | peg$currPos++;
|
|---|
| 2493 | } else {
|
|---|
| 2494 | s5 = peg$FAILED;
|
|---|
| 2495 | {
|
|---|
| 2496 | peg$fail(peg$c54);
|
|---|
| 2497 | }
|
|---|
| 2498 | }
|
|---|
| 2499 | if (s5 !== peg$FAILED) {
|
|---|
| 2500 | s4 = peg$c55(s4, s5);
|
|---|
| 2501 | s3 = s4;
|
|---|
| 2502 | } else {
|
|---|
| 2503 | peg$currPos = s3;
|
|---|
| 2504 | s3 = peg$FAILED;
|
|---|
| 2505 | }
|
|---|
| 2506 | } else {
|
|---|
| 2507 | peg$currPos = s3;
|
|---|
| 2508 | s3 = peg$FAILED;
|
|---|
| 2509 | }
|
|---|
| 2510 | }
|
|---|
| 2511 | while (s3 !== peg$FAILED) {
|
|---|
| 2512 | s2.push(s3);
|
|---|
| 2513 | if (peg$c59.test(input.charAt(peg$currPos))) {
|
|---|
| 2514 | s3 = input.charAt(peg$currPos);
|
|---|
| 2515 | peg$currPos++;
|
|---|
| 2516 | } else {
|
|---|
| 2517 | s3 = peg$FAILED;
|
|---|
| 2518 | {
|
|---|
| 2519 | peg$fail(peg$c60);
|
|---|
| 2520 | }
|
|---|
| 2521 | }
|
|---|
| 2522 | if (s3 === peg$FAILED) {
|
|---|
| 2523 | s3 = peg$currPos;
|
|---|
| 2524 | if (input.charCodeAt(peg$currPos) === 92) {
|
|---|
| 2525 | s4 = peg$c52;
|
|---|
| 2526 | peg$currPos++;
|
|---|
| 2527 | } else {
|
|---|
| 2528 | s4 = peg$FAILED;
|
|---|
| 2529 | {
|
|---|
| 2530 | peg$fail(peg$c53);
|
|---|
| 2531 | }
|
|---|
| 2532 | }
|
|---|
| 2533 | if (s4 !== peg$FAILED) {
|
|---|
| 2534 | if (input.length > peg$currPos) {
|
|---|
| 2535 | s5 = input.charAt(peg$currPos);
|
|---|
| 2536 | peg$currPos++;
|
|---|
| 2537 | } else {
|
|---|
| 2538 | s5 = peg$FAILED;
|
|---|
| 2539 | {
|
|---|
| 2540 | peg$fail(peg$c54);
|
|---|
| 2541 | }
|
|---|
| 2542 | }
|
|---|
| 2543 | if (s5 !== peg$FAILED) {
|
|---|
| 2544 | s4 = peg$c55(s4, s5);
|
|---|
| 2545 | s3 = s4;
|
|---|
| 2546 | } else {
|
|---|
| 2547 | peg$currPos = s3;
|
|---|
| 2548 | s3 = peg$FAILED;
|
|---|
| 2549 | }
|
|---|
| 2550 | } else {
|
|---|
| 2551 | peg$currPos = s3;
|
|---|
| 2552 | s3 = peg$FAILED;
|
|---|
| 2553 | }
|
|---|
| 2554 | }
|
|---|
| 2555 | }
|
|---|
| 2556 | if (s2 !== peg$FAILED) {
|
|---|
| 2557 | if (input.charCodeAt(peg$currPos) === 39) {
|
|---|
| 2558 | s3 = peg$c57;
|
|---|
| 2559 | peg$currPos++;
|
|---|
| 2560 | } else {
|
|---|
| 2561 | s3 = peg$FAILED;
|
|---|
| 2562 | {
|
|---|
| 2563 | peg$fail(peg$c58);
|
|---|
| 2564 | }
|
|---|
| 2565 | }
|
|---|
| 2566 | if (s3 !== peg$FAILED) {
|
|---|
| 2567 | s1 = peg$c56(s2);
|
|---|
| 2568 | s0 = s1;
|
|---|
| 2569 | } else {
|
|---|
| 2570 | peg$currPos = s0;
|
|---|
| 2571 | s0 = peg$FAILED;
|
|---|
| 2572 | }
|
|---|
| 2573 | } else {
|
|---|
| 2574 | peg$currPos = s0;
|
|---|
| 2575 | s0 = peg$FAILED;
|
|---|
| 2576 | }
|
|---|
| 2577 | } else {
|
|---|
| 2578 | peg$currPos = s0;
|
|---|
| 2579 | s0 = peg$FAILED;
|
|---|
| 2580 | }
|
|---|
| 2581 | }
|
|---|
| 2582 | peg$resultsCache[key] = {
|
|---|
| 2583 | nextPos: peg$currPos,
|
|---|
| 2584 | result: s0
|
|---|
| 2585 | };
|
|---|
| 2586 | return s0;
|
|---|
| 2587 | }
|
|---|
| 2588 | function peg$parsenumber() {
|
|---|
| 2589 | var s0, s1, s2, s3;
|
|---|
| 2590 | var key = peg$currPos * 36 + 18,
|
|---|
| 2591 | cached = peg$resultsCache[key];
|
|---|
| 2592 | if (cached) {
|
|---|
| 2593 | peg$currPos = cached.nextPos;
|
|---|
| 2594 | return cached.result;
|
|---|
| 2595 | }
|
|---|
| 2596 | s0 = peg$currPos;
|
|---|
| 2597 | s1 = peg$currPos;
|
|---|
| 2598 | s2 = [];
|
|---|
| 2599 | if (peg$c61.test(input.charAt(peg$currPos))) {
|
|---|
| 2600 | s3 = input.charAt(peg$currPos);
|
|---|
| 2601 | peg$currPos++;
|
|---|
| 2602 | } else {
|
|---|
| 2603 | s3 = peg$FAILED;
|
|---|
| 2604 | {
|
|---|
| 2605 | peg$fail(peg$c62);
|
|---|
| 2606 | }
|
|---|
| 2607 | }
|
|---|
| 2608 | while (s3 !== peg$FAILED) {
|
|---|
| 2609 | s2.push(s3);
|
|---|
| 2610 | if (peg$c61.test(input.charAt(peg$currPos))) {
|
|---|
| 2611 | s3 = input.charAt(peg$currPos);
|
|---|
| 2612 | peg$currPos++;
|
|---|
| 2613 | } else {
|
|---|
| 2614 | s3 = peg$FAILED;
|
|---|
| 2615 | {
|
|---|
| 2616 | peg$fail(peg$c62);
|
|---|
| 2617 | }
|
|---|
| 2618 | }
|
|---|
| 2619 | }
|
|---|
| 2620 | if (s2 !== peg$FAILED) {
|
|---|
| 2621 | if (input.charCodeAt(peg$currPos) === 46) {
|
|---|
| 2622 | s3 = peg$c43;
|
|---|
| 2623 | peg$currPos++;
|
|---|
| 2624 | } else {
|
|---|
| 2625 | s3 = peg$FAILED;
|
|---|
| 2626 | {
|
|---|
| 2627 | peg$fail(peg$c44);
|
|---|
| 2628 | }
|
|---|
| 2629 | }
|
|---|
| 2630 | if (s3 !== peg$FAILED) {
|
|---|
| 2631 | s2 = [s2, s3];
|
|---|
| 2632 | s1 = s2;
|
|---|
| 2633 | } else {
|
|---|
| 2634 | peg$currPos = s1;
|
|---|
| 2635 | s1 = peg$FAILED;
|
|---|
| 2636 | }
|
|---|
| 2637 | } else {
|
|---|
| 2638 | peg$currPos = s1;
|
|---|
| 2639 | s1 = peg$FAILED;
|
|---|
| 2640 | }
|
|---|
| 2641 | if (s1 === peg$FAILED) {
|
|---|
| 2642 | s1 = null;
|
|---|
| 2643 | }
|
|---|
| 2644 | if (s1 !== peg$FAILED) {
|
|---|
| 2645 | s2 = [];
|
|---|
| 2646 | if (peg$c61.test(input.charAt(peg$currPos))) {
|
|---|
| 2647 | s3 = input.charAt(peg$currPos);
|
|---|
| 2648 | peg$currPos++;
|
|---|
| 2649 | } else {
|
|---|
| 2650 | s3 = peg$FAILED;
|
|---|
| 2651 | {
|
|---|
| 2652 | peg$fail(peg$c62);
|
|---|
| 2653 | }
|
|---|
| 2654 | }
|
|---|
| 2655 | if (s3 !== peg$FAILED) {
|
|---|
| 2656 | while (s3 !== peg$FAILED) {
|
|---|
| 2657 | s2.push(s3);
|
|---|
| 2658 | if (peg$c61.test(input.charAt(peg$currPos))) {
|
|---|
| 2659 | s3 = input.charAt(peg$currPos);
|
|---|
| 2660 | peg$currPos++;
|
|---|
| 2661 | } else {
|
|---|
| 2662 | s3 = peg$FAILED;
|
|---|
| 2663 | {
|
|---|
| 2664 | peg$fail(peg$c62);
|
|---|
| 2665 | }
|
|---|
| 2666 | }
|
|---|
| 2667 | }
|
|---|
| 2668 | } else {
|
|---|
| 2669 | s2 = peg$FAILED;
|
|---|
| 2670 | }
|
|---|
| 2671 | if (s2 !== peg$FAILED) {
|
|---|
| 2672 | s1 = peg$c63(s1, s2);
|
|---|
| 2673 | s0 = s1;
|
|---|
| 2674 | } else {
|
|---|
| 2675 | peg$currPos = s0;
|
|---|
| 2676 | s0 = peg$FAILED;
|
|---|
| 2677 | }
|
|---|
| 2678 | } else {
|
|---|
| 2679 | peg$currPos = s0;
|
|---|
| 2680 | s0 = peg$FAILED;
|
|---|
| 2681 | }
|
|---|
| 2682 | peg$resultsCache[key] = {
|
|---|
| 2683 | nextPos: peg$currPos,
|
|---|
| 2684 | result: s0
|
|---|
| 2685 | };
|
|---|
| 2686 | return s0;
|
|---|
| 2687 | }
|
|---|
| 2688 | function peg$parsepath() {
|
|---|
| 2689 | var s0, s1;
|
|---|
| 2690 | var key = peg$currPos * 36 + 19,
|
|---|
| 2691 | cached = peg$resultsCache[key];
|
|---|
| 2692 | if (cached) {
|
|---|
| 2693 | peg$currPos = cached.nextPos;
|
|---|
| 2694 | return cached.result;
|
|---|
| 2695 | }
|
|---|
| 2696 | s0 = peg$currPos;
|
|---|
| 2697 | s1 = peg$parseidentifierName();
|
|---|
| 2698 | if (s1 !== peg$FAILED) {
|
|---|
| 2699 | s1 = peg$c64(s1);
|
|---|
| 2700 | }
|
|---|
| 2701 | s0 = s1;
|
|---|
| 2702 | peg$resultsCache[key] = {
|
|---|
| 2703 | nextPos: peg$currPos,
|
|---|
| 2704 | result: s0
|
|---|
| 2705 | };
|
|---|
| 2706 | return s0;
|
|---|
| 2707 | }
|
|---|
| 2708 | function peg$parsetype() {
|
|---|
| 2709 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 2710 | var key = peg$currPos * 36 + 20,
|
|---|
| 2711 | cached = peg$resultsCache[key];
|
|---|
| 2712 | if (cached) {
|
|---|
| 2713 | peg$currPos = cached.nextPos;
|
|---|
| 2714 | return cached.result;
|
|---|
| 2715 | }
|
|---|
| 2716 | s0 = peg$currPos;
|
|---|
| 2717 | if (input.substr(peg$currPos, 5) === peg$c65) {
|
|---|
| 2718 | s1 = peg$c65;
|
|---|
| 2719 | peg$currPos += 5;
|
|---|
| 2720 | } else {
|
|---|
| 2721 | s1 = peg$FAILED;
|
|---|
| 2722 | {
|
|---|
| 2723 | peg$fail(peg$c66);
|
|---|
| 2724 | }
|
|---|
| 2725 | }
|
|---|
| 2726 | if (s1 !== peg$FAILED) {
|
|---|
| 2727 | s2 = peg$parse_();
|
|---|
| 2728 | if (s2 !== peg$FAILED) {
|
|---|
| 2729 | s3 = [];
|
|---|
| 2730 | if (peg$c67.test(input.charAt(peg$currPos))) {
|
|---|
| 2731 | s4 = input.charAt(peg$currPos);
|
|---|
| 2732 | peg$currPos++;
|
|---|
| 2733 | } else {
|
|---|
| 2734 | s4 = peg$FAILED;
|
|---|
| 2735 | {
|
|---|
| 2736 | peg$fail(peg$c68);
|
|---|
| 2737 | }
|
|---|
| 2738 | }
|
|---|
| 2739 | if (s4 !== peg$FAILED) {
|
|---|
| 2740 | while (s4 !== peg$FAILED) {
|
|---|
| 2741 | s3.push(s4);
|
|---|
| 2742 | if (peg$c67.test(input.charAt(peg$currPos))) {
|
|---|
| 2743 | s4 = input.charAt(peg$currPos);
|
|---|
| 2744 | peg$currPos++;
|
|---|
| 2745 | } else {
|
|---|
| 2746 | s4 = peg$FAILED;
|
|---|
| 2747 | {
|
|---|
| 2748 | peg$fail(peg$c68);
|
|---|
| 2749 | }
|
|---|
| 2750 | }
|
|---|
| 2751 | }
|
|---|
| 2752 | } else {
|
|---|
| 2753 | s3 = peg$FAILED;
|
|---|
| 2754 | }
|
|---|
| 2755 | if (s3 !== peg$FAILED) {
|
|---|
| 2756 | s4 = peg$parse_();
|
|---|
| 2757 | if (s4 !== peg$FAILED) {
|
|---|
| 2758 | if (input.charCodeAt(peg$currPos) === 41) {
|
|---|
| 2759 | s5 = peg$c69;
|
|---|
| 2760 | peg$currPos++;
|
|---|
| 2761 | } else {
|
|---|
| 2762 | s5 = peg$FAILED;
|
|---|
| 2763 | {
|
|---|
| 2764 | peg$fail(peg$c70);
|
|---|
| 2765 | }
|
|---|
| 2766 | }
|
|---|
| 2767 | if (s5 !== peg$FAILED) {
|
|---|
| 2768 | s1 = peg$c71(s3);
|
|---|
| 2769 | s0 = s1;
|
|---|
| 2770 | } else {
|
|---|
| 2771 | peg$currPos = s0;
|
|---|
| 2772 | s0 = peg$FAILED;
|
|---|
| 2773 | }
|
|---|
| 2774 | } else {
|
|---|
| 2775 | peg$currPos = s0;
|
|---|
| 2776 | s0 = peg$FAILED;
|
|---|
| 2777 | }
|
|---|
| 2778 | } else {
|
|---|
| 2779 | peg$currPos = s0;
|
|---|
| 2780 | s0 = peg$FAILED;
|
|---|
| 2781 | }
|
|---|
| 2782 | } else {
|
|---|
| 2783 | peg$currPos = s0;
|
|---|
| 2784 | s0 = peg$FAILED;
|
|---|
| 2785 | }
|
|---|
| 2786 | } else {
|
|---|
| 2787 | peg$currPos = s0;
|
|---|
| 2788 | s0 = peg$FAILED;
|
|---|
| 2789 | }
|
|---|
| 2790 | peg$resultsCache[key] = {
|
|---|
| 2791 | nextPos: peg$currPos,
|
|---|
| 2792 | result: s0
|
|---|
| 2793 | };
|
|---|
| 2794 | return s0;
|
|---|
| 2795 | }
|
|---|
| 2796 | function peg$parseflags() {
|
|---|
| 2797 | var s0, s1;
|
|---|
| 2798 | var key = peg$currPos * 36 + 21,
|
|---|
| 2799 | cached = peg$resultsCache[key];
|
|---|
| 2800 | if (cached) {
|
|---|
| 2801 | peg$currPos = cached.nextPos;
|
|---|
| 2802 | return cached.result;
|
|---|
| 2803 | }
|
|---|
| 2804 | s0 = [];
|
|---|
| 2805 | if (peg$c72.test(input.charAt(peg$currPos))) {
|
|---|
| 2806 | s1 = input.charAt(peg$currPos);
|
|---|
| 2807 | peg$currPos++;
|
|---|
| 2808 | } else {
|
|---|
| 2809 | s1 = peg$FAILED;
|
|---|
| 2810 | {
|
|---|
| 2811 | peg$fail(peg$c73);
|
|---|
| 2812 | }
|
|---|
| 2813 | }
|
|---|
| 2814 | if (s1 !== peg$FAILED) {
|
|---|
| 2815 | while (s1 !== peg$FAILED) {
|
|---|
| 2816 | s0.push(s1);
|
|---|
| 2817 | if (peg$c72.test(input.charAt(peg$currPos))) {
|
|---|
| 2818 | s1 = input.charAt(peg$currPos);
|
|---|
| 2819 | peg$currPos++;
|
|---|
| 2820 | } else {
|
|---|
| 2821 | s1 = peg$FAILED;
|
|---|
| 2822 | {
|
|---|
| 2823 | peg$fail(peg$c73);
|
|---|
| 2824 | }
|
|---|
| 2825 | }
|
|---|
| 2826 | }
|
|---|
| 2827 | } else {
|
|---|
| 2828 | s0 = peg$FAILED;
|
|---|
| 2829 | }
|
|---|
| 2830 | peg$resultsCache[key] = {
|
|---|
| 2831 | nextPos: peg$currPos,
|
|---|
| 2832 | result: s0
|
|---|
| 2833 | };
|
|---|
| 2834 | return s0;
|
|---|
| 2835 | }
|
|---|
| 2836 | function peg$parseregex() {
|
|---|
| 2837 | var s0, s1, s2, s3, s4;
|
|---|
| 2838 | var key = peg$currPos * 36 + 22,
|
|---|
| 2839 | cached = peg$resultsCache[key];
|
|---|
| 2840 | if (cached) {
|
|---|
| 2841 | peg$currPos = cached.nextPos;
|
|---|
| 2842 | return cached.result;
|
|---|
| 2843 | }
|
|---|
| 2844 | s0 = peg$currPos;
|
|---|
| 2845 | if (input.charCodeAt(peg$currPos) === 47) {
|
|---|
| 2846 | s1 = peg$c74;
|
|---|
| 2847 | peg$currPos++;
|
|---|
| 2848 | } else {
|
|---|
| 2849 | s1 = peg$FAILED;
|
|---|
| 2850 | {
|
|---|
| 2851 | peg$fail(peg$c75);
|
|---|
| 2852 | }
|
|---|
| 2853 | }
|
|---|
| 2854 | if (s1 !== peg$FAILED) {
|
|---|
| 2855 | s2 = [];
|
|---|
| 2856 | s3 = peg$parsere_character_class();
|
|---|
| 2857 | if (s3 === peg$FAILED) {
|
|---|
| 2858 | s3 = peg$parsere_escape();
|
|---|
| 2859 | if (s3 === peg$FAILED) {
|
|---|
| 2860 | s3 = peg$parsere_chars();
|
|---|
| 2861 | }
|
|---|
| 2862 | }
|
|---|
| 2863 | if (s3 !== peg$FAILED) {
|
|---|
| 2864 | while (s3 !== peg$FAILED) {
|
|---|
| 2865 | s2.push(s3);
|
|---|
| 2866 | s3 = peg$parsere_character_class();
|
|---|
| 2867 | if (s3 === peg$FAILED) {
|
|---|
| 2868 | s3 = peg$parsere_escape();
|
|---|
| 2869 | if (s3 === peg$FAILED) {
|
|---|
| 2870 | s3 = peg$parsere_chars();
|
|---|
| 2871 | }
|
|---|
| 2872 | }
|
|---|
| 2873 | }
|
|---|
| 2874 | } else {
|
|---|
| 2875 | s2 = peg$FAILED;
|
|---|
| 2876 | }
|
|---|
| 2877 | if (s2 !== peg$FAILED) {
|
|---|
| 2878 | if (input.charCodeAt(peg$currPos) === 47) {
|
|---|
| 2879 | s3 = peg$c74;
|
|---|
| 2880 | peg$currPos++;
|
|---|
| 2881 | } else {
|
|---|
| 2882 | s3 = peg$FAILED;
|
|---|
| 2883 | {
|
|---|
| 2884 | peg$fail(peg$c75);
|
|---|
| 2885 | }
|
|---|
| 2886 | }
|
|---|
| 2887 | if (s3 !== peg$FAILED) {
|
|---|
| 2888 | s4 = peg$parseflags();
|
|---|
| 2889 | if (s4 === peg$FAILED) {
|
|---|
| 2890 | s4 = null;
|
|---|
| 2891 | }
|
|---|
| 2892 | if (s4 !== peg$FAILED) {
|
|---|
| 2893 | s1 = peg$c76(s2, s4);
|
|---|
| 2894 | s0 = s1;
|
|---|
| 2895 | } else {
|
|---|
| 2896 | peg$currPos = s0;
|
|---|
| 2897 | s0 = peg$FAILED;
|
|---|
| 2898 | }
|
|---|
| 2899 | } else {
|
|---|
| 2900 | peg$currPos = s0;
|
|---|
| 2901 | s0 = peg$FAILED;
|
|---|
| 2902 | }
|
|---|
| 2903 | } else {
|
|---|
| 2904 | peg$currPos = s0;
|
|---|
| 2905 | s0 = peg$FAILED;
|
|---|
| 2906 | }
|
|---|
| 2907 | } else {
|
|---|
| 2908 | peg$currPos = s0;
|
|---|
| 2909 | s0 = peg$FAILED;
|
|---|
| 2910 | }
|
|---|
| 2911 | peg$resultsCache[key] = {
|
|---|
| 2912 | nextPos: peg$currPos,
|
|---|
| 2913 | result: s0
|
|---|
| 2914 | };
|
|---|
| 2915 | return s0;
|
|---|
| 2916 | }
|
|---|
| 2917 | function peg$parsere_character_class() {
|
|---|
| 2918 | var s0, s1, s2, s3;
|
|---|
| 2919 | var key = peg$currPos * 36 + 23,
|
|---|
| 2920 | cached = peg$resultsCache[key];
|
|---|
| 2921 | if (cached) {
|
|---|
| 2922 | peg$currPos = cached.nextPos;
|
|---|
| 2923 | return cached.result;
|
|---|
| 2924 | }
|
|---|
| 2925 | s0 = peg$currPos;
|
|---|
| 2926 | if (input.charCodeAt(peg$currPos) === 91) {
|
|---|
| 2927 | s1 = peg$c31;
|
|---|
| 2928 | peg$currPos++;
|
|---|
| 2929 | } else {
|
|---|
| 2930 | s1 = peg$FAILED;
|
|---|
| 2931 | {
|
|---|
| 2932 | peg$fail(peg$c32);
|
|---|
| 2933 | }
|
|---|
| 2934 | }
|
|---|
| 2935 | if (s1 !== peg$FAILED) {
|
|---|
| 2936 | s2 = [];
|
|---|
| 2937 | if (peg$c77.test(input.charAt(peg$currPos))) {
|
|---|
| 2938 | s3 = input.charAt(peg$currPos);
|
|---|
| 2939 | peg$currPos++;
|
|---|
| 2940 | } else {
|
|---|
| 2941 | s3 = peg$FAILED;
|
|---|
| 2942 | {
|
|---|
| 2943 | peg$fail(peg$c78);
|
|---|
| 2944 | }
|
|---|
| 2945 | }
|
|---|
| 2946 | if (s3 === peg$FAILED) {
|
|---|
| 2947 | s3 = peg$parsere_escape();
|
|---|
| 2948 | }
|
|---|
| 2949 | if (s3 !== peg$FAILED) {
|
|---|
| 2950 | while (s3 !== peg$FAILED) {
|
|---|
| 2951 | s2.push(s3);
|
|---|
| 2952 | if (peg$c77.test(input.charAt(peg$currPos))) {
|
|---|
| 2953 | s3 = input.charAt(peg$currPos);
|
|---|
| 2954 | peg$currPos++;
|
|---|
| 2955 | } else {
|
|---|
| 2956 | s3 = peg$FAILED;
|
|---|
| 2957 | {
|
|---|
| 2958 | peg$fail(peg$c78);
|
|---|
| 2959 | }
|
|---|
| 2960 | }
|
|---|
| 2961 | if (s3 === peg$FAILED) {
|
|---|
| 2962 | s3 = peg$parsere_escape();
|
|---|
| 2963 | }
|
|---|
| 2964 | }
|
|---|
| 2965 | } else {
|
|---|
| 2966 | s2 = peg$FAILED;
|
|---|
| 2967 | }
|
|---|
| 2968 | if (s2 !== peg$FAILED) {
|
|---|
| 2969 | if (input.charCodeAt(peg$currPos) === 93) {
|
|---|
| 2970 | s3 = peg$c33;
|
|---|
| 2971 | peg$currPos++;
|
|---|
| 2972 | } else {
|
|---|
| 2973 | s3 = peg$FAILED;
|
|---|
| 2974 | {
|
|---|
| 2975 | peg$fail(peg$c34);
|
|---|
| 2976 | }
|
|---|
| 2977 | }
|
|---|
| 2978 | if (s3 !== peg$FAILED) {
|
|---|
| 2979 | s1 = peg$c79(s2);
|
|---|
| 2980 | s0 = s1;
|
|---|
| 2981 | } else {
|
|---|
| 2982 | peg$currPos = s0;
|
|---|
| 2983 | s0 = peg$FAILED;
|
|---|
| 2984 | }
|
|---|
| 2985 | } else {
|
|---|
| 2986 | peg$currPos = s0;
|
|---|
| 2987 | s0 = peg$FAILED;
|
|---|
| 2988 | }
|
|---|
| 2989 | } else {
|
|---|
| 2990 | peg$currPos = s0;
|
|---|
| 2991 | s0 = peg$FAILED;
|
|---|
| 2992 | }
|
|---|
| 2993 | peg$resultsCache[key] = {
|
|---|
| 2994 | nextPos: peg$currPos,
|
|---|
| 2995 | result: s0
|
|---|
| 2996 | };
|
|---|
| 2997 | return s0;
|
|---|
| 2998 | }
|
|---|
| 2999 | function peg$parsere_escape() {
|
|---|
| 3000 | var s0, s1, s2;
|
|---|
| 3001 | var key = peg$currPos * 36 + 24,
|
|---|
| 3002 | cached = peg$resultsCache[key];
|
|---|
| 3003 | if (cached) {
|
|---|
| 3004 | peg$currPos = cached.nextPos;
|
|---|
| 3005 | return cached.result;
|
|---|
| 3006 | }
|
|---|
| 3007 | s0 = peg$currPos;
|
|---|
| 3008 | if (input.charCodeAt(peg$currPos) === 92) {
|
|---|
| 3009 | s1 = peg$c52;
|
|---|
| 3010 | peg$currPos++;
|
|---|
| 3011 | } else {
|
|---|
| 3012 | s1 = peg$FAILED;
|
|---|
| 3013 | {
|
|---|
| 3014 | peg$fail(peg$c53);
|
|---|
| 3015 | }
|
|---|
| 3016 | }
|
|---|
| 3017 | if (s1 !== peg$FAILED) {
|
|---|
| 3018 | if (input.length > peg$currPos) {
|
|---|
| 3019 | s2 = input.charAt(peg$currPos);
|
|---|
| 3020 | peg$currPos++;
|
|---|
| 3021 | } else {
|
|---|
| 3022 | s2 = peg$FAILED;
|
|---|
| 3023 | {
|
|---|
| 3024 | peg$fail(peg$c54);
|
|---|
| 3025 | }
|
|---|
| 3026 | }
|
|---|
| 3027 | if (s2 !== peg$FAILED) {
|
|---|
| 3028 | s1 = peg$c80(s2);
|
|---|
| 3029 | s0 = s1;
|
|---|
| 3030 | } else {
|
|---|
| 3031 | peg$currPos = s0;
|
|---|
| 3032 | s0 = peg$FAILED;
|
|---|
| 3033 | }
|
|---|
| 3034 | } else {
|
|---|
| 3035 | peg$currPos = s0;
|
|---|
| 3036 | s0 = peg$FAILED;
|
|---|
| 3037 | }
|
|---|
| 3038 | peg$resultsCache[key] = {
|
|---|
| 3039 | nextPos: peg$currPos,
|
|---|
| 3040 | result: s0
|
|---|
| 3041 | };
|
|---|
| 3042 | return s0;
|
|---|
| 3043 | }
|
|---|
| 3044 | function peg$parsere_chars() {
|
|---|
| 3045 | var s0, s1, s2;
|
|---|
| 3046 | var key = peg$currPos * 36 + 25,
|
|---|
| 3047 | cached = peg$resultsCache[key];
|
|---|
| 3048 | if (cached) {
|
|---|
| 3049 | peg$currPos = cached.nextPos;
|
|---|
| 3050 | return cached.result;
|
|---|
| 3051 | }
|
|---|
| 3052 | s0 = peg$currPos;
|
|---|
| 3053 | s1 = [];
|
|---|
| 3054 | if (peg$c81.test(input.charAt(peg$currPos))) {
|
|---|
| 3055 | s2 = input.charAt(peg$currPos);
|
|---|
| 3056 | peg$currPos++;
|
|---|
| 3057 | } else {
|
|---|
| 3058 | s2 = peg$FAILED;
|
|---|
| 3059 | {
|
|---|
| 3060 | peg$fail(peg$c82);
|
|---|
| 3061 | }
|
|---|
| 3062 | }
|
|---|
| 3063 | if (s2 !== peg$FAILED) {
|
|---|
| 3064 | while (s2 !== peg$FAILED) {
|
|---|
| 3065 | s1.push(s2);
|
|---|
| 3066 | if (peg$c81.test(input.charAt(peg$currPos))) {
|
|---|
| 3067 | s2 = input.charAt(peg$currPos);
|
|---|
| 3068 | peg$currPos++;
|
|---|
| 3069 | } else {
|
|---|
| 3070 | s2 = peg$FAILED;
|
|---|
| 3071 | {
|
|---|
| 3072 | peg$fail(peg$c82);
|
|---|
| 3073 | }
|
|---|
| 3074 | }
|
|---|
| 3075 | }
|
|---|
| 3076 | } else {
|
|---|
| 3077 | s1 = peg$FAILED;
|
|---|
| 3078 | }
|
|---|
| 3079 | if (s1 !== peg$FAILED) {
|
|---|
| 3080 | s1 = peg$c83(s1);
|
|---|
| 3081 | }
|
|---|
| 3082 | s0 = s1;
|
|---|
| 3083 | peg$resultsCache[key] = {
|
|---|
| 3084 | nextPos: peg$currPos,
|
|---|
| 3085 | result: s0
|
|---|
| 3086 | };
|
|---|
| 3087 | return s0;
|
|---|
| 3088 | }
|
|---|
| 3089 | function peg$parsefield() {
|
|---|
| 3090 | var s0, s1, s2, s3, s4, s5, s6;
|
|---|
| 3091 | var key = peg$currPos * 36 + 26,
|
|---|
| 3092 | cached = peg$resultsCache[key];
|
|---|
| 3093 | if (cached) {
|
|---|
| 3094 | peg$currPos = cached.nextPos;
|
|---|
| 3095 | return cached.result;
|
|---|
| 3096 | }
|
|---|
| 3097 | s0 = peg$currPos;
|
|---|
| 3098 | if (input.charCodeAt(peg$currPos) === 46) {
|
|---|
| 3099 | s1 = peg$c43;
|
|---|
| 3100 | peg$currPos++;
|
|---|
| 3101 | } else {
|
|---|
| 3102 | s1 = peg$FAILED;
|
|---|
| 3103 | {
|
|---|
| 3104 | peg$fail(peg$c44);
|
|---|
| 3105 | }
|
|---|
| 3106 | }
|
|---|
| 3107 | if (s1 !== peg$FAILED) {
|
|---|
| 3108 | s2 = peg$parseidentifierName();
|
|---|
| 3109 | if (s2 !== peg$FAILED) {
|
|---|
| 3110 | s3 = [];
|
|---|
| 3111 | s4 = peg$currPos;
|
|---|
| 3112 | if (input.charCodeAt(peg$currPos) === 46) {
|
|---|
| 3113 | s5 = peg$c43;
|
|---|
| 3114 | peg$currPos++;
|
|---|
| 3115 | } else {
|
|---|
| 3116 | s5 = peg$FAILED;
|
|---|
| 3117 | {
|
|---|
| 3118 | peg$fail(peg$c44);
|
|---|
| 3119 | }
|
|---|
| 3120 | }
|
|---|
| 3121 | if (s5 !== peg$FAILED) {
|
|---|
| 3122 | s6 = peg$parseidentifierName();
|
|---|
| 3123 | if (s6 !== peg$FAILED) {
|
|---|
| 3124 | s5 = [s5, s6];
|
|---|
| 3125 | s4 = s5;
|
|---|
| 3126 | } else {
|
|---|
| 3127 | peg$currPos = s4;
|
|---|
| 3128 | s4 = peg$FAILED;
|
|---|
| 3129 | }
|
|---|
| 3130 | } else {
|
|---|
| 3131 | peg$currPos = s4;
|
|---|
| 3132 | s4 = peg$FAILED;
|
|---|
| 3133 | }
|
|---|
| 3134 | while (s4 !== peg$FAILED) {
|
|---|
| 3135 | s3.push(s4);
|
|---|
| 3136 | s4 = peg$currPos;
|
|---|
| 3137 | if (input.charCodeAt(peg$currPos) === 46) {
|
|---|
| 3138 | s5 = peg$c43;
|
|---|
| 3139 | peg$currPos++;
|
|---|
| 3140 | } else {
|
|---|
| 3141 | s5 = peg$FAILED;
|
|---|
| 3142 | {
|
|---|
| 3143 | peg$fail(peg$c44);
|
|---|
| 3144 | }
|
|---|
| 3145 | }
|
|---|
| 3146 | if (s5 !== peg$FAILED) {
|
|---|
| 3147 | s6 = peg$parseidentifierName();
|
|---|
| 3148 | if (s6 !== peg$FAILED) {
|
|---|
| 3149 | s5 = [s5, s6];
|
|---|
| 3150 | s4 = s5;
|
|---|
| 3151 | } else {
|
|---|
| 3152 | peg$currPos = s4;
|
|---|
| 3153 | s4 = peg$FAILED;
|
|---|
| 3154 | }
|
|---|
| 3155 | } else {
|
|---|
| 3156 | peg$currPos = s4;
|
|---|
| 3157 | s4 = peg$FAILED;
|
|---|
| 3158 | }
|
|---|
| 3159 | }
|
|---|
| 3160 | if (s3 !== peg$FAILED) {
|
|---|
| 3161 | s1 = peg$c84(s2, s3);
|
|---|
| 3162 | s0 = s1;
|
|---|
| 3163 | } else {
|
|---|
| 3164 | peg$currPos = s0;
|
|---|
| 3165 | s0 = peg$FAILED;
|
|---|
| 3166 | }
|
|---|
| 3167 | } else {
|
|---|
| 3168 | peg$currPos = s0;
|
|---|
| 3169 | s0 = peg$FAILED;
|
|---|
| 3170 | }
|
|---|
| 3171 | } else {
|
|---|
| 3172 | peg$currPos = s0;
|
|---|
| 3173 | s0 = peg$FAILED;
|
|---|
| 3174 | }
|
|---|
| 3175 | peg$resultsCache[key] = {
|
|---|
| 3176 | nextPos: peg$currPos,
|
|---|
| 3177 | result: s0
|
|---|
| 3178 | };
|
|---|
| 3179 | return s0;
|
|---|
| 3180 | }
|
|---|
| 3181 | function peg$parsenegation() {
|
|---|
| 3182 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 3183 | var key = peg$currPos * 36 + 27,
|
|---|
| 3184 | cached = peg$resultsCache[key];
|
|---|
| 3185 | if (cached) {
|
|---|
| 3186 | peg$currPos = cached.nextPos;
|
|---|
| 3187 | return cached.result;
|
|---|
| 3188 | }
|
|---|
| 3189 | s0 = peg$currPos;
|
|---|
| 3190 | if (input.substr(peg$currPos, 5) === peg$c85) {
|
|---|
| 3191 | s1 = peg$c85;
|
|---|
| 3192 | peg$currPos += 5;
|
|---|
| 3193 | } else {
|
|---|
| 3194 | s1 = peg$FAILED;
|
|---|
| 3195 | {
|
|---|
| 3196 | peg$fail(peg$c86);
|
|---|
| 3197 | }
|
|---|
| 3198 | }
|
|---|
| 3199 | if (s1 !== peg$FAILED) {
|
|---|
| 3200 | s2 = peg$parse_();
|
|---|
| 3201 | if (s2 !== peg$FAILED) {
|
|---|
| 3202 | s3 = peg$parseselectors();
|
|---|
| 3203 | if (s3 !== peg$FAILED) {
|
|---|
| 3204 | s4 = peg$parse_();
|
|---|
| 3205 | if (s4 !== peg$FAILED) {
|
|---|
| 3206 | if (input.charCodeAt(peg$currPos) === 41) {
|
|---|
| 3207 | s5 = peg$c69;
|
|---|
| 3208 | peg$currPos++;
|
|---|
| 3209 | } else {
|
|---|
| 3210 | s5 = peg$FAILED;
|
|---|
| 3211 | {
|
|---|
| 3212 | peg$fail(peg$c70);
|
|---|
| 3213 | }
|
|---|
| 3214 | }
|
|---|
| 3215 | if (s5 !== peg$FAILED) {
|
|---|
| 3216 | s1 = peg$c87(s3);
|
|---|
| 3217 | s0 = s1;
|
|---|
| 3218 | } else {
|
|---|
| 3219 | peg$currPos = s0;
|
|---|
| 3220 | s0 = peg$FAILED;
|
|---|
| 3221 | }
|
|---|
| 3222 | } else {
|
|---|
| 3223 | peg$currPos = s0;
|
|---|
| 3224 | s0 = peg$FAILED;
|
|---|
| 3225 | }
|
|---|
| 3226 | } else {
|
|---|
| 3227 | peg$currPos = s0;
|
|---|
| 3228 | s0 = peg$FAILED;
|
|---|
| 3229 | }
|
|---|
| 3230 | } else {
|
|---|
| 3231 | peg$currPos = s0;
|
|---|
| 3232 | s0 = peg$FAILED;
|
|---|
| 3233 | }
|
|---|
| 3234 | } else {
|
|---|
| 3235 | peg$currPos = s0;
|
|---|
| 3236 | s0 = peg$FAILED;
|
|---|
| 3237 | }
|
|---|
| 3238 | peg$resultsCache[key] = {
|
|---|
| 3239 | nextPos: peg$currPos,
|
|---|
| 3240 | result: s0
|
|---|
| 3241 | };
|
|---|
| 3242 | return s0;
|
|---|
| 3243 | }
|
|---|
| 3244 | function peg$parsematches() {
|
|---|
| 3245 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 3246 | var key = peg$currPos * 36 + 28,
|
|---|
| 3247 | cached = peg$resultsCache[key];
|
|---|
| 3248 | if (cached) {
|
|---|
| 3249 | peg$currPos = cached.nextPos;
|
|---|
| 3250 | return cached.result;
|
|---|
| 3251 | }
|
|---|
| 3252 | s0 = peg$currPos;
|
|---|
| 3253 | if (input.substr(peg$currPos, 9) === peg$c88) {
|
|---|
| 3254 | s1 = peg$c88;
|
|---|
| 3255 | peg$currPos += 9;
|
|---|
| 3256 | } else {
|
|---|
| 3257 | s1 = peg$FAILED;
|
|---|
| 3258 | {
|
|---|
| 3259 | peg$fail(peg$c89);
|
|---|
| 3260 | }
|
|---|
| 3261 | }
|
|---|
| 3262 | if (s1 !== peg$FAILED) {
|
|---|
| 3263 | s2 = peg$parse_();
|
|---|
| 3264 | if (s2 !== peg$FAILED) {
|
|---|
| 3265 | s3 = peg$parseselectors();
|
|---|
| 3266 | if (s3 !== peg$FAILED) {
|
|---|
| 3267 | s4 = peg$parse_();
|
|---|
| 3268 | if (s4 !== peg$FAILED) {
|
|---|
| 3269 | if (input.charCodeAt(peg$currPos) === 41) {
|
|---|
| 3270 | s5 = peg$c69;
|
|---|
| 3271 | peg$currPos++;
|
|---|
| 3272 | } else {
|
|---|
| 3273 | s5 = peg$FAILED;
|
|---|
| 3274 | {
|
|---|
| 3275 | peg$fail(peg$c70);
|
|---|
| 3276 | }
|
|---|
| 3277 | }
|
|---|
| 3278 | if (s5 !== peg$FAILED) {
|
|---|
| 3279 | s1 = peg$c90(s3);
|
|---|
| 3280 | s0 = s1;
|
|---|
| 3281 | } else {
|
|---|
| 3282 | peg$currPos = s0;
|
|---|
| 3283 | s0 = peg$FAILED;
|
|---|
| 3284 | }
|
|---|
| 3285 | } else {
|
|---|
| 3286 | peg$currPos = s0;
|
|---|
| 3287 | s0 = peg$FAILED;
|
|---|
| 3288 | }
|
|---|
| 3289 | } else {
|
|---|
| 3290 | peg$currPos = s0;
|
|---|
| 3291 | s0 = peg$FAILED;
|
|---|
| 3292 | }
|
|---|
| 3293 | } else {
|
|---|
| 3294 | peg$currPos = s0;
|
|---|
| 3295 | s0 = peg$FAILED;
|
|---|
| 3296 | }
|
|---|
| 3297 | } else {
|
|---|
| 3298 | peg$currPos = s0;
|
|---|
| 3299 | s0 = peg$FAILED;
|
|---|
| 3300 | }
|
|---|
| 3301 | peg$resultsCache[key] = {
|
|---|
| 3302 | nextPos: peg$currPos,
|
|---|
| 3303 | result: s0
|
|---|
| 3304 | };
|
|---|
| 3305 | return s0;
|
|---|
| 3306 | }
|
|---|
| 3307 | function peg$parseis() {
|
|---|
| 3308 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 3309 | var key = peg$currPos * 36 + 29,
|
|---|
| 3310 | cached = peg$resultsCache[key];
|
|---|
| 3311 | if (cached) {
|
|---|
| 3312 | peg$currPos = cached.nextPos;
|
|---|
| 3313 | return cached.result;
|
|---|
| 3314 | }
|
|---|
| 3315 | s0 = peg$currPos;
|
|---|
| 3316 | if (input.substr(peg$currPos, 4) === peg$c91) {
|
|---|
| 3317 | s1 = peg$c91;
|
|---|
| 3318 | peg$currPos += 4;
|
|---|
| 3319 | } else {
|
|---|
| 3320 | s1 = peg$FAILED;
|
|---|
| 3321 | {
|
|---|
| 3322 | peg$fail(peg$c92);
|
|---|
| 3323 | }
|
|---|
| 3324 | }
|
|---|
| 3325 | if (s1 !== peg$FAILED) {
|
|---|
| 3326 | s2 = peg$parse_();
|
|---|
| 3327 | if (s2 !== peg$FAILED) {
|
|---|
| 3328 | s3 = peg$parseselectors();
|
|---|
| 3329 | if (s3 !== peg$FAILED) {
|
|---|
| 3330 | s4 = peg$parse_();
|
|---|
| 3331 | if (s4 !== peg$FAILED) {
|
|---|
| 3332 | if (input.charCodeAt(peg$currPos) === 41) {
|
|---|
| 3333 | s5 = peg$c69;
|
|---|
| 3334 | peg$currPos++;
|
|---|
| 3335 | } else {
|
|---|
| 3336 | s5 = peg$FAILED;
|
|---|
| 3337 | {
|
|---|
| 3338 | peg$fail(peg$c70);
|
|---|
| 3339 | }
|
|---|
| 3340 | }
|
|---|
| 3341 | if (s5 !== peg$FAILED) {
|
|---|
| 3342 | s1 = peg$c90(s3);
|
|---|
| 3343 | s0 = s1;
|
|---|
| 3344 | } else {
|
|---|
| 3345 | peg$currPos = s0;
|
|---|
| 3346 | s0 = peg$FAILED;
|
|---|
| 3347 | }
|
|---|
| 3348 | } else {
|
|---|
| 3349 | peg$currPos = s0;
|
|---|
| 3350 | s0 = peg$FAILED;
|
|---|
| 3351 | }
|
|---|
| 3352 | } else {
|
|---|
| 3353 | peg$currPos = s0;
|
|---|
| 3354 | s0 = peg$FAILED;
|
|---|
| 3355 | }
|
|---|
| 3356 | } else {
|
|---|
| 3357 | peg$currPos = s0;
|
|---|
| 3358 | s0 = peg$FAILED;
|
|---|
| 3359 | }
|
|---|
| 3360 | } else {
|
|---|
| 3361 | peg$currPos = s0;
|
|---|
| 3362 | s0 = peg$FAILED;
|
|---|
| 3363 | }
|
|---|
| 3364 | peg$resultsCache[key] = {
|
|---|
| 3365 | nextPos: peg$currPos,
|
|---|
| 3366 | result: s0
|
|---|
| 3367 | };
|
|---|
| 3368 | return s0;
|
|---|
| 3369 | }
|
|---|
| 3370 | function peg$parsehas() {
|
|---|
| 3371 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 3372 | var key = peg$currPos * 36 + 30,
|
|---|
| 3373 | cached = peg$resultsCache[key];
|
|---|
| 3374 | if (cached) {
|
|---|
| 3375 | peg$currPos = cached.nextPos;
|
|---|
| 3376 | return cached.result;
|
|---|
| 3377 | }
|
|---|
| 3378 | s0 = peg$currPos;
|
|---|
| 3379 | if (input.substr(peg$currPos, 5) === peg$c93) {
|
|---|
| 3380 | s1 = peg$c93;
|
|---|
| 3381 | peg$currPos += 5;
|
|---|
| 3382 | } else {
|
|---|
| 3383 | s1 = peg$FAILED;
|
|---|
| 3384 | {
|
|---|
| 3385 | peg$fail(peg$c94);
|
|---|
| 3386 | }
|
|---|
| 3387 | }
|
|---|
| 3388 | if (s1 !== peg$FAILED) {
|
|---|
| 3389 | s2 = peg$parse_();
|
|---|
| 3390 | if (s2 !== peg$FAILED) {
|
|---|
| 3391 | s3 = peg$parsehasSelectors();
|
|---|
| 3392 | if (s3 !== peg$FAILED) {
|
|---|
| 3393 | s4 = peg$parse_();
|
|---|
| 3394 | if (s4 !== peg$FAILED) {
|
|---|
| 3395 | if (input.charCodeAt(peg$currPos) === 41) {
|
|---|
| 3396 | s5 = peg$c69;
|
|---|
| 3397 | peg$currPos++;
|
|---|
| 3398 | } else {
|
|---|
| 3399 | s5 = peg$FAILED;
|
|---|
| 3400 | {
|
|---|
| 3401 | peg$fail(peg$c70);
|
|---|
| 3402 | }
|
|---|
| 3403 | }
|
|---|
| 3404 | if (s5 !== peg$FAILED) {
|
|---|
| 3405 | s1 = peg$c95(s3);
|
|---|
| 3406 | s0 = s1;
|
|---|
| 3407 | } else {
|
|---|
| 3408 | peg$currPos = s0;
|
|---|
| 3409 | s0 = peg$FAILED;
|
|---|
| 3410 | }
|
|---|
| 3411 | } else {
|
|---|
| 3412 | peg$currPos = s0;
|
|---|
| 3413 | s0 = peg$FAILED;
|
|---|
| 3414 | }
|
|---|
| 3415 | } else {
|
|---|
| 3416 | peg$currPos = s0;
|
|---|
| 3417 | s0 = peg$FAILED;
|
|---|
| 3418 | }
|
|---|
| 3419 | } else {
|
|---|
| 3420 | peg$currPos = s0;
|
|---|
| 3421 | s0 = peg$FAILED;
|
|---|
| 3422 | }
|
|---|
| 3423 | } else {
|
|---|
| 3424 | peg$currPos = s0;
|
|---|
| 3425 | s0 = peg$FAILED;
|
|---|
| 3426 | }
|
|---|
| 3427 | peg$resultsCache[key] = {
|
|---|
| 3428 | nextPos: peg$currPos,
|
|---|
| 3429 | result: s0
|
|---|
| 3430 | };
|
|---|
| 3431 | return s0;
|
|---|
| 3432 | }
|
|---|
| 3433 | function peg$parsefirstChild() {
|
|---|
| 3434 | var s0, s1;
|
|---|
| 3435 | var key = peg$currPos * 36 + 31,
|
|---|
| 3436 | cached = peg$resultsCache[key];
|
|---|
| 3437 | if (cached) {
|
|---|
| 3438 | peg$currPos = cached.nextPos;
|
|---|
| 3439 | return cached.result;
|
|---|
| 3440 | }
|
|---|
| 3441 | s0 = peg$currPos;
|
|---|
| 3442 | if (input.substr(peg$currPos, 12) === peg$c96) {
|
|---|
| 3443 | s1 = peg$c96;
|
|---|
| 3444 | peg$currPos += 12;
|
|---|
| 3445 | } else {
|
|---|
| 3446 | s1 = peg$FAILED;
|
|---|
| 3447 | {
|
|---|
| 3448 | peg$fail(peg$c97);
|
|---|
| 3449 | }
|
|---|
| 3450 | }
|
|---|
| 3451 | if (s1 !== peg$FAILED) {
|
|---|
| 3452 | s1 = peg$c98();
|
|---|
| 3453 | }
|
|---|
| 3454 | s0 = s1;
|
|---|
| 3455 | peg$resultsCache[key] = {
|
|---|
| 3456 | nextPos: peg$currPos,
|
|---|
| 3457 | result: s0
|
|---|
| 3458 | };
|
|---|
| 3459 | return s0;
|
|---|
| 3460 | }
|
|---|
| 3461 | function peg$parselastChild() {
|
|---|
| 3462 | var s0, s1;
|
|---|
| 3463 | var key = peg$currPos * 36 + 32,
|
|---|
| 3464 | cached = peg$resultsCache[key];
|
|---|
| 3465 | if (cached) {
|
|---|
| 3466 | peg$currPos = cached.nextPos;
|
|---|
| 3467 | return cached.result;
|
|---|
| 3468 | }
|
|---|
| 3469 | s0 = peg$currPos;
|
|---|
| 3470 | if (input.substr(peg$currPos, 11) === peg$c99) {
|
|---|
| 3471 | s1 = peg$c99;
|
|---|
| 3472 | peg$currPos += 11;
|
|---|
| 3473 | } else {
|
|---|
| 3474 | s1 = peg$FAILED;
|
|---|
| 3475 | {
|
|---|
| 3476 | peg$fail(peg$c100);
|
|---|
| 3477 | }
|
|---|
| 3478 | }
|
|---|
| 3479 | if (s1 !== peg$FAILED) {
|
|---|
| 3480 | s1 = peg$c101();
|
|---|
| 3481 | }
|
|---|
| 3482 | s0 = s1;
|
|---|
| 3483 | peg$resultsCache[key] = {
|
|---|
| 3484 | nextPos: peg$currPos,
|
|---|
| 3485 | result: s0
|
|---|
| 3486 | };
|
|---|
| 3487 | return s0;
|
|---|
| 3488 | }
|
|---|
| 3489 | function peg$parsenthChild() {
|
|---|
| 3490 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 3491 | var key = peg$currPos * 36 + 33,
|
|---|
| 3492 | cached = peg$resultsCache[key];
|
|---|
| 3493 | if (cached) {
|
|---|
| 3494 | peg$currPos = cached.nextPos;
|
|---|
| 3495 | return cached.result;
|
|---|
| 3496 | }
|
|---|
| 3497 | s0 = peg$currPos;
|
|---|
| 3498 | if (input.substr(peg$currPos, 11) === peg$c102) {
|
|---|
| 3499 | s1 = peg$c102;
|
|---|
| 3500 | peg$currPos += 11;
|
|---|
| 3501 | } else {
|
|---|
| 3502 | s1 = peg$FAILED;
|
|---|
| 3503 | {
|
|---|
| 3504 | peg$fail(peg$c103);
|
|---|
| 3505 | }
|
|---|
| 3506 | }
|
|---|
| 3507 | if (s1 !== peg$FAILED) {
|
|---|
| 3508 | s2 = peg$parse_();
|
|---|
| 3509 | if (s2 !== peg$FAILED) {
|
|---|
| 3510 | s3 = [];
|
|---|
| 3511 | if (peg$c61.test(input.charAt(peg$currPos))) {
|
|---|
| 3512 | s4 = input.charAt(peg$currPos);
|
|---|
| 3513 | peg$currPos++;
|
|---|
| 3514 | } else {
|
|---|
| 3515 | s4 = peg$FAILED;
|
|---|
| 3516 | {
|
|---|
| 3517 | peg$fail(peg$c62);
|
|---|
| 3518 | }
|
|---|
| 3519 | }
|
|---|
| 3520 | if (s4 !== peg$FAILED) {
|
|---|
| 3521 | while (s4 !== peg$FAILED) {
|
|---|
| 3522 | s3.push(s4);
|
|---|
| 3523 | if (peg$c61.test(input.charAt(peg$currPos))) {
|
|---|
| 3524 | s4 = input.charAt(peg$currPos);
|
|---|
| 3525 | peg$currPos++;
|
|---|
| 3526 | } else {
|
|---|
| 3527 | s4 = peg$FAILED;
|
|---|
| 3528 | {
|
|---|
| 3529 | peg$fail(peg$c62);
|
|---|
| 3530 | }
|
|---|
| 3531 | }
|
|---|
| 3532 | }
|
|---|
| 3533 | } else {
|
|---|
| 3534 | s3 = peg$FAILED;
|
|---|
| 3535 | }
|
|---|
| 3536 | if (s3 !== peg$FAILED) {
|
|---|
| 3537 | s4 = peg$parse_();
|
|---|
| 3538 | if (s4 !== peg$FAILED) {
|
|---|
| 3539 | if (input.charCodeAt(peg$currPos) === 41) {
|
|---|
| 3540 | s5 = peg$c69;
|
|---|
| 3541 | peg$currPos++;
|
|---|
| 3542 | } else {
|
|---|
| 3543 | s5 = peg$FAILED;
|
|---|
| 3544 | {
|
|---|
| 3545 | peg$fail(peg$c70);
|
|---|
| 3546 | }
|
|---|
| 3547 | }
|
|---|
| 3548 | if (s5 !== peg$FAILED) {
|
|---|
| 3549 | s1 = peg$c104(s3);
|
|---|
| 3550 | s0 = s1;
|
|---|
| 3551 | } else {
|
|---|
| 3552 | peg$currPos = s0;
|
|---|
| 3553 | s0 = peg$FAILED;
|
|---|
| 3554 | }
|
|---|
| 3555 | } else {
|
|---|
| 3556 | peg$currPos = s0;
|
|---|
| 3557 | s0 = peg$FAILED;
|
|---|
| 3558 | }
|
|---|
| 3559 | } else {
|
|---|
| 3560 | peg$currPos = s0;
|
|---|
| 3561 | s0 = peg$FAILED;
|
|---|
| 3562 | }
|
|---|
| 3563 | } else {
|
|---|
| 3564 | peg$currPos = s0;
|
|---|
| 3565 | s0 = peg$FAILED;
|
|---|
| 3566 | }
|
|---|
| 3567 | } else {
|
|---|
| 3568 | peg$currPos = s0;
|
|---|
| 3569 | s0 = peg$FAILED;
|
|---|
| 3570 | }
|
|---|
| 3571 | peg$resultsCache[key] = {
|
|---|
| 3572 | nextPos: peg$currPos,
|
|---|
| 3573 | result: s0
|
|---|
| 3574 | };
|
|---|
| 3575 | return s0;
|
|---|
| 3576 | }
|
|---|
| 3577 | function peg$parsenthLastChild() {
|
|---|
| 3578 | var s0, s1, s2, s3, s4, s5;
|
|---|
| 3579 | var key = peg$currPos * 36 + 34,
|
|---|
| 3580 | cached = peg$resultsCache[key];
|
|---|
| 3581 | if (cached) {
|
|---|
| 3582 | peg$currPos = cached.nextPos;
|
|---|
| 3583 | return cached.result;
|
|---|
| 3584 | }
|
|---|
| 3585 | s0 = peg$currPos;
|
|---|
| 3586 | if (input.substr(peg$currPos, 16) === peg$c105) {
|
|---|
| 3587 | s1 = peg$c105;
|
|---|
| 3588 | peg$currPos += 16;
|
|---|
| 3589 | } else {
|
|---|
| 3590 | s1 = peg$FAILED;
|
|---|
| 3591 | {
|
|---|
| 3592 | peg$fail(peg$c106);
|
|---|
| 3593 | }
|
|---|
| 3594 | }
|
|---|
| 3595 | if (s1 !== peg$FAILED) {
|
|---|
| 3596 | s2 = peg$parse_();
|
|---|
| 3597 | if (s2 !== peg$FAILED) {
|
|---|
| 3598 | s3 = [];
|
|---|
| 3599 | if (peg$c61.test(input.charAt(peg$currPos))) {
|
|---|
| 3600 | s4 = input.charAt(peg$currPos);
|
|---|
| 3601 | peg$currPos++;
|
|---|
| 3602 | } else {
|
|---|
| 3603 | s4 = peg$FAILED;
|
|---|
| 3604 | {
|
|---|
| 3605 | peg$fail(peg$c62);
|
|---|
| 3606 | }
|
|---|
| 3607 | }
|
|---|
| 3608 | if (s4 !== peg$FAILED) {
|
|---|
| 3609 | while (s4 !== peg$FAILED) {
|
|---|
| 3610 | s3.push(s4);
|
|---|
| 3611 | if (peg$c61.test(input.charAt(peg$currPos))) {
|
|---|
| 3612 | s4 = input.charAt(peg$currPos);
|
|---|
| 3613 | peg$currPos++;
|
|---|
| 3614 | } else {
|
|---|
| 3615 | s4 = peg$FAILED;
|
|---|
| 3616 | {
|
|---|
| 3617 | peg$fail(peg$c62);
|
|---|
| 3618 | }
|
|---|
| 3619 | }
|
|---|
| 3620 | }
|
|---|
| 3621 | } else {
|
|---|
| 3622 | s3 = peg$FAILED;
|
|---|
| 3623 | }
|
|---|
| 3624 | if (s3 !== peg$FAILED) {
|
|---|
| 3625 | s4 = peg$parse_();
|
|---|
| 3626 | if (s4 !== peg$FAILED) {
|
|---|
| 3627 | if (input.charCodeAt(peg$currPos) === 41) {
|
|---|
| 3628 | s5 = peg$c69;
|
|---|
| 3629 | peg$currPos++;
|
|---|
| 3630 | } else {
|
|---|
| 3631 | s5 = peg$FAILED;
|
|---|
| 3632 | {
|
|---|
| 3633 | peg$fail(peg$c70);
|
|---|
| 3634 | }
|
|---|
| 3635 | }
|
|---|
| 3636 | if (s5 !== peg$FAILED) {
|
|---|
| 3637 | s1 = peg$c107(s3);
|
|---|
| 3638 | s0 = s1;
|
|---|
| 3639 | } else {
|
|---|
| 3640 | peg$currPos = s0;
|
|---|
| 3641 | s0 = peg$FAILED;
|
|---|
| 3642 | }
|
|---|
| 3643 | } else {
|
|---|
| 3644 | peg$currPos = s0;
|
|---|
| 3645 | s0 = peg$FAILED;
|
|---|
| 3646 | }
|
|---|
| 3647 | } else {
|
|---|
| 3648 | peg$currPos = s0;
|
|---|
| 3649 | s0 = peg$FAILED;
|
|---|
| 3650 | }
|
|---|
| 3651 | } else {
|
|---|
| 3652 | peg$currPos = s0;
|
|---|
| 3653 | s0 = peg$FAILED;
|
|---|
| 3654 | }
|
|---|
| 3655 | } else {
|
|---|
| 3656 | peg$currPos = s0;
|
|---|
| 3657 | s0 = peg$FAILED;
|
|---|
| 3658 | }
|
|---|
| 3659 | peg$resultsCache[key] = {
|
|---|
| 3660 | nextPos: peg$currPos,
|
|---|
| 3661 | result: s0
|
|---|
| 3662 | };
|
|---|
| 3663 | return s0;
|
|---|
| 3664 | }
|
|---|
| 3665 | function peg$parseclass() {
|
|---|
| 3666 | var s0, s1, s2;
|
|---|
| 3667 | var key = peg$currPos * 36 + 35,
|
|---|
| 3668 | cached = peg$resultsCache[key];
|
|---|
| 3669 | if (cached) {
|
|---|
| 3670 | peg$currPos = cached.nextPos;
|
|---|
| 3671 | return cached.result;
|
|---|
| 3672 | }
|
|---|
| 3673 | s0 = peg$currPos;
|
|---|
| 3674 | if (input.charCodeAt(peg$currPos) === 58) {
|
|---|
| 3675 | s1 = peg$c108;
|
|---|
| 3676 | peg$currPos++;
|
|---|
| 3677 | } else {
|
|---|
| 3678 | s1 = peg$FAILED;
|
|---|
| 3679 | {
|
|---|
| 3680 | peg$fail(peg$c109);
|
|---|
| 3681 | }
|
|---|
| 3682 | }
|
|---|
| 3683 | if (s1 !== peg$FAILED) {
|
|---|
| 3684 | s2 = peg$parseidentifierName();
|
|---|
| 3685 | if (s2 !== peg$FAILED) {
|
|---|
| 3686 | s1 = peg$c110(s2);
|
|---|
| 3687 | s0 = s1;
|
|---|
| 3688 | } else {
|
|---|
| 3689 | peg$currPos = s0;
|
|---|
| 3690 | s0 = peg$FAILED;
|
|---|
| 3691 | }
|
|---|
| 3692 | } else {
|
|---|
| 3693 | peg$currPos = s0;
|
|---|
| 3694 | s0 = peg$FAILED;
|
|---|
| 3695 | }
|
|---|
| 3696 | peg$resultsCache[key] = {
|
|---|
| 3697 | nextPos: peg$currPos,
|
|---|
| 3698 | result: s0
|
|---|
| 3699 | };
|
|---|
| 3700 | return s0;
|
|---|
| 3701 | }
|
|---|
| 3702 | function nth(n) {
|
|---|
| 3703 | return {
|
|---|
| 3704 | type: 'nth-child',
|
|---|
| 3705 | index: {
|
|---|
| 3706 | type: 'literal',
|
|---|
| 3707 | value: n
|
|---|
| 3708 | }
|
|---|
| 3709 | };
|
|---|
| 3710 | }
|
|---|
| 3711 | function nthLast(n) {
|
|---|
| 3712 | return {
|
|---|
| 3713 | type: 'nth-last-child',
|
|---|
| 3714 | index: {
|
|---|
| 3715 | type: 'literal',
|
|---|
| 3716 | value: n
|
|---|
| 3717 | }
|
|---|
| 3718 | };
|
|---|
| 3719 | }
|
|---|
| 3720 | function strUnescape(s) {
|
|---|
| 3721 | return s.replace(/\\(.)/g, function (match, ch) {
|
|---|
| 3722 | switch (ch) {
|
|---|
| 3723 | case 'b':
|
|---|
| 3724 | return '\b';
|
|---|
| 3725 | case 'f':
|
|---|
| 3726 | return '\f';
|
|---|
| 3727 | case 'n':
|
|---|
| 3728 | return '\n';
|
|---|
| 3729 | case 'r':
|
|---|
| 3730 | return '\r';
|
|---|
| 3731 | case 't':
|
|---|
| 3732 | return '\t';
|
|---|
| 3733 | case 'v':
|
|---|
| 3734 | return '\v';
|
|---|
| 3735 | default:
|
|---|
| 3736 | return ch;
|
|---|
| 3737 | }
|
|---|
| 3738 | });
|
|---|
| 3739 | }
|
|---|
| 3740 | peg$result = peg$startRuleFunction();
|
|---|
| 3741 | if (peg$result !== peg$FAILED && peg$currPos === input.length) {
|
|---|
| 3742 | return peg$result;
|
|---|
| 3743 | } else {
|
|---|
| 3744 | if (peg$result !== peg$FAILED && peg$currPos < input.length) {
|
|---|
| 3745 | peg$fail(peg$endExpectation());
|
|---|
| 3746 | }
|
|---|
| 3747 | 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));
|
|---|
| 3748 | }
|
|---|
| 3749 | }
|
|---|
| 3750 | return {
|
|---|
| 3751 | SyntaxError: peg$SyntaxError,
|
|---|
| 3752 | parse: peg$parse
|
|---|
| 3753 | };
|
|---|
| 3754 | });
|
|---|
| 3755 | });
|
|---|
| 3756 |
|
|---|
| 3757 | /**
|
|---|
| 3758 | * @typedef {"LEFT_SIDE"|"RIGHT_SIDE"} Side
|
|---|
| 3759 | */
|
|---|
| 3760 |
|
|---|
| 3761 | var LEFT_SIDE = 'LEFT_SIDE';
|
|---|
| 3762 | var RIGHT_SIDE = 'RIGHT_SIDE';
|
|---|
| 3763 |
|
|---|
| 3764 | /**
|
|---|
| 3765 | * @external AST
|
|---|
| 3766 | * @see https://esprima.readthedocs.io/en/latest/syntax-tree-format.html
|
|---|
| 3767 | */
|
|---|
| 3768 |
|
|---|
| 3769 | /**
|
|---|
| 3770 | * One of the rules of `grammar.pegjs`
|
|---|
| 3771 | * @typedef {PlainObject} SelectorAST
|
|---|
| 3772 | * @see grammar.pegjs
|
|---|
| 3773 | */
|
|---|
| 3774 |
|
|---|
| 3775 | /**
|
|---|
| 3776 | * The `sequence` production of `grammar.pegjs`
|
|---|
| 3777 | * @typedef {PlainObject} SelectorSequenceAST
|
|---|
| 3778 | */
|
|---|
| 3779 |
|
|---|
| 3780 | /**
|
|---|
| 3781 | * Get the value of a property which may be multiple levels down
|
|---|
| 3782 | * in the object.
|
|---|
| 3783 | * @param {?PlainObject} obj
|
|---|
| 3784 | * @param {string[]} keys
|
|---|
| 3785 | * @returns {undefined|boolean|string|number|external:AST}
|
|---|
| 3786 | */
|
|---|
| 3787 | function getPath(obj, keys) {
|
|---|
| 3788 | for (var i = 0; i < keys.length; ++i) {
|
|---|
| 3789 | if (obj == null) {
|
|---|
| 3790 | return obj;
|
|---|
| 3791 | }
|
|---|
| 3792 | obj = obj[keys[i]];
|
|---|
| 3793 | }
|
|---|
| 3794 | return obj;
|
|---|
| 3795 | }
|
|---|
| 3796 |
|
|---|
| 3797 | /**
|
|---|
| 3798 | * Determine whether `node` can be reached by following `path`,
|
|---|
| 3799 | * starting at `ancestor`.
|
|---|
| 3800 | * @param {?external:AST} node
|
|---|
| 3801 | * @param {?external:AST} ancestor
|
|---|
| 3802 | * @param {string[]} path
|
|---|
| 3803 | * @param {Integer} fromPathIndex
|
|---|
| 3804 | * @returns {boolean}
|
|---|
| 3805 | */
|
|---|
| 3806 | function inPath(node, ancestor, path, fromPathIndex) {
|
|---|
| 3807 | var current = ancestor;
|
|---|
| 3808 | for (var i = fromPathIndex; i < path.length; ++i) {
|
|---|
| 3809 | if (current == null) {
|
|---|
| 3810 | return false;
|
|---|
| 3811 | }
|
|---|
| 3812 | var field = current[path[i]];
|
|---|
| 3813 | if (Array.isArray(field)) {
|
|---|
| 3814 | for (var k = 0; k < field.length; ++k) {
|
|---|
| 3815 | if (inPath(node, field[k], path, i + 1)) {
|
|---|
| 3816 | return true;
|
|---|
| 3817 | }
|
|---|
| 3818 | }
|
|---|
| 3819 | return false;
|
|---|
| 3820 | }
|
|---|
| 3821 | current = field;
|
|---|
| 3822 | }
|
|---|
| 3823 | return node === current;
|
|---|
| 3824 | }
|
|---|
| 3825 |
|
|---|
| 3826 | /**
|
|---|
| 3827 | * A generated matcher function for a selector.
|
|---|
| 3828 | * @callback SelectorMatcher
|
|---|
| 3829 | * @param {?SelectorAST} selector
|
|---|
| 3830 | * @param {external:AST[]} [ancestry=[]]
|
|---|
| 3831 | * @param {ESQueryOptions} [options]
|
|---|
| 3832 | * @returns {void}
|
|---|
| 3833 | */
|
|---|
| 3834 |
|
|---|
| 3835 | /**
|
|---|
| 3836 | * A WeakMap for holding cached matcher functions for selectors.
|
|---|
| 3837 | * @type {WeakMap<SelectorAST, SelectorMatcher>}
|
|---|
| 3838 | */
|
|---|
| 3839 | var MATCHER_CACHE = typeof WeakMap === 'function' ? new WeakMap() : null;
|
|---|
| 3840 |
|
|---|
| 3841 | /**
|
|---|
| 3842 | * Look up a matcher function for `selector` in the cache.
|
|---|
| 3843 | * If it does not exist, generate it with `generateMatcher` and add it to the cache.
|
|---|
| 3844 | * In engines without WeakMap, the caching is skipped and matchers are generated with every call.
|
|---|
| 3845 | * @param {?SelectorAST} selector
|
|---|
| 3846 | * @returns {SelectorMatcher}
|
|---|
| 3847 | */
|
|---|
| 3848 | function getMatcher(selector) {
|
|---|
| 3849 | if (selector == null) {
|
|---|
| 3850 | return function () {
|
|---|
| 3851 | return true;
|
|---|
| 3852 | };
|
|---|
| 3853 | }
|
|---|
| 3854 | if (MATCHER_CACHE != null) {
|
|---|
| 3855 | var matcher = MATCHER_CACHE.get(selector);
|
|---|
| 3856 | if (matcher != null) {
|
|---|
| 3857 | return matcher;
|
|---|
| 3858 | }
|
|---|
| 3859 | matcher = generateMatcher(selector);
|
|---|
| 3860 | MATCHER_CACHE.set(selector, matcher);
|
|---|
| 3861 | return matcher;
|
|---|
| 3862 | }
|
|---|
| 3863 | return generateMatcher(selector);
|
|---|
| 3864 | }
|
|---|
| 3865 |
|
|---|
| 3866 | /**
|
|---|
| 3867 | * Create a matcher function for `selector`,
|
|---|
| 3868 | * @param {?SelectorAST} selector
|
|---|
| 3869 | * @returns {SelectorMatcher}
|
|---|
| 3870 | */
|
|---|
| 3871 | function generateMatcher(selector) {
|
|---|
| 3872 | switch (selector.type) {
|
|---|
| 3873 | case 'wildcard':
|
|---|
| 3874 | return function () {
|
|---|
| 3875 | return true;
|
|---|
| 3876 | };
|
|---|
| 3877 | case 'identifier':
|
|---|
| 3878 | {
|
|---|
| 3879 | var value = selector.value.toLowerCase();
|
|---|
| 3880 | return function (node, ancestry, options) {
|
|---|
| 3881 | var nodeTypeKey = options && options.nodeTypeKey || 'type';
|
|---|
| 3882 | return value === node[nodeTypeKey].toLowerCase();
|
|---|
| 3883 | };
|
|---|
| 3884 | }
|
|---|
| 3885 | case 'exactNode':
|
|---|
| 3886 | return function (node, ancestry) {
|
|---|
| 3887 | return ancestry.length === 0;
|
|---|
| 3888 | };
|
|---|
| 3889 | case 'field':
|
|---|
| 3890 | {
|
|---|
| 3891 | var path = selector.name.split('.');
|
|---|
| 3892 | return function (node, ancestry) {
|
|---|
| 3893 | var ancestor = ancestry[path.length - 1];
|
|---|
| 3894 | return inPath(node, ancestor, path, 0);
|
|---|
| 3895 | };
|
|---|
| 3896 | }
|
|---|
| 3897 | case 'matches':
|
|---|
| 3898 | {
|
|---|
| 3899 | var matchers = selector.selectors.map(getMatcher);
|
|---|
| 3900 | return function (node, ancestry, options) {
|
|---|
| 3901 | for (var i = 0; i < matchers.length; ++i) {
|
|---|
| 3902 | if (matchers[i](node, ancestry, options)) {
|
|---|
| 3903 | return true;
|
|---|
| 3904 | }
|
|---|
| 3905 | }
|
|---|
| 3906 | return false;
|
|---|
| 3907 | };
|
|---|
| 3908 | }
|
|---|
| 3909 | case 'compound':
|
|---|
| 3910 | {
|
|---|
| 3911 | var _matchers = selector.selectors.map(getMatcher);
|
|---|
| 3912 | return function (node, ancestry, options) {
|
|---|
| 3913 | for (var i = 0; i < _matchers.length; ++i) {
|
|---|
| 3914 | if (!_matchers[i](node, ancestry, options)) {
|
|---|
| 3915 | return false;
|
|---|
| 3916 | }
|
|---|
| 3917 | }
|
|---|
| 3918 | return true;
|
|---|
| 3919 | };
|
|---|
| 3920 | }
|
|---|
| 3921 | case 'not':
|
|---|
| 3922 | {
|
|---|
| 3923 | var _matchers2 = selector.selectors.map(getMatcher);
|
|---|
| 3924 | return function (node, ancestry, options) {
|
|---|
| 3925 | for (var i = 0; i < _matchers2.length; ++i) {
|
|---|
| 3926 | if (_matchers2[i](node, ancestry, options)) {
|
|---|
| 3927 | return false;
|
|---|
| 3928 | }
|
|---|
| 3929 | }
|
|---|
| 3930 | return true;
|
|---|
| 3931 | };
|
|---|
| 3932 | }
|
|---|
| 3933 | case 'has':
|
|---|
| 3934 | {
|
|---|
| 3935 | var _matchers3 = selector.selectors.map(getMatcher);
|
|---|
| 3936 | return function (node, ancestry, options) {
|
|---|
| 3937 | var result = false;
|
|---|
| 3938 | var a = [];
|
|---|
| 3939 | estraverse.traverse(node, {
|
|---|
| 3940 | enter: function enter(node, parent) {
|
|---|
| 3941 | if (parent != null) {
|
|---|
| 3942 | a.unshift(parent);
|
|---|
| 3943 | }
|
|---|
| 3944 | for (var i = 0; i < _matchers3.length; ++i) {
|
|---|
| 3945 | if (_matchers3[i](node, a, options)) {
|
|---|
| 3946 | result = true;
|
|---|
| 3947 | this["break"]();
|
|---|
| 3948 | return;
|
|---|
| 3949 | }
|
|---|
| 3950 | }
|
|---|
| 3951 | },
|
|---|
| 3952 | leave: function leave() {
|
|---|
| 3953 | a.shift();
|
|---|
| 3954 | },
|
|---|
| 3955 | keys: options && options.visitorKeys,
|
|---|
| 3956 | fallback: options && options.fallback || 'iteration'
|
|---|
| 3957 | });
|
|---|
| 3958 | return result;
|
|---|
| 3959 | };
|
|---|
| 3960 | }
|
|---|
| 3961 | case 'child':
|
|---|
| 3962 | {
|
|---|
| 3963 | var left = getMatcher(selector.left);
|
|---|
| 3964 | var right = getMatcher(selector.right);
|
|---|
| 3965 | return function (node, ancestry, options) {
|
|---|
| 3966 | if (ancestry.length > 0 && right(node, ancestry, options)) {
|
|---|
| 3967 | return left(ancestry[0], ancestry.slice(1), options);
|
|---|
| 3968 | }
|
|---|
| 3969 | return false;
|
|---|
| 3970 | };
|
|---|
| 3971 | }
|
|---|
| 3972 | case 'descendant':
|
|---|
| 3973 | {
|
|---|
| 3974 | var _left = getMatcher(selector.left);
|
|---|
| 3975 | var _right = getMatcher(selector.right);
|
|---|
| 3976 | return function (node, ancestry, options) {
|
|---|
| 3977 | if (_right(node, ancestry, options)) {
|
|---|
| 3978 | for (var i = 0, l = ancestry.length; i < l; ++i) {
|
|---|
| 3979 | if (_left(ancestry[i], ancestry.slice(i + 1), options)) {
|
|---|
| 3980 | return true;
|
|---|
| 3981 | }
|
|---|
| 3982 | }
|
|---|
| 3983 | }
|
|---|
| 3984 | return false;
|
|---|
| 3985 | };
|
|---|
| 3986 | }
|
|---|
| 3987 | case 'attribute':
|
|---|
| 3988 | {
|
|---|
| 3989 | var _path = selector.name.split('.');
|
|---|
| 3990 | switch (selector.operator) {
|
|---|
| 3991 | case void 0:
|
|---|
| 3992 | return function (node) {
|
|---|
| 3993 | return getPath(node, _path) != null;
|
|---|
| 3994 | };
|
|---|
| 3995 | case '=':
|
|---|
| 3996 | switch (selector.value.type) {
|
|---|
| 3997 | case 'regexp':
|
|---|
| 3998 | return function (node) {
|
|---|
| 3999 | var p = getPath(node, _path);
|
|---|
| 4000 | return typeof p === 'string' && selector.value.value.test(p);
|
|---|
| 4001 | };
|
|---|
| 4002 | case 'literal':
|
|---|
| 4003 | {
|
|---|
| 4004 | var literal = "".concat(selector.value.value);
|
|---|
| 4005 | return function (node) {
|
|---|
| 4006 | return literal === "".concat(getPath(node, _path));
|
|---|
| 4007 | };
|
|---|
| 4008 | }
|
|---|
| 4009 | case 'type':
|
|---|
| 4010 | return function (node) {
|
|---|
| 4011 | return selector.value.value === _typeof(getPath(node, _path));
|
|---|
| 4012 | };
|
|---|
| 4013 | }
|
|---|
| 4014 | throw new Error("Unknown selector value type: ".concat(selector.value.type));
|
|---|
| 4015 | case '!=':
|
|---|
| 4016 | switch (selector.value.type) {
|
|---|
| 4017 | case 'regexp':
|
|---|
| 4018 | return function (node) {
|
|---|
| 4019 | return !selector.value.value.test(getPath(node, _path));
|
|---|
| 4020 | };
|
|---|
| 4021 | case 'literal':
|
|---|
| 4022 | {
|
|---|
| 4023 | var _literal = "".concat(selector.value.value);
|
|---|
| 4024 | return function (node) {
|
|---|
| 4025 | return _literal !== "".concat(getPath(node, _path));
|
|---|
| 4026 | };
|
|---|
| 4027 | }
|
|---|
| 4028 | case 'type':
|
|---|
| 4029 | return function (node) {
|
|---|
| 4030 | return selector.value.value !== _typeof(getPath(node, _path));
|
|---|
| 4031 | };
|
|---|
| 4032 | }
|
|---|
| 4033 | throw new Error("Unknown selector value type: ".concat(selector.value.type));
|
|---|
| 4034 | case '<=':
|
|---|
| 4035 | return function (node) {
|
|---|
| 4036 | return getPath(node, _path) <= selector.value.value;
|
|---|
| 4037 | };
|
|---|
| 4038 | case '<':
|
|---|
| 4039 | return function (node) {
|
|---|
| 4040 | return getPath(node, _path) < selector.value.value;
|
|---|
| 4041 | };
|
|---|
| 4042 | case '>':
|
|---|
| 4043 | return function (node) {
|
|---|
| 4044 | return getPath(node, _path) > selector.value.value;
|
|---|
| 4045 | };
|
|---|
| 4046 | case '>=':
|
|---|
| 4047 | return function (node) {
|
|---|
| 4048 | return getPath(node, _path) >= selector.value.value;
|
|---|
| 4049 | };
|
|---|
| 4050 | }
|
|---|
| 4051 | throw new Error("Unknown operator: ".concat(selector.operator));
|
|---|
| 4052 | }
|
|---|
| 4053 | case 'sibling':
|
|---|
| 4054 | {
|
|---|
| 4055 | var _left2 = getMatcher(selector.left);
|
|---|
| 4056 | var _right2 = getMatcher(selector.right);
|
|---|
| 4057 | return function (node, ancestry, options) {
|
|---|
| 4058 | return _right2(node, ancestry, options) && sibling(node, _left2, ancestry, LEFT_SIDE, options) || selector.left.subject && _left2(node, ancestry, options) && sibling(node, _right2, ancestry, RIGHT_SIDE, options);
|
|---|
| 4059 | };
|
|---|
| 4060 | }
|
|---|
| 4061 | case 'adjacent':
|
|---|
| 4062 | {
|
|---|
| 4063 | var _left3 = getMatcher(selector.left);
|
|---|
| 4064 | var _right3 = getMatcher(selector.right);
|
|---|
| 4065 | return function (node, ancestry, options) {
|
|---|
| 4066 | return _right3(node, ancestry, options) && adjacent(node, _left3, ancestry, LEFT_SIDE, options) || selector.right.subject && _left3(node, ancestry, options) && adjacent(node, _right3, ancestry, RIGHT_SIDE, options);
|
|---|
| 4067 | };
|
|---|
| 4068 | }
|
|---|
| 4069 | case 'nth-child':
|
|---|
| 4070 | {
|
|---|
| 4071 | var nth = selector.index.value;
|
|---|
| 4072 | var _right4 = getMatcher(selector.right);
|
|---|
| 4073 | return function (node, ancestry, options) {
|
|---|
| 4074 | return _right4(node, ancestry, options) && nthChild(node, ancestry, nth, options);
|
|---|
| 4075 | };
|
|---|
| 4076 | }
|
|---|
| 4077 | case 'nth-last-child':
|
|---|
| 4078 | {
|
|---|
| 4079 | var _nth = -selector.index.value;
|
|---|
| 4080 | var _right5 = getMatcher(selector.right);
|
|---|
| 4081 | return function (node, ancestry, options) {
|
|---|
| 4082 | return _right5(node, ancestry, options) && nthChild(node, ancestry, _nth, options);
|
|---|
| 4083 | };
|
|---|
| 4084 | }
|
|---|
| 4085 | case 'class':
|
|---|
| 4086 | {
|
|---|
| 4087 | var name = selector.name.toLowerCase();
|
|---|
| 4088 | return function (node, ancestry, options) {
|
|---|
| 4089 | if (options && options.matchClass) {
|
|---|
| 4090 | return options.matchClass(selector.name, node, ancestry);
|
|---|
| 4091 | }
|
|---|
| 4092 | if (options && options.nodeTypeKey) return false;
|
|---|
| 4093 | switch (name) {
|
|---|
| 4094 | case 'statement':
|
|---|
| 4095 | if (node.type.slice(-9) === 'Statement') return true;
|
|---|
| 4096 | // fallthrough: interface Declaration <: Statement { }
|
|---|
| 4097 | case 'declaration':
|
|---|
| 4098 | return node.type.slice(-11) === 'Declaration';
|
|---|
| 4099 | case 'pattern':
|
|---|
| 4100 | if (node.type.slice(-7) === 'Pattern') return true;
|
|---|
| 4101 | // fallthrough: interface Expression <: Node, Pattern { }
|
|---|
| 4102 | case 'expression':
|
|---|
| 4103 | return node.type.slice(-10) === 'Expression' || node.type.slice(-7) === 'Literal' || node.type === 'Identifier' && (ancestry.length === 0 || ancestry[0].type !== 'MetaProperty') || node.type === 'MetaProperty';
|
|---|
| 4104 | case 'function':
|
|---|
| 4105 | return node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression';
|
|---|
| 4106 | }
|
|---|
| 4107 | throw new Error("Unknown class name: ".concat(selector.name));
|
|---|
| 4108 | };
|
|---|
| 4109 | }
|
|---|
| 4110 | }
|
|---|
| 4111 | throw new Error("Unknown selector type: ".concat(selector.type));
|
|---|
| 4112 | }
|
|---|
| 4113 |
|
|---|
| 4114 | /**
|
|---|
| 4115 | * @callback TraverseOptionFallback
|
|---|
| 4116 | * @param {external:AST} node The given node.
|
|---|
| 4117 | * @returns {string[]} An array of visitor keys for the given node.
|
|---|
| 4118 | */
|
|---|
| 4119 |
|
|---|
| 4120 | /**
|
|---|
| 4121 | * @callback ClassMatcher
|
|---|
| 4122 | * @param {string} className The name of the class to match.
|
|---|
| 4123 | * @param {external:AST} node The node to match against.
|
|---|
| 4124 | * @param {Array<external:AST>} ancestry The ancestry of the node.
|
|---|
| 4125 | * @returns {boolean} True if the node matches the class, false if not.
|
|---|
| 4126 | */
|
|---|
| 4127 |
|
|---|
| 4128 | /**
|
|---|
| 4129 | * @typedef {object} ESQueryOptions
|
|---|
| 4130 | * @property {string} [nodeTypeKey="type"] By passing `nodeTypeKey`, we can allow other ASTs to use ESQuery.
|
|---|
| 4131 | * @property { { [nodeType: string]: string[] } } [visitorKeys] By passing `visitorKeys` mapping, we can extend the properties of the nodes that traverse the node.
|
|---|
| 4132 | * @property {TraverseOptionFallback} [fallback] By passing `fallback` option, we can control the properties of traversing nodes when encountering unknown nodes.
|
|---|
| 4133 | * @property {ClassMatcher} [matchClass] By passing `matchClass` option, we can customize the interpretation of classes.
|
|---|
| 4134 | */
|
|---|
| 4135 |
|
|---|
| 4136 | /**
|
|---|
| 4137 | * Given a `node` and its ancestors, determine if `node` is matched
|
|---|
| 4138 | * by `selector`.
|
|---|
| 4139 | * @param {?external:AST} node
|
|---|
| 4140 | * @param {?SelectorAST} selector
|
|---|
| 4141 | * @param {external:AST[]} [ancestry=[]]
|
|---|
| 4142 | * @param {ESQueryOptions} [options]
|
|---|
| 4143 | * @throws {Error} Unknowns (operator, class name, selector type, or
|
|---|
| 4144 | * selector value type)
|
|---|
| 4145 | * @returns {boolean}
|
|---|
| 4146 | */
|
|---|
| 4147 | function matches(node, selector, ancestry, options) {
|
|---|
| 4148 | if (!selector) {
|
|---|
| 4149 | return true;
|
|---|
| 4150 | }
|
|---|
| 4151 | if (!node) {
|
|---|
| 4152 | return false;
|
|---|
| 4153 | }
|
|---|
| 4154 | if (!ancestry) {
|
|---|
| 4155 | ancestry = [];
|
|---|
| 4156 | }
|
|---|
| 4157 | return getMatcher(selector)(node, ancestry, options);
|
|---|
| 4158 | }
|
|---|
| 4159 |
|
|---|
| 4160 | /**
|
|---|
| 4161 | * Get visitor keys of a given node.
|
|---|
| 4162 | * @param {external:AST} node The AST node to get keys.
|
|---|
| 4163 | * @param {ESQueryOptions|undefined} options
|
|---|
| 4164 | * @returns {string[]} Visitor keys of the node.
|
|---|
| 4165 | */
|
|---|
| 4166 | function getVisitorKeys(node, options) {
|
|---|
| 4167 | var nodeTypeKey = options && options.nodeTypeKey || 'type';
|
|---|
| 4168 | var nodeType = node[nodeTypeKey];
|
|---|
| 4169 | if (options && options.visitorKeys && options.visitorKeys[nodeType]) {
|
|---|
| 4170 | return options.visitorKeys[nodeType];
|
|---|
| 4171 | }
|
|---|
| 4172 | if (estraverse.VisitorKeys[nodeType]) {
|
|---|
| 4173 | return estraverse.VisitorKeys[nodeType];
|
|---|
| 4174 | }
|
|---|
| 4175 | if (options && typeof options.fallback === 'function') {
|
|---|
| 4176 | return options.fallback(node);
|
|---|
| 4177 | }
|
|---|
| 4178 | // 'iteration' fallback
|
|---|
| 4179 | return Object.keys(node).filter(function (key) {
|
|---|
| 4180 | return key !== nodeTypeKey;
|
|---|
| 4181 | });
|
|---|
| 4182 | }
|
|---|
| 4183 |
|
|---|
| 4184 | /**
|
|---|
| 4185 | * Check whether the given value is an ASTNode or not.
|
|---|
| 4186 | * @param {any} node The value to check.
|
|---|
| 4187 | * @param {ESQueryOptions|undefined} options The options to use.
|
|---|
| 4188 | * @returns {boolean} `true` if the value is an ASTNode.
|
|---|
| 4189 | */
|
|---|
| 4190 | function isNode(node, options) {
|
|---|
| 4191 | var nodeTypeKey = options && options.nodeTypeKey || 'type';
|
|---|
| 4192 | return node !== null && _typeof(node) === 'object' && typeof node[nodeTypeKey] === 'string';
|
|---|
| 4193 | }
|
|---|
| 4194 |
|
|---|
| 4195 | /**
|
|---|
| 4196 | * Determines if the given node has a sibling that matches the
|
|---|
| 4197 | * given selector matcher.
|
|---|
| 4198 | * @param {external:AST} node
|
|---|
| 4199 | * @param {SelectorMatcher} matcher
|
|---|
| 4200 | * @param {external:AST[]} ancestry
|
|---|
| 4201 | * @param {Side} side
|
|---|
| 4202 | * @param {ESQueryOptions|undefined} options
|
|---|
| 4203 | * @returns {boolean}
|
|---|
| 4204 | */
|
|---|
| 4205 | function sibling(node, matcher, ancestry, side, options) {
|
|---|
| 4206 | var _ancestry = _slicedToArray(ancestry, 1),
|
|---|
| 4207 | parent = _ancestry[0];
|
|---|
| 4208 | if (!parent) {
|
|---|
| 4209 | return false;
|
|---|
| 4210 | }
|
|---|
| 4211 | var keys = getVisitorKeys(parent, options);
|
|---|
| 4212 | for (var i = 0; i < keys.length; ++i) {
|
|---|
| 4213 | var listProp = parent[keys[i]];
|
|---|
| 4214 | if (Array.isArray(listProp)) {
|
|---|
| 4215 | var startIndex = listProp.indexOf(node);
|
|---|
| 4216 | if (startIndex < 0) {
|
|---|
| 4217 | continue;
|
|---|
| 4218 | }
|
|---|
| 4219 | var lowerBound = void 0,
|
|---|
| 4220 | upperBound = void 0;
|
|---|
| 4221 | if (side === LEFT_SIDE) {
|
|---|
| 4222 | lowerBound = 0;
|
|---|
| 4223 | upperBound = startIndex;
|
|---|
| 4224 | } else {
|
|---|
| 4225 | lowerBound = startIndex + 1;
|
|---|
| 4226 | upperBound = listProp.length;
|
|---|
| 4227 | }
|
|---|
| 4228 | for (var k = lowerBound; k < upperBound; ++k) {
|
|---|
| 4229 | if (isNode(listProp[k], options) && matcher(listProp[k], ancestry, options)) {
|
|---|
| 4230 | return true;
|
|---|
| 4231 | }
|
|---|
| 4232 | }
|
|---|
| 4233 | }
|
|---|
| 4234 | }
|
|---|
| 4235 | return false;
|
|---|
| 4236 | }
|
|---|
| 4237 |
|
|---|
| 4238 | /**
|
|---|
| 4239 | * Determines if the given node has an adjacent sibling that matches
|
|---|
| 4240 | * the given selector matcher.
|
|---|
| 4241 | * @param {external:AST} node
|
|---|
| 4242 | * @param {SelectorMatcher} matcher
|
|---|
| 4243 | * @param {external:AST[]} ancestry
|
|---|
| 4244 | * @param {Side} side
|
|---|
| 4245 | * @param {ESQueryOptions|undefined} options
|
|---|
| 4246 | * @returns {boolean}
|
|---|
| 4247 | */
|
|---|
| 4248 | function adjacent(node, matcher, ancestry, side, options) {
|
|---|
| 4249 | var _ancestry2 = _slicedToArray(ancestry, 1),
|
|---|
| 4250 | parent = _ancestry2[0];
|
|---|
| 4251 | if (!parent) {
|
|---|
| 4252 | return false;
|
|---|
| 4253 | }
|
|---|
| 4254 | var keys = getVisitorKeys(parent, options);
|
|---|
| 4255 | for (var i = 0; i < keys.length; ++i) {
|
|---|
| 4256 | var listProp = parent[keys[i]];
|
|---|
| 4257 | if (Array.isArray(listProp)) {
|
|---|
| 4258 | var idx = listProp.indexOf(node);
|
|---|
| 4259 | if (idx < 0) {
|
|---|
| 4260 | continue;
|
|---|
| 4261 | }
|
|---|
| 4262 | if (side === LEFT_SIDE && idx > 0 && isNode(listProp[idx - 1], options) && matcher(listProp[idx - 1], ancestry, options)) {
|
|---|
| 4263 | return true;
|
|---|
| 4264 | }
|
|---|
| 4265 | if (side === RIGHT_SIDE && idx < listProp.length - 1 && isNode(listProp[idx + 1], options) && matcher(listProp[idx + 1], ancestry, options)) {
|
|---|
| 4266 | return true;
|
|---|
| 4267 | }
|
|---|
| 4268 | }
|
|---|
| 4269 | }
|
|---|
| 4270 | return false;
|
|---|
| 4271 | }
|
|---|
| 4272 |
|
|---|
| 4273 | /**
|
|---|
| 4274 | * Determines if the given node is the `nth` child.
|
|---|
| 4275 | * If `nth` is negative then the position is counted
|
|---|
| 4276 | * from the end of the list of children.
|
|---|
| 4277 | * @param {external:AST} node
|
|---|
| 4278 | * @param {external:AST[]} ancestry
|
|---|
| 4279 | * @param {Integer} nth
|
|---|
| 4280 | * @param {ESQueryOptions|undefined} options
|
|---|
| 4281 | * @returns {boolean}
|
|---|
| 4282 | */
|
|---|
| 4283 | function nthChild(node, ancestry, nth, options) {
|
|---|
| 4284 | if (nth === 0) {
|
|---|
| 4285 | return false;
|
|---|
| 4286 | }
|
|---|
| 4287 | var _ancestry3 = _slicedToArray(ancestry, 1),
|
|---|
| 4288 | parent = _ancestry3[0];
|
|---|
| 4289 | if (!parent) {
|
|---|
| 4290 | return false;
|
|---|
| 4291 | }
|
|---|
| 4292 | var keys = getVisitorKeys(parent, options);
|
|---|
| 4293 | for (var i = 0; i < keys.length; ++i) {
|
|---|
| 4294 | var listProp = parent[keys[i]];
|
|---|
| 4295 | if (Array.isArray(listProp)) {
|
|---|
| 4296 | var idx = nth < 0 ? listProp.length + nth : nth - 1;
|
|---|
| 4297 | if (idx >= 0 && idx < listProp.length && listProp[idx] === node) {
|
|---|
| 4298 | return true;
|
|---|
| 4299 | }
|
|---|
| 4300 | }
|
|---|
| 4301 | }
|
|---|
| 4302 | return false;
|
|---|
| 4303 | }
|
|---|
| 4304 |
|
|---|
| 4305 | /**
|
|---|
| 4306 | * For each selector node marked as a subject, find the portion of the
|
|---|
| 4307 | * selector that the subject must match.
|
|---|
| 4308 | * @param {SelectorAST} selector
|
|---|
| 4309 | * @param {SelectorAST} [ancestor] Defaults to `selector`
|
|---|
| 4310 | * @returns {SelectorAST[]}
|
|---|
| 4311 | */
|
|---|
| 4312 | function subjects(selector, ancestor) {
|
|---|
| 4313 | if (selector == null || _typeof(selector) != 'object') {
|
|---|
| 4314 | return [];
|
|---|
| 4315 | }
|
|---|
| 4316 | if (ancestor == null) {
|
|---|
| 4317 | ancestor = selector;
|
|---|
| 4318 | }
|
|---|
| 4319 | var results = selector.subject ? [ancestor] : [];
|
|---|
| 4320 | var keys = Object.keys(selector);
|
|---|
| 4321 | for (var i = 0; i < keys.length; ++i) {
|
|---|
| 4322 | var p = keys[i];
|
|---|
| 4323 | var sel = selector[p];
|
|---|
| 4324 | results.push.apply(results, _toConsumableArray(subjects(sel, p === 'left' ? sel : ancestor)));
|
|---|
| 4325 | }
|
|---|
| 4326 | return results;
|
|---|
| 4327 | }
|
|---|
| 4328 |
|
|---|
| 4329 | /**
|
|---|
| 4330 | * @callback TraverseVisitor
|
|---|
| 4331 | * @param {?external:AST} node
|
|---|
| 4332 | * @param {?external:AST} parent
|
|---|
| 4333 | * @param {external:AST[]} ancestry
|
|---|
| 4334 | */
|
|---|
| 4335 |
|
|---|
| 4336 | /**
|
|---|
| 4337 | * From a JS AST and a selector AST, collect all JS AST nodes that
|
|---|
| 4338 | * match the selector.
|
|---|
| 4339 | * @param {external:AST} ast
|
|---|
| 4340 | * @param {?SelectorAST} selector
|
|---|
| 4341 | * @param {TraverseVisitor} visitor
|
|---|
| 4342 | * @param {ESQueryOptions} [options]
|
|---|
| 4343 | * @returns {external:AST[]}
|
|---|
| 4344 | */
|
|---|
| 4345 | function traverse(ast, selector, visitor, options) {
|
|---|
| 4346 | if (!selector) {
|
|---|
| 4347 | return;
|
|---|
| 4348 | }
|
|---|
| 4349 | var ancestry = [];
|
|---|
| 4350 | var matcher = getMatcher(selector);
|
|---|
| 4351 | var altSubjects = subjects(selector).map(getMatcher);
|
|---|
| 4352 | estraverse.traverse(ast, {
|
|---|
| 4353 | enter: function enter(node, parent) {
|
|---|
| 4354 | if (parent != null) {
|
|---|
| 4355 | ancestry.unshift(parent);
|
|---|
| 4356 | }
|
|---|
| 4357 | if (matcher(node, ancestry, options)) {
|
|---|
| 4358 | if (altSubjects.length) {
|
|---|
| 4359 | for (var i = 0, l = altSubjects.length; i < l; ++i) {
|
|---|
| 4360 | if (altSubjects[i](node, ancestry, options)) {
|
|---|
| 4361 | visitor(node, parent, ancestry);
|
|---|
| 4362 | }
|
|---|
| 4363 | for (var k = 0, m = ancestry.length; k < m; ++k) {
|
|---|
| 4364 | var succeedingAncestry = ancestry.slice(k + 1);
|
|---|
| 4365 | if (altSubjects[i](ancestry[k], succeedingAncestry, options)) {
|
|---|
| 4366 | visitor(ancestry[k], parent, succeedingAncestry);
|
|---|
| 4367 | }
|
|---|
| 4368 | }
|
|---|
| 4369 | }
|
|---|
| 4370 | } else {
|
|---|
| 4371 | visitor(node, parent, ancestry);
|
|---|
| 4372 | }
|
|---|
| 4373 | }
|
|---|
| 4374 | },
|
|---|
| 4375 | leave: function leave() {
|
|---|
| 4376 | ancestry.shift();
|
|---|
| 4377 | },
|
|---|
| 4378 | keys: options && options.visitorKeys,
|
|---|
| 4379 | fallback: options && options.fallback || 'iteration'
|
|---|
| 4380 | });
|
|---|
| 4381 | }
|
|---|
| 4382 |
|
|---|
| 4383 | /**
|
|---|
| 4384 | * From a JS AST and a selector AST, collect all JS AST nodes that
|
|---|
| 4385 | * match the selector.
|
|---|
| 4386 | * @param {external:AST} ast
|
|---|
| 4387 | * @param {?SelectorAST} selector
|
|---|
| 4388 | * @param {ESQueryOptions} [options]
|
|---|
| 4389 | * @returns {external:AST[]}
|
|---|
| 4390 | */
|
|---|
| 4391 | function match(ast, selector, options) {
|
|---|
| 4392 | var results = [];
|
|---|
| 4393 | traverse(ast, selector, function (node) {
|
|---|
| 4394 | results.push(node);
|
|---|
| 4395 | }, options);
|
|---|
| 4396 | return results;
|
|---|
| 4397 | }
|
|---|
| 4398 |
|
|---|
| 4399 | /**
|
|---|
| 4400 | * Parse a selector string and return its AST.
|
|---|
| 4401 | * @param {string} selector
|
|---|
| 4402 | * @returns {SelectorAST}
|
|---|
| 4403 | */
|
|---|
| 4404 | function parse(selector) {
|
|---|
| 4405 | return parser.parse(selector);
|
|---|
| 4406 | }
|
|---|
| 4407 |
|
|---|
| 4408 | /**
|
|---|
| 4409 | * Query the code AST using the selector string.
|
|---|
| 4410 | * @param {external:AST} ast
|
|---|
| 4411 | * @param {string} selector
|
|---|
| 4412 | * @param {ESQueryOptions} [options]
|
|---|
| 4413 | * @returns {external:AST[]}
|
|---|
| 4414 | */
|
|---|
| 4415 | function query(ast, selector, options) {
|
|---|
| 4416 | return match(ast, parse(selector), options);
|
|---|
| 4417 | }
|
|---|
| 4418 | query.parse = parse;
|
|---|
| 4419 | query.match = match;
|
|---|
| 4420 | query.traverse = traverse;
|
|---|
| 4421 | query.matches = matches;
|
|---|
| 4422 | query.query = query;
|
|---|
| 4423 |
|
|---|
| 4424 | return query;
|
|---|
| 4425 |
|
|---|
| 4426 | })));
|
|---|