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