.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / esquery / parser.js
1 /*
2  * Generated by PEG.js 0.10.0.
3  *
4  * http://pegjs.org/
5  */
6 (function(root, factory) {
7   if (typeof define === "function" && define.amd) {
8     define([], factory);
9   } else if (typeof module === "object" && module.exports) {
10     module.exports = factory();
11   }
12 })(this, function() {
13   "use strict";
14
15   function peg$subclass(child, parent) {
16     function ctor() { this.constructor = child; }
17     ctor.prototype = parent.prototype;
18     child.prototype = new ctor();
19   }
20
21   function peg$SyntaxError(message, expected, found, location) {
22     this.message  = message;
23     this.expected = expected;
24     this.found    = found;
25     this.location = location;
26     this.name     = "SyntaxError";
27
28     if (typeof Error.captureStackTrace === "function") {
29       Error.captureStackTrace(this, peg$SyntaxError);
30     }
31   }
32
33   peg$subclass(peg$SyntaxError, Error);
34
35   peg$SyntaxError.buildMessage = function(expected, found) {
36     var DESCRIBE_EXPECTATION_FNS = {
37           literal: function(expectation) {
38             return "\"" + literalEscape(expectation.text) + "\"";
39           },
40
41           "class": function(expectation) {
42             var escapedParts = "",
43                 i;
44
45             for (i = 0; i < expectation.parts.length; i++) {
46               escapedParts += expectation.parts[i] instanceof Array
47                 ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
48                 : classEscape(expectation.parts[i]);
49             }
50
51             return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
52           },
53
54           any: function(expectation) {
55             return "any character";
56           },
57
58           end: function(expectation) {
59             return "end of input";
60           },
61
62           other: function(expectation) {
63             return expectation.description;
64           }
65         };
66
67     function hex(ch) {
68       return ch.charCodeAt(0).toString(16).toUpperCase();
69     }
70
71     function literalEscape(s) {
72       return s
73         .replace(/\\/g, '\\\\')
74         .replace(/"/g,  '\\"')
75         .replace(/\0/g, '\\0')
76         .replace(/\t/g, '\\t')
77         .replace(/\n/g, '\\n')
78         .replace(/\r/g, '\\r')
79         .replace(/[\x00-\x0F]/g,          function(ch) { return '\\x0' + hex(ch); })
80         .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x'  + hex(ch); });
81     }
82
83     function classEscape(s) {
84       return s
85         .replace(/\\/g, '\\\\')
86         .replace(/\]/g, '\\]')
87         .replace(/\^/g, '\\^')
88         .replace(/-/g,  '\\-')
89         .replace(/\0/g, '\\0')
90         .replace(/\t/g, '\\t')
91         .replace(/\n/g, '\\n')
92         .replace(/\r/g, '\\r')
93         .replace(/[\x00-\x0F]/g,          function(ch) { return '\\x0' + hex(ch); })
94         .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x'  + hex(ch); });
95     }
96
97     function describeExpectation(expectation) {
98       return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
99     }
100
101     function describeExpected(expected) {
102       var descriptions = new Array(expected.length),
103           i, j;
104
105       for (i = 0; i < expected.length; i++) {
106         descriptions[i] = describeExpectation(expected[i]);
107       }
108
109       descriptions.sort();
110
111       if (descriptions.length > 0) {
112         for (i = 1, j = 1; i < descriptions.length; i++) {
113           if (descriptions[i - 1] !== descriptions[i]) {
114             descriptions[j] = descriptions[i];
115             j++;
116           }
117         }
118         descriptions.length = j;
119       }
120
121       switch (descriptions.length) {
122         case 1:
123           return descriptions[0];
124
125         case 2:
126           return descriptions[0] + " or " + descriptions[1];
127
128         default:
129           return descriptions.slice(0, -1).join(", ")
130             + ", or "
131             + descriptions[descriptions.length - 1];
132       }
133     }
134
135     function describeFound(found) {
136       return found ? "\"" + literalEscape(found) + "\"" : "end of input";
137     }
138
139     return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
140   };
141
142   function peg$parse(input, options) {
143     options = options !== void 0 ? options : {};
144
145     var peg$FAILED = {},
146
147         peg$startRuleFunctions = { start: peg$parsestart },
148         peg$startRuleFunction  = peg$parsestart,
149
150         peg$c0 = function(ss) {
151             return ss.length === 1 ? ss[0] : { type: 'matches', selectors: ss };
152           },
153         peg$c1 = function() { return void 0; },
154         peg$c2 = " ",
155         peg$c3 = peg$literalExpectation(" ", false),
156         peg$c4 = /^[^ [\],():#!=><~+.]/,
157         peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false),
158         peg$c6 = function(i) { return i.join(''); },
159         peg$c7 = ">",
160         peg$c8 = peg$literalExpectation(">", false),
161         peg$c9 = function() { return 'child'; },
162         peg$c10 = "~",
163         peg$c11 = peg$literalExpectation("~", false),
164         peg$c12 = function() { return 'sibling'; },
165         peg$c13 = "+",
166         peg$c14 = peg$literalExpectation("+", false),
167         peg$c15 = function() { return 'adjacent'; },
168         peg$c16 = function() { return 'descendant'; },
169         peg$c17 = ",",
170         peg$c18 = peg$literalExpectation(",", false),
171         peg$c19 = function(s, ss) {
172           return [s].concat(ss.map(function (s) { return s[3]; }));
173         },
174         peg$c20 = function(a, ops) {
175             return ops.reduce(function (memo, rhs) {
176               return { type: rhs[0], left: memo, right: rhs[1] };
177             }, a);
178           },
179         peg$c21 = "!",
180         peg$c22 = peg$literalExpectation("!", false),
181         peg$c23 = function(subject, as) {
182             const b = as.length === 1 ? as[0] : { type: 'compound', selectors: as };
183             if(subject) b.subject = true;
184             return b;
185           },
186         peg$c24 = "*",
187         peg$c25 = peg$literalExpectation("*", false),
188         peg$c26 = function(a) { return { type: 'wildcard', value: a }; },
189         peg$c27 = "#",
190         peg$c28 = peg$literalExpectation("#", false),
191         peg$c29 = function(i) { return { type: 'identifier', value: i }; },
192         peg$c30 = "[",
193         peg$c31 = peg$literalExpectation("[", false),
194         peg$c32 = "]",
195         peg$c33 = peg$literalExpectation("]", false),
196         peg$c34 = function(v) { return v; },
197         peg$c35 = /^[><!]/,
198         peg$c36 = peg$classExpectation([">", "<", "!"], false, false),
199         peg$c37 = "=",
200         peg$c38 = peg$literalExpectation("=", false),
201         peg$c39 = function(a) { return (a || '') + '='; },
202         peg$c40 = /^[><]/,
203         peg$c41 = peg$classExpectation([">", "<"], false, false),
204         peg$c42 = ".",
205         peg$c43 = peg$literalExpectation(".", false),
206         peg$c44 = function(a, as) {
207             return [].concat.apply([a], as).join('');
208           },
209         peg$c45 = function(name, op, value) {
210               return { type: 'attribute', name: name, operator: op, value: value };
211             },
212         peg$c46 = function(name) { return { type: 'attribute', name: name }; },
213         peg$c47 = "\"",
214         peg$c48 = peg$literalExpectation("\"", false),
215         peg$c49 = /^[^\\"]/,
216         peg$c50 = peg$classExpectation(["\\", "\""], true, false),
217         peg$c51 = "\\",
218         peg$c52 = peg$literalExpectation("\\", false),
219         peg$c53 = peg$anyExpectation(),
220         peg$c54 = function(a, b) { return a + b; },
221         peg$c55 = function(d) {
222                 return { type: 'literal', value: strUnescape(d.join('')) };
223               },
224         peg$c56 = "'",
225         peg$c57 = peg$literalExpectation("'", false),
226         peg$c58 = /^[^\\']/,
227         peg$c59 = peg$classExpectation(["\\", "'"], true, false),
228         peg$c60 = /^[0-9]/,
229         peg$c61 = peg$classExpectation([["0", "9"]], false, false),
230         peg$c62 = function(a, b) {
231                 // Can use `a.flat().join('')` once supported
232                 const leadingDecimals = a ? [].concat.apply([], a).join('') : '';
233                 return { type: 'literal', value: parseFloat(leadingDecimals + b.join('')) };
234               },
235         peg$c63 = function(i) { return { type: 'literal', value: i }; },
236         peg$c64 = "type(",
237         peg$c65 = peg$literalExpectation("type(", false),
238         peg$c66 = /^[^ )]/,
239         peg$c67 = peg$classExpectation([" ", ")"], true, false),
240         peg$c68 = ")",
241         peg$c69 = peg$literalExpectation(")", false),
242         peg$c70 = function(t) { return { type: 'type', value: t.join('') }; },
243         peg$c71 = /^[imsu]/,
244         peg$c72 = peg$classExpectation(["i", "m", "s", "u"], false, false),
245         peg$c73 = "/",
246         peg$c74 = peg$literalExpectation("/", false),
247         peg$c75 = /^[^\/]/,
248         peg$c76 = peg$classExpectation(["/"], true, false),
249         peg$c77 = function(d, flgs) { return {
250               type: 'regexp', value: new RegExp(d.join(''), flgs ? flgs.join('') : '') };
251             },
252         peg$c78 = function(i, is) {
253           return { type: 'field', name: is.reduce(function(memo, p){ return memo + p[0] + p[1]; }, i)};
254         },
255         peg$c79 = ":not(",
256         peg$c80 = peg$literalExpectation(":not(", false),
257         peg$c81 = function(ss) { return { type: 'not', selectors: ss }; },
258         peg$c82 = ":matches(",
259         peg$c83 = peg$literalExpectation(":matches(", false),
260         peg$c84 = function(ss) { return { type: 'matches', selectors: ss }; },
261         peg$c85 = ":has(",
262         peg$c86 = peg$literalExpectation(":has(", false),
263         peg$c87 = function(ss) { return { type: 'has', selectors: ss }; },
264         peg$c88 = ":first-child",
265         peg$c89 = peg$literalExpectation(":first-child", false),
266         peg$c90 = function() { return nth(1); },
267         peg$c91 = ":last-child",
268         peg$c92 = peg$literalExpectation(":last-child", false),
269         peg$c93 = function() { return nthLast(1); },
270         peg$c94 = ":nth-child(",
271         peg$c95 = peg$literalExpectation(":nth-child(", false),
272         peg$c96 = function(n) { return nth(parseInt(n.join(''), 10)); },
273         peg$c97 = ":nth-last-child(",
274         peg$c98 = peg$literalExpectation(":nth-last-child(", false),
275         peg$c99 = function(n) { return nthLast(parseInt(n.join(''), 10)); },
276         peg$c100 = ":",
277         peg$c101 = peg$literalExpectation(":", false),
278         peg$c102 = "statement",
279         peg$c103 = peg$literalExpectation("statement", true),
280         peg$c104 = "expression",
281         peg$c105 = peg$literalExpectation("expression", true),
282         peg$c106 = "declaration",
283         peg$c107 = peg$literalExpectation("declaration", true),
284         peg$c108 = "function",
285         peg$c109 = peg$literalExpectation("function", true),
286         peg$c110 = "pattern",
287         peg$c111 = peg$literalExpectation("pattern", true),
288         peg$c112 = function(c) {
289           return { type: 'class', name: c };
290         },
291
292         peg$currPos          = 0,
293         peg$savedPos         = 0,
294         peg$posDetailsCache  = [{ line: 1, column: 1 }],
295         peg$maxFailPos       = 0,
296         peg$maxFailExpected  = [],
297         peg$silentFails      = 0,
298
299         peg$resultsCache = {},
300
301         peg$result;
302
303     if ("startRule" in options) {
304       if (!(options.startRule in peg$startRuleFunctions)) {
305         throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
306       }
307
308       peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
309     }
310
311     function text() {
312       return input.substring(peg$savedPos, peg$currPos);
313     }
314
315     function location() {
316       return peg$computeLocation(peg$savedPos, peg$currPos);
317     }
318
319     function expected(description, location) {
320       location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
321
322       throw peg$buildStructuredError(
323         [peg$otherExpectation(description)],
324         input.substring(peg$savedPos, peg$currPos),
325         location
326       );
327     }
328
329     function error(message, location) {
330       location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
331
332       throw peg$buildSimpleError(message, location);
333     }
334
335     function peg$literalExpectation(text, ignoreCase) {
336       return { type: "literal", text: text, ignoreCase: ignoreCase };
337     }
338
339     function peg$classExpectation(parts, inverted, ignoreCase) {
340       return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
341     }
342
343     function peg$anyExpectation() {
344       return { type: "any" };
345     }
346
347     function peg$endExpectation() {
348       return { type: "end" };
349     }
350
351     function peg$otherExpectation(description) {
352       return { type: "other", description: description };
353     }
354
355     function peg$computePosDetails(pos) {
356       var details = peg$posDetailsCache[pos], p;
357
358       if (details) {
359         return details;
360       } else {
361         p = pos - 1;
362         while (!peg$posDetailsCache[p]) {
363           p--;
364         }
365
366         details = peg$posDetailsCache[p];
367         details = {
368           line:   details.line,
369           column: details.column
370         };
371
372         while (p < pos) {
373           if (input.charCodeAt(p) === 10) {
374             details.line++;
375             details.column = 1;
376           } else {
377             details.column++;
378           }
379
380           p++;
381         }
382
383         peg$posDetailsCache[pos] = details;
384         return details;
385       }
386     }
387
388     function peg$computeLocation(startPos, endPos) {
389       var startPosDetails = peg$computePosDetails(startPos),
390           endPosDetails   = peg$computePosDetails(endPos);
391
392       return {
393         start: {
394           offset: startPos,
395           line:   startPosDetails.line,
396           column: startPosDetails.column
397         },
398         end: {
399           offset: endPos,
400           line:   endPosDetails.line,
401           column: endPosDetails.column
402         }
403       };
404     }
405
406     function peg$fail(expected) {
407       if (peg$currPos < peg$maxFailPos) { return; }
408
409       if (peg$currPos > peg$maxFailPos) {
410         peg$maxFailPos = peg$currPos;
411         peg$maxFailExpected = [];
412       }
413
414       peg$maxFailExpected.push(expected);
415     }
416
417     function peg$buildSimpleError(message, location) {
418       return new peg$SyntaxError(message, null, null, location);
419     }
420
421     function peg$buildStructuredError(expected, found, location) {
422       return new peg$SyntaxError(
423         peg$SyntaxError.buildMessage(expected, found),
424         expected,
425         found,
426         location
427       );
428     }
429
430     function peg$parsestart() {
431       var s0, s1, s2, s3;
432
433       var key    = peg$currPos * 30 + 0,
434           cached = peg$resultsCache[key];
435
436       if (cached) {
437         peg$currPos = cached.nextPos;
438
439         return cached.result;
440       }
441
442       s0 = peg$currPos;
443       s1 = peg$parse_();
444       if (s1 !== peg$FAILED) {
445         s2 = peg$parseselectors();
446         if (s2 !== peg$FAILED) {
447           s3 = peg$parse_();
448           if (s3 !== peg$FAILED) {
449             peg$savedPos = s0;
450             s1 = peg$c0(s2);
451             s0 = s1;
452           } else {
453             peg$currPos = s0;
454             s0 = peg$FAILED;
455           }
456         } else {
457           peg$currPos = s0;
458           s0 = peg$FAILED;
459         }
460       } else {
461         peg$currPos = s0;
462         s0 = peg$FAILED;
463       }
464       if (s0 === peg$FAILED) {
465         s0 = peg$currPos;
466         s1 = peg$parse_();
467         if (s1 !== peg$FAILED) {
468           peg$savedPos = s0;
469           s1 = peg$c1();
470         }
471         s0 = s1;
472       }
473
474       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
475
476       return s0;
477     }
478
479     function peg$parse_() {
480       var s0, s1;
481
482       var key    = peg$currPos * 30 + 1,
483           cached = peg$resultsCache[key];
484
485       if (cached) {
486         peg$currPos = cached.nextPos;
487
488         return cached.result;
489       }
490
491       s0 = [];
492       if (input.charCodeAt(peg$currPos) === 32) {
493         s1 = peg$c2;
494         peg$currPos++;
495       } else {
496         s1 = peg$FAILED;
497         if (peg$silentFails === 0) { peg$fail(peg$c3); }
498       }
499       while (s1 !== peg$FAILED) {
500         s0.push(s1);
501         if (input.charCodeAt(peg$currPos) === 32) {
502           s1 = peg$c2;
503           peg$currPos++;
504         } else {
505           s1 = peg$FAILED;
506           if (peg$silentFails === 0) { peg$fail(peg$c3); }
507         }
508       }
509
510       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
511
512       return s0;
513     }
514
515     function peg$parseidentifierName() {
516       var s0, s1, s2;
517
518       var key    = peg$currPos * 30 + 2,
519           cached = peg$resultsCache[key];
520
521       if (cached) {
522         peg$currPos = cached.nextPos;
523
524         return cached.result;
525       }
526
527       s0 = peg$currPos;
528       s1 = [];
529       if (peg$c4.test(input.charAt(peg$currPos))) {
530         s2 = input.charAt(peg$currPos);
531         peg$currPos++;
532       } else {
533         s2 = peg$FAILED;
534         if (peg$silentFails === 0) { peg$fail(peg$c5); }
535       }
536       if (s2 !== peg$FAILED) {
537         while (s2 !== peg$FAILED) {
538           s1.push(s2);
539           if (peg$c4.test(input.charAt(peg$currPos))) {
540             s2 = input.charAt(peg$currPos);
541             peg$currPos++;
542           } else {
543             s2 = peg$FAILED;
544             if (peg$silentFails === 0) { peg$fail(peg$c5); }
545           }
546         }
547       } else {
548         s1 = peg$FAILED;
549       }
550       if (s1 !== peg$FAILED) {
551         peg$savedPos = s0;
552         s1 = peg$c6(s1);
553       }
554       s0 = s1;
555
556       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
557
558       return s0;
559     }
560
561     function peg$parsebinaryOp() {
562       var s0, s1, s2, s3;
563
564       var key    = peg$currPos * 30 + 3,
565           cached = peg$resultsCache[key];
566
567       if (cached) {
568         peg$currPos = cached.nextPos;
569
570         return cached.result;
571       }
572
573       s0 = peg$currPos;
574       s1 = peg$parse_();
575       if (s1 !== peg$FAILED) {
576         if (input.charCodeAt(peg$currPos) === 62) {
577           s2 = peg$c7;
578           peg$currPos++;
579         } else {
580           s2 = peg$FAILED;
581           if (peg$silentFails === 0) { peg$fail(peg$c8); }
582         }
583         if (s2 !== peg$FAILED) {
584           s3 = peg$parse_();
585           if (s3 !== peg$FAILED) {
586             peg$savedPos = s0;
587             s1 = peg$c9();
588             s0 = s1;
589           } else {
590             peg$currPos = s0;
591             s0 = peg$FAILED;
592           }
593         } else {
594           peg$currPos = s0;
595           s0 = peg$FAILED;
596         }
597       } else {
598         peg$currPos = s0;
599         s0 = peg$FAILED;
600       }
601       if (s0 === peg$FAILED) {
602         s0 = peg$currPos;
603         s1 = peg$parse_();
604         if (s1 !== peg$FAILED) {
605           if (input.charCodeAt(peg$currPos) === 126) {
606             s2 = peg$c10;
607             peg$currPos++;
608           } else {
609             s2 = peg$FAILED;
610             if (peg$silentFails === 0) { peg$fail(peg$c11); }
611           }
612           if (s2 !== peg$FAILED) {
613             s3 = peg$parse_();
614             if (s3 !== peg$FAILED) {
615               peg$savedPos = s0;
616               s1 = peg$c12();
617               s0 = s1;
618             } else {
619               peg$currPos = s0;
620               s0 = peg$FAILED;
621             }
622           } else {
623             peg$currPos = s0;
624             s0 = peg$FAILED;
625           }
626         } else {
627           peg$currPos = s0;
628           s0 = peg$FAILED;
629         }
630         if (s0 === peg$FAILED) {
631           s0 = peg$currPos;
632           s1 = peg$parse_();
633           if (s1 !== peg$FAILED) {
634             if (input.charCodeAt(peg$currPos) === 43) {
635               s2 = peg$c13;
636               peg$currPos++;
637             } else {
638               s2 = peg$FAILED;
639               if (peg$silentFails === 0) { peg$fail(peg$c14); }
640             }
641             if (s2 !== peg$FAILED) {
642               s3 = peg$parse_();
643               if (s3 !== peg$FAILED) {
644                 peg$savedPos = s0;
645                 s1 = peg$c15();
646                 s0 = s1;
647               } else {
648                 peg$currPos = s0;
649                 s0 = peg$FAILED;
650               }
651             } else {
652               peg$currPos = s0;
653               s0 = peg$FAILED;
654             }
655           } else {
656             peg$currPos = s0;
657             s0 = peg$FAILED;
658           }
659           if (s0 === peg$FAILED) {
660             s0 = peg$currPos;
661             if (input.charCodeAt(peg$currPos) === 32) {
662               s1 = peg$c2;
663               peg$currPos++;
664             } else {
665               s1 = peg$FAILED;
666               if (peg$silentFails === 0) { peg$fail(peg$c3); }
667             }
668             if (s1 !== peg$FAILED) {
669               s2 = peg$parse_();
670               if (s2 !== peg$FAILED) {
671                 peg$savedPos = s0;
672                 s1 = peg$c16();
673                 s0 = s1;
674               } else {
675                 peg$currPos = s0;
676                 s0 = peg$FAILED;
677               }
678             } else {
679               peg$currPos = s0;
680               s0 = peg$FAILED;
681             }
682           }
683         }
684       }
685
686       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
687
688       return s0;
689     }
690
691     function peg$parseselectors() {
692       var s0, s1, s2, s3, s4, s5, s6, s7;
693
694       var key    = peg$currPos * 30 + 4,
695           cached = peg$resultsCache[key];
696
697       if (cached) {
698         peg$currPos = cached.nextPos;
699
700         return cached.result;
701       }
702
703       s0 = peg$currPos;
704       s1 = peg$parseselector();
705       if (s1 !== peg$FAILED) {
706         s2 = [];
707         s3 = peg$currPos;
708         s4 = peg$parse_();
709         if (s4 !== peg$FAILED) {
710           if (input.charCodeAt(peg$currPos) === 44) {
711             s5 = peg$c17;
712             peg$currPos++;
713           } else {
714             s5 = peg$FAILED;
715             if (peg$silentFails === 0) { peg$fail(peg$c18); }
716           }
717           if (s5 !== peg$FAILED) {
718             s6 = peg$parse_();
719             if (s6 !== peg$FAILED) {
720               s7 = peg$parseselector();
721               if (s7 !== peg$FAILED) {
722                 s4 = [s4, s5, s6, s7];
723                 s3 = s4;
724               } else {
725                 peg$currPos = s3;
726                 s3 = peg$FAILED;
727               }
728             } else {
729               peg$currPos = s3;
730               s3 = peg$FAILED;
731             }
732           } else {
733             peg$currPos = s3;
734             s3 = peg$FAILED;
735           }
736         } else {
737           peg$currPos = s3;
738           s3 = peg$FAILED;
739         }
740         while (s3 !== peg$FAILED) {
741           s2.push(s3);
742           s3 = peg$currPos;
743           s4 = peg$parse_();
744           if (s4 !== peg$FAILED) {
745             if (input.charCodeAt(peg$currPos) === 44) {
746               s5 = peg$c17;
747               peg$currPos++;
748             } else {
749               s5 = peg$FAILED;
750               if (peg$silentFails === 0) { peg$fail(peg$c18); }
751             }
752             if (s5 !== peg$FAILED) {
753               s6 = peg$parse_();
754               if (s6 !== peg$FAILED) {
755                 s7 = peg$parseselector();
756                 if (s7 !== peg$FAILED) {
757                   s4 = [s4, s5, s6, s7];
758                   s3 = s4;
759                 } else {
760                   peg$currPos = s3;
761                   s3 = peg$FAILED;
762                 }
763               } else {
764                 peg$currPos = s3;
765                 s3 = peg$FAILED;
766               }
767             } else {
768               peg$currPos = s3;
769               s3 = peg$FAILED;
770             }
771           } else {
772             peg$currPos = s3;
773             s3 = peg$FAILED;
774           }
775         }
776         if (s2 !== peg$FAILED) {
777           peg$savedPos = s0;
778           s1 = peg$c19(s1, s2);
779           s0 = s1;
780         } else {
781           peg$currPos = s0;
782           s0 = peg$FAILED;
783         }
784       } else {
785         peg$currPos = s0;
786         s0 = peg$FAILED;
787       }
788
789       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
790
791       return s0;
792     }
793
794     function peg$parseselector() {
795       var s0, s1, s2, s3, s4, s5;
796
797       var key    = peg$currPos * 30 + 5,
798           cached = peg$resultsCache[key];
799
800       if (cached) {
801         peg$currPos = cached.nextPos;
802
803         return cached.result;
804       }
805
806       s0 = peg$currPos;
807       s1 = peg$parsesequence();
808       if (s1 !== peg$FAILED) {
809         s2 = [];
810         s3 = peg$currPos;
811         s4 = peg$parsebinaryOp();
812         if (s4 !== peg$FAILED) {
813           s5 = peg$parsesequence();
814           if (s5 !== peg$FAILED) {
815             s4 = [s4, s5];
816             s3 = s4;
817           } else {
818             peg$currPos = s3;
819             s3 = peg$FAILED;
820           }
821         } else {
822           peg$currPos = s3;
823           s3 = peg$FAILED;
824         }
825         while (s3 !== peg$FAILED) {
826           s2.push(s3);
827           s3 = peg$currPos;
828           s4 = peg$parsebinaryOp();
829           if (s4 !== peg$FAILED) {
830             s5 = peg$parsesequence();
831             if (s5 !== peg$FAILED) {
832               s4 = [s4, s5];
833               s3 = s4;
834             } else {
835               peg$currPos = s3;
836               s3 = peg$FAILED;
837             }
838           } else {
839             peg$currPos = s3;
840             s3 = peg$FAILED;
841           }
842         }
843         if (s2 !== peg$FAILED) {
844           peg$savedPos = s0;
845           s1 = peg$c20(s1, s2);
846           s0 = s1;
847         } else {
848           peg$currPos = s0;
849           s0 = peg$FAILED;
850         }
851       } else {
852         peg$currPos = s0;
853         s0 = peg$FAILED;
854       }
855
856       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
857
858       return s0;
859     }
860
861     function peg$parsesequence() {
862       var s0, s1, s2, s3;
863
864       var key    = peg$currPos * 30 + 6,
865           cached = peg$resultsCache[key];
866
867       if (cached) {
868         peg$currPos = cached.nextPos;
869
870         return cached.result;
871       }
872
873       s0 = peg$currPos;
874       if (input.charCodeAt(peg$currPos) === 33) {
875         s1 = peg$c21;
876         peg$currPos++;
877       } else {
878         s1 = peg$FAILED;
879         if (peg$silentFails === 0) { peg$fail(peg$c22); }
880       }
881       if (s1 === peg$FAILED) {
882         s1 = null;
883       }
884       if (s1 !== peg$FAILED) {
885         s2 = [];
886         s3 = peg$parseatom();
887         if (s3 !== peg$FAILED) {
888           while (s3 !== peg$FAILED) {
889             s2.push(s3);
890             s3 = peg$parseatom();
891           }
892         } else {
893           s2 = peg$FAILED;
894         }
895         if (s2 !== peg$FAILED) {
896           peg$savedPos = s0;
897           s1 = peg$c23(s1, s2);
898           s0 = s1;
899         } else {
900           peg$currPos = s0;
901           s0 = peg$FAILED;
902         }
903       } else {
904         peg$currPos = s0;
905         s0 = peg$FAILED;
906       }
907
908       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
909
910       return s0;
911     }
912
913     function peg$parseatom() {
914       var s0;
915
916       var key    = peg$currPos * 30 + 7,
917           cached = peg$resultsCache[key];
918
919       if (cached) {
920         peg$currPos = cached.nextPos;
921
922         return cached.result;
923       }
924
925       s0 = peg$parsewildcard();
926       if (s0 === peg$FAILED) {
927         s0 = peg$parseidentifier();
928         if (s0 === peg$FAILED) {
929           s0 = peg$parseattr();
930           if (s0 === peg$FAILED) {
931             s0 = peg$parsefield();
932             if (s0 === peg$FAILED) {
933               s0 = peg$parsenegation();
934               if (s0 === peg$FAILED) {
935                 s0 = peg$parsematches();
936                 if (s0 === peg$FAILED) {
937                   s0 = peg$parsehas();
938                   if (s0 === peg$FAILED) {
939                     s0 = peg$parsefirstChild();
940                     if (s0 === peg$FAILED) {
941                       s0 = peg$parselastChild();
942                       if (s0 === peg$FAILED) {
943                         s0 = peg$parsenthChild();
944                         if (s0 === peg$FAILED) {
945                           s0 = peg$parsenthLastChild();
946                           if (s0 === peg$FAILED) {
947                             s0 = peg$parseclass();
948                           }
949                         }
950                       }
951                     }
952                   }
953                 }
954               }
955             }
956           }
957         }
958       }
959
960       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
961
962       return s0;
963     }
964
965     function peg$parsewildcard() {
966       var s0, s1;
967
968       var key    = peg$currPos * 30 + 8,
969           cached = peg$resultsCache[key];
970
971       if (cached) {
972         peg$currPos = cached.nextPos;
973
974         return cached.result;
975       }
976
977       s0 = peg$currPos;
978       if (input.charCodeAt(peg$currPos) === 42) {
979         s1 = peg$c24;
980         peg$currPos++;
981       } else {
982         s1 = peg$FAILED;
983         if (peg$silentFails === 0) { peg$fail(peg$c25); }
984       }
985       if (s1 !== peg$FAILED) {
986         peg$savedPos = s0;
987         s1 = peg$c26(s1);
988       }
989       s0 = s1;
990
991       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
992
993       return s0;
994     }
995
996     function peg$parseidentifier() {
997       var s0, s1, s2;
998
999       var key    = peg$currPos * 30 + 9,
1000           cached = peg$resultsCache[key];
1001
1002       if (cached) {
1003         peg$currPos = cached.nextPos;
1004
1005         return cached.result;
1006       }
1007
1008       s0 = peg$currPos;
1009       if (input.charCodeAt(peg$currPos) === 35) {
1010         s1 = peg$c27;
1011         peg$currPos++;
1012       } else {
1013         s1 = peg$FAILED;
1014         if (peg$silentFails === 0) { peg$fail(peg$c28); }
1015       }
1016       if (s1 === peg$FAILED) {
1017         s1 = null;
1018       }
1019       if (s1 !== peg$FAILED) {
1020         s2 = peg$parseidentifierName();
1021         if (s2 !== peg$FAILED) {
1022           peg$savedPos = s0;
1023           s1 = peg$c29(s2);
1024           s0 = s1;
1025         } else {
1026           peg$currPos = s0;
1027           s0 = peg$FAILED;
1028         }
1029       } else {
1030         peg$currPos = s0;
1031         s0 = peg$FAILED;
1032       }
1033
1034       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1035
1036       return s0;
1037     }
1038
1039     function peg$parseattr() {
1040       var s0, s1, s2, s3, s4, s5;
1041
1042       var key    = peg$currPos * 30 + 10,
1043           cached = peg$resultsCache[key];
1044
1045       if (cached) {
1046         peg$currPos = cached.nextPos;
1047
1048         return cached.result;
1049       }
1050
1051       s0 = peg$currPos;
1052       if (input.charCodeAt(peg$currPos) === 91) {
1053         s1 = peg$c30;
1054         peg$currPos++;
1055       } else {
1056         s1 = peg$FAILED;
1057         if (peg$silentFails === 0) { peg$fail(peg$c31); }
1058       }
1059       if (s1 !== peg$FAILED) {
1060         s2 = peg$parse_();
1061         if (s2 !== peg$FAILED) {
1062           s3 = peg$parseattrValue();
1063           if (s3 !== peg$FAILED) {
1064             s4 = peg$parse_();
1065             if (s4 !== peg$FAILED) {
1066               if (input.charCodeAt(peg$currPos) === 93) {
1067                 s5 = peg$c32;
1068                 peg$currPos++;
1069               } else {
1070                 s5 = peg$FAILED;
1071                 if (peg$silentFails === 0) { peg$fail(peg$c33); }
1072               }
1073               if (s5 !== peg$FAILED) {
1074                 peg$savedPos = s0;
1075                 s1 = peg$c34(s3);
1076                 s0 = s1;
1077               } else {
1078                 peg$currPos = s0;
1079                 s0 = peg$FAILED;
1080               }
1081             } else {
1082               peg$currPos = s0;
1083               s0 = peg$FAILED;
1084             }
1085           } else {
1086             peg$currPos = s0;
1087             s0 = peg$FAILED;
1088           }
1089         } else {
1090           peg$currPos = s0;
1091           s0 = peg$FAILED;
1092         }
1093       } else {
1094         peg$currPos = s0;
1095         s0 = peg$FAILED;
1096       }
1097
1098       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1099
1100       return s0;
1101     }
1102
1103     function peg$parseattrOps() {
1104       var s0, s1, s2;
1105
1106       var key    = peg$currPos * 30 + 11,
1107           cached = peg$resultsCache[key];
1108
1109       if (cached) {
1110         peg$currPos = cached.nextPos;
1111
1112         return cached.result;
1113       }
1114
1115       s0 = peg$currPos;
1116       if (peg$c35.test(input.charAt(peg$currPos))) {
1117         s1 = input.charAt(peg$currPos);
1118         peg$currPos++;
1119       } else {
1120         s1 = peg$FAILED;
1121         if (peg$silentFails === 0) { peg$fail(peg$c36); }
1122       }
1123       if (s1 === peg$FAILED) {
1124         s1 = null;
1125       }
1126       if (s1 !== peg$FAILED) {
1127         if (input.charCodeAt(peg$currPos) === 61) {
1128           s2 = peg$c37;
1129           peg$currPos++;
1130         } else {
1131           s2 = peg$FAILED;
1132           if (peg$silentFails === 0) { peg$fail(peg$c38); }
1133         }
1134         if (s2 !== peg$FAILED) {
1135           peg$savedPos = s0;
1136           s1 = peg$c39(s1);
1137           s0 = s1;
1138         } else {
1139           peg$currPos = s0;
1140           s0 = peg$FAILED;
1141         }
1142       } else {
1143         peg$currPos = s0;
1144         s0 = peg$FAILED;
1145       }
1146       if (s0 === peg$FAILED) {
1147         if (peg$c40.test(input.charAt(peg$currPos))) {
1148           s0 = input.charAt(peg$currPos);
1149           peg$currPos++;
1150         } else {
1151           s0 = peg$FAILED;
1152           if (peg$silentFails === 0) { peg$fail(peg$c41); }
1153         }
1154       }
1155
1156       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1157
1158       return s0;
1159     }
1160
1161     function peg$parseattrEqOps() {
1162       var s0, s1, s2;
1163
1164       var key    = peg$currPos * 30 + 12,
1165           cached = peg$resultsCache[key];
1166
1167       if (cached) {
1168         peg$currPos = cached.nextPos;
1169
1170         return cached.result;
1171       }
1172
1173       s0 = peg$currPos;
1174       if (input.charCodeAt(peg$currPos) === 33) {
1175         s1 = peg$c21;
1176         peg$currPos++;
1177       } else {
1178         s1 = peg$FAILED;
1179         if (peg$silentFails === 0) { peg$fail(peg$c22); }
1180       }
1181       if (s1 === peg$FAILED) {
1182         s1 = null;
1183       }
1184       if (s1 !== peg$FAILED) {
1185         if (input.charCodeAt(peg$currPos) === 61) {
1186           s2 = peg$c37;
1187           peg$currPos++;
1188         } else {
1189           s2 = peg$FAILED;
1190           if (peg$silentFails === 0) { peg$fail(peg$c38); }
1191         }
1192         if (s2 !== peg$FAILED) {
1193           peg$savedPos = s0;
1194           s1 = peg$c39(s1);
1195           s0 = s1;
1196         } else {
1197           peg$currPos = s0;
1198           s0 = peg$FAILED;
1199         }
1200       } else {
1201         peg$currPos = s0;
1202         s0 = peg$FAILED;
1203       }
1204
1205       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1206
1207       return s0;
1208     }
1209
1210     function peg$parseattrName() {
1211       var s0, s1, s2, s3, s4, s5;
1212
1213       var key    = peg$currPos * 30 + 13,
1214           cached = peg$resultsCache[key];
1215
1216       if (cached) {
1217         peg$currPos = cached.nextPos;
1218
1219         return cached.result;
1220       }
1221
1222       s0 = peg$currPos;
1223       s1 = peg$parseidentifierName();
1224       if (s1 !== peg$FAILED) {
1225         s2 = [];
1226         s3 = peg$currPos;
1227         if (input.charCodeAt(peg$currPos) === 46) {
1228           s4 = peg$c42;
1229           peg$currPos++;
1230         } else {
1231           s4 = peg$FAILED;
1232           if (peg$silentFails === 0) { peg$fail(peg$c43); }
1233         }
1234         if (s4 !== peg$FAILED) {
1235           s5 = peg$parseidentifierName();
1236           if (s5 !== peg$FAILED) {
1237             s4 = [s4, s5];
1238             s3 = s4;
1239           } else {
1240             peg$currPos = s3;
1241             s3 = peg$FAILED;
1242           }
1243         } else {
1244           peg$currPos = s3;
1245           s3 = peg$FAILED;
1246         }
1247         while (s3 !== peg$FAILED) {
1248           s2.push(s3);
1249           s3 = peg$currPos;
1250           if (input.charCodeAt(peg$currPos) === 46) {
1251             s4 = peg$c42;
1252             peg$currPos++;
1253           } else {
1254             s4 = peg$FAILED;
1255             if (peg$silentFails === 0) { peg$fail(peg$c43); }
1256           }
1257           if (s4 !== peg$FAILED) {
1258             s5 = peg$parseidentifierName();
1259             if (s5 !== peg$FAILED) {
1260               s4 = [s4, s5];
1261               s3 = s4;
1262             } else {
1263               peg$currPos = s3;
1264               s3 = peg$FAILED;
1265             }
1266           } else {
1267             peg$currPos = s3;
1268             s3 = peg$FAILED;
1269           }
1270         }
1271         if (s2 !== peg$FAILED) {
1272           peg$savedPos = s0;
1273           s1 = peg$c44(s1, s2);
1274           s0 = s1;
1275         } else {
1276           peg$currPos = s0;
1277           s0 = peg$FAILED;
1278         }
1279       } else {
1280         peg$currPos = s0;
1281         s0 = peg$FAILED;
1282       }
1283
1284       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1285
1286       return s0;
1287     }
1288
1289     function peg$parseattrValue() {
1290       var s0, s1, s2, s3, s4, s5;
1291
1292       var key    = peg$currPos * 30 + 14,
1293           cached = peg$resultsCache[key];
1294
1295       if (cached) {
1296         peg$currPos = cached.nextPos;
1297
1298         return cached.result;
1299       }
1300
1301       s0 = peg$currPos;
1302       s1 = peg$parseattrName();
1303       if (s1 !== peg$FAILED) {
1304         s2 = peg$parse_();
1305         if (s2 !== peg$FAILED) {
1306           s3 = peg$parseattrEqOps();
1307           if (s3 !== peg$FAILED) {
1308             s4 = peg$parse_();
1309             if (s4 !== peg$FAILED) {
1310               s5 = peg$parsetype();
1311               if (s5 === peg$FAILED) {
1312                 s5 = peg$parseregex();
1313               }
1314               if (s5 !== peg$FAILED) {
1315                 peg$savedPos = s0;
1316                 s1 = peg$c45(s1, s3, s5);
1317                 s0 = s1;
1318               } else {
1319                 peg$currPos = s0;
1320                 s0 = peg$FAILED;
1321               }
1322             } else {
1323               peg$currPos = s0;
1324               s0 = peg$FAILED;
1325             }
1326           } else {
1327             peg$currPos = s0;
1328             s0 = peg$FAILED;
1329           }
1330         } else {
1331           peg$currPos = s0;
1332           s0 = peg$FAILED;
1333         }
1334       } else {
1335         peg$currPos = s0;
1336         s0 = peg$FAILED;
1337       }
1338       if (s0 === peg$FAILED) {
1339         s0 = peg$currPos;
1340         s1 = peg$parseattrName();
1341         if (s1 !== peg$FAILED) {
1342           s2 = peg$parse_();
1343           if (s2 !== peg$FAILED) {
1344             s3 = peg$parseattrOps();
1345             if (s3 !== peg$FAILED) {
1346               s4 = peg$parse_();
1347               if (s4 !== peg$FAILED) {
1348                 s5 = peg$parsestring();
1349                 if (s5 === peg$FAILED) {
1350                   s5 = peg$parsenumber();
1351                   if (s5 === peg$FAILED) {
1352                     s5 = peg$parsepath();
1353                   }
1354                 }
1355                 if (s5 !== peg$FAILED) {
1356                   peg$savedPos = s0;
1357                   s1 = peg$c45(s1, s3, s5);
1358                   s0 = s1;
1359                 } else {
1360                   peg$currPos = s0;
1361                   s0 = peg$FAILED;
1362                 }
1363               } else {
1364                 peg$currPos = s0;
1365                 s0 = peg$FAILED;
1366               }
1367             } else {
1368               peg$currPos = s0;
1369               s0 = peg$FAILED;
1370             }
1371           } else {
1372             peg$currPos = s0;
1373             s0 = peg$FAILED;
1374           }
1375         } else {
1376           peg$currPos = s0;
1377           s0 = peg$FAILED;
1378         }
1379         if (s0 === peg$FAILED) {
1380           s0 = peg$currPos;
1381           s1 = peg$parseattrName();
1382           if (s1 !== peg$FAILED) {
1383             peg$savedPos = s0;
1384             s1 = peg$c46(s1);
1385           }
1386           s0 = s1;
1387         }
1388       }
1389
1390       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1391
1392       return s0;
1393     }
1394
1395     function peg$parsestring() {
1396       var s0, s1, s2, s3, s4, s5;
1397
1398       var key    = peg$currPos * 30 + 15,
1399           cached = peg$resultsCache[key];
1400
1401       if (cached) {
1402         peg$currPos = cached.nextPos;
1403
1404         return cached.result;
1405       }
1406
1407       s0 = peg$currPos;
1408       if (input.charCodeAt(peg$currPos) === 34) {
1409         s1 = peg$c47;
1410         peg$currPos++;
1411       } else {
1412         s1 = peg$FAILED;
1413         if (peg$silentFails === 0) { peg$fail(peg$c48); }
1414       }
1415       if (s1 !== peg$FAILED) {
1416         s2 = [];
1417         if (peg$c49.test(input.charAt(peg$currPos))) {
1418           s3 = input.charAt(peg$currPos);
1419           peg$currPos++;
1420         } else {
1421           s3 = peg$FAILED;
1422           if (peg$silentFails === 0) { peg$fail(peg$c50); }
1423         }
1424         if (s3 === peg$FAILED) {
1425           s3 = peg$currPos;
1426           if (input.charCodeAt(peg$currPos) === 92) {
1427             s4 = peg$c51;
1428             peg$currPos++;
1429           } else {
1430             s4 = peg$FAILED;
1431             if (peg$silentFails === 0) { peg$fail(peg$c52); }
1432           }
1433           if (s4 !== peg$FAILED) {
1434             if (input.length > peg$currPos) {
1435               s5 = input.charAt(peg$currPos);
1436               peg$currPos++;
1437             } else {
1438               s5 = peg$FAILED;
1439               if (peg$silentFails === 0) { peg$fail(peg$c53); }
1440             }
1441             if (s5 !== peg$FAILED) {
1442               peg$savedPos = s3;
1443               s4 = peg$c54(s4, s5);
1444               s3 = s4;
1445             } else {
1446               peg$currPos = s3;
1447               s3 = peg$FAILED;
1448             }
1449           } else {
1450             peg$currPos = s3;
1451             s3 = peg$FAILED;
1452           }
1453         }
1454         while (s3 !== peg$FAILED) {
1455           s2.push(s3);
1456           if (peg$c49.test(input.charAt(peg$currPos))) {
1457             s3 = input.charAt(peg$currPos);
1458             peg$currPos++;
1459           } else {
1460             s3 = peg$FAILED;
1461             if (peg$silentFails === 0) { peg$fail(peg$c50); }
1462           }
1463           if (s3 === peg$FAILED) {
1464             s3 = peg$currPos;
1465             if (input.charCodeAt(peg$currPos) === 92) {
1466               s4 = peg$c51;
1467               peg$currPos++;
1468             } else {
1469               s4 = peg$FAILED;
1470               if (peg$silentFails === 0) { peg$fail(peg$c52); }
1471             }
1472             if (s4 !== peg$FAILED) {
1473               if (input.length > peg$currPos) {
1474                 s5 = input.charAt(peg$currPos);
1475                 peg$currPos++;
1476               } else {
1477                 s5 = peg$FAILED;
1478                 if (peg$silentFails === 0) { peg$fail(peg$c53); }
1479               }
1480               if (s5 !== peg$FAILED) {
1481                 peg$savedPos = s3;
1482                 s4 = peg$c54(s4, s5);
1483                 s3 = s4;
1484               } else {
1485                 peg$currPos = s3;
1486                 s3 = peg$FAILED;
1487               }
1488             } else {
1489               peg$currPos = s3;
1490               s3 = peg$FAILED;
1491             }
1492           }
1493         }
1494         if (s2 !== peg$FAILED) {
1495           if (input.charCodeAt(peg$currPos) === 34) {
1496             s3 = peg$c47;
1497             peg$currPos++;
1498           } else {
1499             s3 = peg$FAILED;
1500             if (peg$silentFails === 0) { peg$fail(peg$c48); }
1501           }
1502           if (s3 !== peg$FAILED) {
1503             peg$savedPos = s0;
1504             s1 = peg$c55(s2);
1505             s0 = s1;
1506           } else {
1507             peg$currPos = s0;
1508             s0 = peg$FAILED;
1509           }
1510         } else {
1511           peg$currPos = s0;
1512           s0 = peg$FAILED;
1513         }
1514       } else {
1515         peg$currPos = s0;
1516         s0 = peg$FAILED;
1517       }
1518       if (s0 === peg$FAILED) {
1519         s0 = peg$currPos;
1520         if (input.charCodeAt(peg$currPos) === 39) {
1521           s1 = peg$c56;
1522           peg$currPos++;
1523         } else {
1524           s1 = peg$FAILED;
1525           if (peg$silentFails === 0) { peg$fail(peg$c57); }
1526         }
1527         if (s1 !== peg$FAILED) {
1528           s2 = [];
1529           if (peg$c58.test(input.charAt(peg$currPos))) {
1530             s3 = input.charAt(peg$currPos);
1531             peg$currPos++;
1532           } else {
1533             s3 = peg$FAILED;
1534             if (peg$silentFails === 0) { peg$fail(peg$c59); }
1535           }
1536           if (s3 === peg$FAILED) {
1537             s3 = peg$currPos;
1538             if (input.charCodeAt(peg$currPos) === 92) {
1539               s4 = peg$c51;
1540               peg$currPos++;
1541             } else {
1542               s4 = peg$FAILED;
1543               if (peg$silentFails === 0) { peg$fail(peg$c52); }
1544             }
1545             if (s4 !== peg$FAILED) {
1546               if (input.length > peg$currPos) {
1547                 s5 = input.charAt(peg$currPos);
1548                 peg$currPos++;
1549               } else {
1550                 s5 = peg$FAILED;
1551                 if (peg$silentFails === 0) { peg$fail(peg$c53); }
1552               }
1553               if (s5 !== peg$FAILED) {
1554                 peg$savedPos = s3;
1555                 s4 = peg$c54(s4, s5);
1556                 s3 = s4;
1557               } else {
1558                 peg$currPos = s3;
1559                 s3 = peg$FAILED;
1560               }
1561             } else {
1562               peg$currPos = s3;
1563               s3 = peg$FAILED;
1564             }
1565           }
1566           while (s3 !== peg$FAILED) {
1567             s2.push(s3);
1568             if (peg$c58.test(input.charAt(peg$currPos))) {
1569               s3 = input.charAt(peg$currPos);
1570               peg$currPos++;
1571             } else {
1572               s3 = peg$FAILED;
1573               if (peg$silentFails === 0) { peg$fail(peg$c59); }
1574             }
1575             if (s3 === peg$FAILED) {
1576               s3 = peg$currPos;
1577               if (input.charCodeAt(peg$currPos) === 92) {
1578                 s4 = peg$c51;
1579                 peg$currPos++;
1580               } else {
1581                 s4 = peg$FAILED;
1582                 if (peg$silentFails === 0) { peg$fail(peg$c52); }
1583               }
1584               if (s4 !== peg$FAILED) {
1585                 if (input.length > peg$currPos) {
1586                   s5 = input.charAt(peg$currPos);
1587                   peg$currPos++;
1588                 } else {
1589                   s5 = peg$FAILED;
1590                   if (peg$silentFails === 0) { peg$fail(peg$c53); }
1591                 }
1592                 if (s5 !== peg$FAILED) {
1593                   peg$savedPos = s3;
1594                   s4 = peg$c54(s4, s5);
1595                   s3 = s4;
1596                 } else {
1597                   peg$currPos = s3;
1598                   s3 = peg$FAILED;
1599                 }
1600               } else {
1601                 peg$currPos = s3;
1602                 s3 = peg$FAILED;
1603               }
1604             }
1605           }
1606           if (s2 !== peg$FAILED) {
1607             if (input.charCodeAt(peg$currPos) === 39) {
1608               s3 = peg$c56;
1609               peg$currPos++;
1610             } else {
1611               s3 = peg$FAILED;
1612               if (peg$silentFails === 0) { peg$fail(peg$c57); }
1613             }
1614             if (s3 !== peg$FAILED) {
1615               peg$savedPos = s0;
1616               s1 = peg$c55(s2);
1617               s0 = s1;
1618             } else {
1619               peg$currPos = s0;
1620               s0 = peg$FAILED;
1621             }
1622           } else {
1623             peg$currPos = s0;
1624             s0 = peg$FAILED;
1625           }
1626         } else {
1627           peg$currPos = s0;
1628           s0 = peg$FAILED;
1629         }
1630       }
1631
1632       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1633
1634       return s0;
1635     }
1636
1637     function peg$parsenumber() {
1638       var s0, s1, s2, s3;
1639
1640       var key    = peg$currPos * 30 + 16,
1641           cached = peg$resultsCache[key];
1642
1643       if (cached) {
1644         peg$currPos = cached.nextPos;
1645
1646         return cached.result;
1647       }
1648
1649       s0 = peg$currPos;
1650       s1 = peg$currPos;
1651       s2 = [];
1652       if (peg$c60.test(input.charAt(peg$currPos))) {
1653         s3 = input.charAt(peg$currPos);
1654         peg$currPos++;
1655       } else {
1656         s3 = peg$FAILED;
1657         if (peg$silentFails === 0) { peg$fail(peg$c61); }
1658       }
1659       while (s3 !== peg$FAILED) {
1660         s2.push(s3);
1661         if (peg$c60.test(input.charAt(peg$currPos))) {
1662           s3 = input.charAt(peg$currPos);
1663           peg$currPos++;
1664         } else {
1665           s3 = peg$FAILED;
1666           if (peg$silentFails === 0) { peg$fail(peg$c61); }
1667         }
1668       }
1669       if (s2 !== peg$FAILED) {
1670         if (input.charCodeAt(peg$currPos) === 46) {
1671           s3 = peg$c42;
1672           peg$currPos++;
1673         } else {
1674           s3 = peg$FAILED;
1675           if (peg$silentFails === 0) { peg$fail(peg$c43); }
1676         }
1677         if (s3 !== peg$FAILED) {
1678           s2 = [s2, s3];
1679           s1 = s2;
1680         } else {
1681           peg$currPos = s1;
1682           s1 = peg$FAILED;
1683         }
1684       } else {
1685         peg$currPos = s1;
1686         s1 = peg$FAILED;
1687       }
1688       if (s1 === peg$FAILED) {
1689         s1 = null;
1690       }
1691       if (s1 !== peg$FAILED) {
1692         s2 = [];
1693         if (peg$c60.test(input.charAt(peg$currPos))) {
1694           s3 = input.charAt(peg$currPos);
1695           peg$currPos++;
1696         } else {
1697           s3 = peg$FAILED;
1698           if (peg$silentFails === 0) { peg$fail(peg$c61); }
1699         }
1700         if (s3 !== peg$FAILED) {
1701           while (s3 !== peg$FAILED) {
1702             s2.push(s3);
1703             if (peg$c60.test(input.charAt(peg$currPos))) {
1704               s3 = input.charAt(peg$currPos);
1705               peg$currPos++;
1706             } else {
1707               s3 = peg$FAILED;
1708               if (peg$silentFails === 0) { peg$fail(peg$c61); }
1709             }
1710           }
1711         } else {
1712           s2 = peg$FAILED;
1713         }
1714         if (s2 !== peg$FAILED) {
1715           peg$savedPos = s0;
1716           s1 = peg$c62(s1, s2);
1717           s0 = s1;
1718         } else {
1719           peg$currPos = s0;
1720           s0 = peg$FAILED;
1721         }
1722       } else {
1723         peg$currPos = s0;
1724         s0 = peg$FAILED;
1725       }
1726
1727       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1728
1729       return s0;
1730     }
1731
1732     function peg$parsepath() {
1733       var s0, s1;
1734
1735       var key    = peg$currPos * 30 + 17,
1736           cached = peg$resultsCache[key];
1737
1738       if (cached) {
1739         peg$currPos = cached.nextPos;
1740
1741         return cached.result;
1742       }
1743
1744       s0 = peg$currPos;
1745       s1 = peg$parseidentifierName();
1746       if (s1 !== peg$FAILED) {
1747         peg$savedPos = s0;
1748         s1 = peg$c63(s1);
1749       }
1750       s0 = s1;
1751
1752       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1753
1754       return s0;
1755     }
1756
1757     function peg$parsetype() {
1758       var s0, s1, s2, s3, s4, s5;
1759
1760       var key    = peg$currPos * 30 + 18,
1761           cached = peg$resultsCache[key];
1762
1763       if (cached) {
1764         peg$currPos = cached.nextPos;
1765
1766         return cached.result;
1767       }
1768
1769       s0 = peg$currPos;
1770       if (input.substr(peg$currPos, 5) === peg$c64) {
1771         s1 = peg$c64;
1772         peg$currPos += 5;
1773       } else {
1774         s1 = peg$FAILED;
1775         if (peg$silentFails === 0) { peg$fail(peg$c65); }
1776       }
1777       if (s1 !== peg$FAILED) {
1778         s2 = peg$parse_();
1779         if (s2 !== peg$FAILED) {
1780           s3 = [];
1781           if (peg$c66.test(input.charAt(peg$currPos))) {
1782             s4 = input.charAt(peg$currPos);
1783             peg$currPos++;
1784           } else {
1785             s4 = peg$FAILED;
1786             if (peg$silentFails === 0) { peg$fail(peg$c67); }
1787           }
1788           if (s4 !== peg$FAILED) {
1789             while (s4 !== peg$FAILED) {
1790               s3.push(s4);
1791               if (peg$c66.test(input.charAt(peg$currPos))) {
1792                 s4 = input.charAt(peg$currPos);
1793                 peg$currPos++;
1794               } else {
1795                 s4 = peg$FAILED;
1796                 if (peg$silentFails === 0) { peg$fail(peg$c67); }
1797               }
1798             }
1799           } else {
1800             s3 = peg$FAILED;
1801           }
1802           if (s3 !== peg$FAILED) {
1803             s4 = peg$parse_();
1804             if (s4 !== peg$FAILED) {
1805               if (input.charCodeAt(peg$currPos) === 41) {
1806                 s5 = peg$c68;
1807                 peg$currPos++;
1808               } else {
1809                 s5 = peg$FAILED;
1810                 if (peg$silentFails === 0) { peg$fail(peg$c69); }
1811               }
1812               if (s5 !== peg$FAILED) {
1813                 peg$savedPos = s0;
1814                 s1 = peg$c70(s3);
1815                 s0 = s1;
1816               } else {
1817                 peg$currPos = s0;
1818                 s0 = peg$FAILED;
1819               }
1820             } else {
1821               peg$currPos = s0;
1822               s0 = peg$FAILED;
1823             }
1824           } else {
1825             peg$currPos = s0;
1826             s0 = peg$FAILED;
1827           }
1828         } else {
1829           peg$currPos = s0;
1830           s0 = peg$FAILED;
1831         }
1832       } else {
1833         peg$currPos = s0;
1834         s0 = peg$FAILED;
1835       }
1836
1837       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1838
1839       return s0;
1840     }
1841
1842     function peg$parseflags() {
1843       var s0, s1;
1844
1845       var key    = peg$currPos * 30 + 19,
1846           cached = peg$resultsCache[key];
1847
1848       if (cached) {
1849         peg$currPos = cached.nextPos;
1850
1851         return cached.result;
1852       }
1853
1854       s0 = [];
1855       if (peg$c71.test(input.charAt(peg$currPos))) {
1856         s1 = input.charAt(peg$currPos);
1857         peg$currPos++;
1858       } else {
1859         s1 = peg$FAILED;
1860         if (peg$silentFails === 0) { peg$fail(peg$c72); }
1861       }
1862       if (s1 !== peg$FAILED) {
1863         while (s1 !== peg$FAILED) {
1864           s0.push(s1);
1865           if (peg$c71.test(input.charAt(peg$currPos))) {
1866             s1 = input.charAt(peg$currPos);
1867             peg$currPos++;
1868           } else {
1869             s1 = peg$FAILED;
1870             if (peg$silentFails === 0) { peg$fail(peg$c72); }
1871           }
1872         }
1873       } else {
1874         s0 = peg$FAILED;
1875       }
1876
1877       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1878
1879       return s0;
1880     }
1881
1882     function peg$parseregex() {
1883       var s0, s1, s2, s3, s4;
1884
1885       var key    = peg$currPos * 30 + 20,
1886           cached = peg$resultsCache[key];
1887
1888       if (cached) {
1889         peg$currPos = cached.nextPos;
1890
1891         return cached.result;
1892       }
1893
1894       s0 = peg$currPos;
1895       if (input.charCodeAt(peg$currPos) === 47) {
1896         s1 = peg$c73;
1897         peg$currPos++;
1898       } else {
1899         s1 = peg$FAILED;
1900         if (peg$silentFails === 0) { peg$fail(peg$c74); }
1901       }
1902       if (s1 !== peg$FAILED) {
1903         s2 = [];
1904         if (peg$c75.test(input.charAt(peg$currPos))) {
1905           s3 = input.charAt(peg$currPos);
1906           peg$currPos++;
1907         } else {
1908           s3 = peg$FAILED;
1909           if (peg$silentFails === 0) { peg$fail(peg$c76); }
1910         }
1911         if (s3 !== peg$FAILED) {
1912           while (s3 !== peg$FAILED) {
1913             s2.push(s3);
1914             if (peg$c75.test(input.charAt(peg$currPos))) {
1915               s3 = input.charAt(peg$currPos);
1916               peg$currPos++;
1917             } else {
1918               s3 = peg$FAILED;
1919               if (peg$silentFails === 0) { peg$fail(peg$c76); }
1920             }
1921           }
1922         } else {
1923           s2 = peg$FAILED;
1924         }
1925         if (s2 !== peg$FAILED) {
1926           if (input.charCodeAt(peg$currPos) === 47) {
1927             s3 = peg$c73;
1928             peg$currPos++;
1929           } else {
1930             s3 = peg$FAILED;
1931             if (peg$silentFails === 0) { peg$fail(peg$c74); }
1932           }
1933           if (s3 !== peg$FAILED) {
1934             s4 = peg$parseflags();
1935             if (s4 === peg$FAILED) {
1936               s4 = null;
1937             }
1938             if (s4 !== peg$FAILED) {
1939               peg$savedPos = s0;
1940               s1 = peg$c77(s2, s4);
1941               s0 = s1;
1942             } else {
1943               peg$currPos = s0;
1944               s0 = peg$FAILED;
1945             }
1946           } else {
1947             peg$currPos = s0;
1948             s0 = peg$FAILED;
1949           }
1950         } else {
1951           peg$currPos = s0;
1952           s0 = peg$FAILED;
1953         }
1954       } else {
1955         peg$currPos = s0;
1956         s0 = peg$FAILED;
1957       }
1958
1959       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1960
1961       return s0;
1962     }
1963
1964     function peg$parsefield() {
1965       var s0, s1, s2, s3, s4, s5, s6;
1966
1967       var key    = peg$currPos * 30 + 21,
1968           cached = peg$resultsCache[key];
1969
1970       if (cached) {
1971         peg$currPos = cached.nextPos;
1972
1973         return cached.result;
1974       }
1975
1976       s0 = peg$currPos;
1977       if (input.charCodeAt(peg$currPos) === 46) {
1978         s1 = peg$c42;
1979         peg$currPos++;
1980       } else {
1981         s1 = peg$FAILED;
1982         if (peg$silentFails === 0) { peg$fail(peg$c43); }
1983       }
1984       if (s1 !== peg$FAILED) {
1985         s2 = peg$parseidentifierName();
1986         if (s2 !== peg$FAILED) {
1987           s3 = [];
1988           s4 = peg$currPos;
1989           if (input.charCodeAt(peg$currPos) === 46) {
1990             s5 = peg$c42;
1991             peg$currPos++;
1992           } else {
1993             s5 = peg$FAILED;
1994             if (peg$silentFails === 0) { peg$fail(peg$c43); }
1995           }
1996           if (s5 !== peg$FAILED) {
1997             s6 = peg$parseidentifierName();
1998             if (s6 !== peg$FAILED) {
1999               s5 = [s5, s6];
2000               s4 = s5;
2001             } else {
2002               peg$currPos = s4;
2003               s4 = peg$FAILED;
2004             }
2005           } else {
2006             peg$currPos = s4;
2007             s4 = peg$FAILED;
2008           }
2009           while (s4 !== peg$FAILED) {
2010             s3.push(s4);
2011             s4 = peg$currPos;
2012             if (input.charCodeAt(peg$currPos) === 46) {
2013               s5 = peg$c42;
2014               peg$currPos++;
2015             } else {
2016               s5 = peg$FAILED;
2017               if (peg$silentFails === 0) { peg$fail(peg$c43); }
2018             }
2019             if (s5 !== peg$FAILED) {
2020               s6 = peg$parseidentifierName();
2021               if (s6 !== peg$FAILED) {
2022                 s5 = [s5, s6];
2023                 s4 = s5;
2024               } else {
2025                 peg$currPos = s4;
2026                 s4 = peg$FAILED;
2027               }
2028             } else {
2029               peg$currPos = s4;
2030               s4 = peg$FAILED;
2031             }
2032           }
2033           if (s3 !== peg$FAILED) {
2034             peg$savedPos = s0;
2035             s1 = peg$c78(s2, s3);
2036             s0 = s1;
2037           } else {
2038             peg$currPos = s0;
2039             s0 = peg$FAILED;
2040           }
2041         } else {
2042           peg$currPos = s0;
2043           s0 = peg$FAILED;
2044         }
2045       } else {
2046         peg$currPos = s0;
2047         s0 = peg$FAILED;
2048       }
2049
2050       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
2051
2052       return s0;
2053     }
2054
2055     function peg$parsenegation() {
2056       var s0, s1, s2, s3, s4, s5;
2057
2058       var key    = peg$currPos * 30 + 22,
2059           cached = peg$resultsCache[key];
2060
2061       if (cached) {
2062         peg$currPos = cached.nextPos;
2063
2064         return cached.result;
2065       }
2066
2067       s0 = peg$currPos;
2068       if (input.substr(peg$currPos, 5) === peg$c79) {
2069         s1 = peg$c79;
2070         peg$currPos += 5;
2071       } else {
2072         s1 = peg$FAILED;
2073         if (peg$silentFails === 0) { peg$fail(peg$c80); }
2074       }
2075       if (s1 !== peg$FAILED) {
2076         s2 = peg$parse_();
2077         if (s2 !== peg$FAILED) {
2078           s3 = peg$parseselectors();
2079           if (s3 !== peg$FAILED) {
2080             s4 = peg$parse_();
2081             if (s4 !== peg$FAILED) {
2082               if (input.charCodeAt(peg$currPos) === 41) {
2083                 s5 = peg$c68;
2084                 peg$currPos++;
2085               } else {
2086                 s5 = peg$FAILED;
2087                 if (peg$silentFails === 0) { peg$fail(peg$c69); }
2088               }
2089               if (s5 !== peg$FAILED) {
2090                 peg$savedPos = s0;
2091                 s1 = peg$c81(s3);
2092                 s0 = s1;
2093               } else {
2094                 peg$currPos = s0;
2095                 s0 = peg$FAILED;
2096               }
2097             } else {
2098               peg$currPos = s0;
2099               s0 = peg$FAILED;
2100             }
2101           } else {
2102             peg$currPos = s0;
2103             s0 = peg$FAILED;
2104           }
2105         } else {
2106           peg$currPos = s0;
2107           s0 = peg$FAILED;
2108         }
2109       } else {
2110         peg$currPos = s0;
2111         s0 = peg$FAILED;
2112       }
2113
2114       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
2115
2116       return s0;
2117     }
2118
2119     function peg$parsematches() {
2120       var s0, s1, s2, s3, s4, s5;
2121
2122       var key    = peg$currPos * 30 + 23,
2123           cached = peg$resultsCache[key];
2124
2125       if (cached) {
2126         peg$currPos = cached.nextPos;
2127
2128         return cached.result;
2129       }
2130
2131       s0 = peg$currPos;
2132       if (input.substr(peg$currPos, 9) === peg$c82) {
2133         s1 = peg$c82;
2134         peg$currPos += 9;
2135       } else {
2136         s1 = peg$FAILED;
2137         if (peg$silentFails === 0) { peg$fail(peg$c83); }
2138       }
2139       if (s1 !== peg$FAILED) {
2140         s2 = peg$parse_();
2141         if (s2 !== peg$FAILED) {
2142           s3 = peg$parseselectors();
2143           if (s3 !== peg$FAILED) {
2144             s4 = peg$parse_();
2145             if (s4 !== peg$FAILED) {
2146               if (input.charCodeAt(peg$currPos) === 41) {
2147                 s5 = peg$c68;
2148                 peg$currPos++;
2149               } else {
2150                 s5 = peg$FAILED;
2151                 if (peg$silentFails === 0) { peg$fail(peg$c69); }
2152               }
2153               if (s5 !== peg$FAILED) {
2154                 peg$savedPos = s0;
2155                 s1 = peg$c84(s3);
2156                 s0 = s1;
2157               } else {
2158                 peg$currPos = s0;
2159                 s0 = peg$FAILED;
2160               }
2161             } else {
2162               peg$currPos = s0;
2163               s0 = peg$FAILED;
2164             }
2165           } else {
2166             peg$currPos = s0;
2167             s0 = peg$FAILED;
2168           }
2169         } else {
2170           peg$currPos = s0;
2171           s0 = peg$FAILED;
2172         }
2173       } else {
2174         peg$currPos = s0;
2175         s0 = peg$FAILED;
2176       }
2177
2178       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
2179
2180       return s0;
2181     }
2182
2183     function peg$parsehas() {
2184       var s0, s1, s2, s3, s4, s5;
2185
2186       var key    = peg$currPos * 30 + 24,
2187           cached = peg$resultsCache[key];
2188
2189       if (cached) {
2190         peg$currPos = cached.nextPos;
2191
2192         return cached.result;
2193       }
2194
2195       s0 = peg$currPos;
2196       if (input.substr(peg$currPos, 5) === peg$c85) {
2197         s1 = peg$c85;
2198         peg$currPos += 5;
2199       } else {
2200         s1 = peg$FAILED;
2201         if (peg$silentFails === 0) { peg$fail(peg$c86); }
2202       }
2203       if (s1 !== peg$FAILED) {
2204         s2 = peg$parse_();
2205         if (s2 !== peg$FAILED) {
2206           s3 = peg$parseselectors();
2207           if (s3 !== peg$FAILED) {
2208             s4 = peg$parse_();
2209             if (s4 !== peg$FAILED) {
2210               if (input.charCodeAt(peg$currPos) === 41) {
2211                 s5 = peg$c68;
2212                 peg$currPos++;
2213               } else {
2214                 s5 = peg$FAILED;
2215                 if (peg$silentFails === 0) { peg$fail(peg$c69); }
2216               }
2217               if (s5 !== peg$FAILED) {
2218                 peg$savedPos = s0;
2219                 s1 = peg$c87(s3);
2220                 s0 = s1;
2221               } else {
2222                 peg$currPos = s0;
2223                 s0 = peg$FAILED;
2224               }
2225             } else {
2226               peg$currPos = s0;
2227               s0 = peg$FAILED;
2228             }
2229           } else {
2230             peg$currPos = s0;
2231             s0 = peg$FAILED;
2232           }
2233         } else {
2234           peg$currPos = s0;
2235           s0 = peg$FAILED;
2236         }
2237       } else {
2238         peg$currPos = s0;
2239         s0 = peg$FAILED;
2240       }
2241
2242       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
2243
2244       return s0;
2245     }
2246
2247     function peg$parsefirstChild() {
2248       var s0, s1;
2249
2250       var key    = peg$currPos * 30 + 25,
2251           cached = peg$resultsCache[key];
2252
2253       if (cached) {
2254         peg$currPos = cached.nextPos;
2255
2256         return cached.result;
2257       }
2258
2259       s0 = peg$currPos;
2260       if (input.substr(peg$currPos, 12) === peg$c88) {
2261         s1 = peg$c88;
2262         peg$currPos += 12;
2263       } else {
2264         s1 = peg$FAILED;
2265         if (peg$silentFails === 0) { peg$fail(peg$c89); }
2266       }
2267       if (s1 !== peg$FAILED) {
2268         peg$savedPos = s0;
2269         s1 = peg$c90();
2270       }
2271       s0 = s1;
2272
2273       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
2274
2275       return s0;
2276     }
2277
2278     function peg$parselastChild() {
2279       var s0, s1;
2280
2281       var key    = peg$currPos * 30 + 26,
2282           cached = peg$resultsCache[key];
2283
2284       if (cached) {
2285         peg$currPos = cached.nextPos;
2286
2287         return cached.result;
2288       }
2289
2290       s0 = peg$currPos;
2291       if (input.substr(peg$currPos, 11) === peg$c91) {
2292         s1 = peg$c91;
2293         peg$currPos += 11;
2294       } else {
2295         s1 = peg$FAILED;
2296         if (peg$silentFails === 0) { peg$fail(peg$c92); }
2297       }
2298       if (s1 !== peg$FAILED) {
2299         peg$savedPos = s0;
2300         s1 = peg$c93();
2301       }
2302       s0 = s1;
2303
2304       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
2305
2306       return s0;
2307     }
2308
2309     function peg$parsenthChild() {
2310       var s0, s1, s2, s3, s4, s5;
2311
2312       var key    = peg$currPos * 30 + 27,
2313           cached = peg$resultsCache[key];
2314
2315       if (cached) {
2316         peg$currPos = cached.nextPos;
2317
2318         return cached.result;
2319       }
2320
2321       s0 = peg$currPos;
2322       if (input.substr(peg$currPos, 11) === peg$c94) {
2323         s1 = peg$c94;
2324         peg$currPos += 11;
2325       } else {
2326         s1 = peg$FAILED;
2327         if (peg$silentFails === 0) { peg$fail(peg$c95); }
2328       }
2329       if (s1 !== peg$FAILED) {
2330         s2 = peg$parse_();
2331         if (s2 !== peg$FAILED) {
2332           s3 = [];
2333           if (peg$c60.test(input.charAt(peg$currPos))) {
2334             s4 = input.charAt(peg$currPos);
2335             peg$currPos++;
2336           } else {
2337             s4 = peg$FAILED;
2338             if (peg$silentFails === 0) { peg$fail(peg$c61); }
2339           }
2340           if (s4 !== peg$FAILED) {
2341             while (s4 !== peg$FAILED) {
2342               s3.push(s4);
2343               if (peg$c60.test(input.charAt(peg$currPos))) {
2344                 s4 = input.charAt(peg$currPos);
2345                 peg$currPos++;
2346               } else {
2347                 s4 = peg$FAILED;
2348                 if (peg$silentFails === 0) { peg$fail(peg$c61); }
2349               }
2350             }
2351           } else {
2352             s3 = peg$FAILED;
2353           }
2354           if (s3 !== peg$FAILED) {
2355             s4 = peg$parse_();
2356             if (s4 !== peg$FAILED) {
2357               if (input.charCodeAt(peg$currPos) === 41) {
2358                 s5 = peg$c68;
2359                 peg$currPos++;
2360               } else {
2361                 s5 = peg$FAILED;
2362                 if (peg$silentFails === 0) { peg$fail(peg$c69); }
2363               }
2364               if (s5 !== peg$FAILED) {
2365                 peg$savedPos = s0;
2366                 s1 = peg$c96(s3);
2367                 s0 = s1;
2368               } else {
2369                 peg$currPos = s0;
2370                 s0 = peg$FAILED;
2371               }
2372             } else {
2373               peg$currPos = s0;
2374               s0 = peg$FAILED;
2375             }
2376           } else {
2377             peg$currPos = s0;
2378             s0 = peg$FAILED;
2379           }
2380         } else {
2381           peg$currPos = s0;
2382           s0 = peg$FAILED;
2383         }
2384       } else {
2385         peg$currPos = s0;
2386         s0 = peg$FAILED;
2387       }
2388
2389       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
2390
2391       return s0;
2392     }
2393
2394     function peg$parsenthLastChild() {
2395       var s0, s1, s2, s3, s4, s5;
2396
2397       var key    = peg$currPos * 30 + 28,
2398           cached = peg$resultsCache[key];
2399
2400       if (cached) {
2401         peg$currPos = cached.nextPos;
2402
2403         return cached.result;
2404       }
2405
2406       s0 = peg$currPos;
2407       if (input.substr(peg$currPos, 16) === peg$c97) {
2408         s1 = peg$c97;
2409         peg$currPos += 16;
2410       } else {
2411         s1 = peg$FAILED;
2412         if (peg$silentFails === 0) { peg$fail(peg$c98); }
2413       }
2414       if (s1 !== peg$FAILED) {
2415         s2 = peg$parse_();
2416         if (s2 !== peg$FAILED) {
2417           s3 = [];
2418           if (peg$c60.test(input.charAt(peg$currPos))) {
2419             s4 = input.charAt(peg$currPos);
2420             peg$currPos++;
2421           } else {
2422             s4 = peg$FAILED;
2423             if (peg$silentFails === 0) { peg$fail(peg$c61); }
2424           }
2425           if (s4 !== peg$FAILED) {
2426             while (s4 !== peg$FAILED) {
2427               s3.push(s4);
2428               if (peg$c60.test(input.charAt(peg$currPos))) {
2429                 s4 = input.charAt(peg$currPos);
2430                 peg$currPos++;
2431               } else {
2432                 s4 = peg$FAILED;
2433                 if (peg$silentFails === 0) { peg$fail(peg$c61); }
2434               }
2435             }
2436           } else {
2437             s3 = peg$FAILED;
2438           }
2439           if (s3 !== peg$FAILED) {
2440             s4 = peg$parse_();
2441             if (s4 !== peg$FAILED) {
2442               if (input.charCodeAt(peg$currPos) === 41) {
2443                 s5 = peg$c68;
2444                 peg$currPos++;
2445               } else {
2446                 s5 = peg$FAILED;
2447                 if (peg$silentFails === 0) { peg$fail(peg$c69); }
2448               }
2449               if (s5 !== peg$FAILED) {
2450                 peg$savedPos = s0;
2451                 s1 = peg$c99(s3);
2452                 s0 = s1;
2453               } else {
2454                 peg$currPos = s0;
2455                 s0 = peg$FAILED;
2456               }
2457             } else {
2458               peg$currPos = s0;
2459               s0 = peg$FAILED;
2460             }
2461           } else {
2462             peg$currPos = s0;
2463             s0 = peg$FAILED;
2464           }
2465         } else {
2466           peg$currPos = s0;
2467           s0 = peg$FAILED;
2468         }
2469       } else {
2470         peg$currPos = s0;
2471         s0 = peg$FAILED;
2472       }
2473
2474       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
2475
2476       return s0;
2477     }
2478
2479     function peg$parseclass() {
2480       var s0, s1, s2;
2481
2482       var key    = peg$currPos * 30 + 29,
2483           cached = peg$resultsCache[key];
2484
2485       if (cached) {
2486         peg$currPos = cached.nextPos;
2487
2488         return cached.result;
2489       }
2490
2491       s0 = peg$currPos;
2492       if (input.charCodeAt(peg$currPos) === 58) {
2493         s1 = peg$c100;
2494         peg$currPos++;
2495       } else {
2496         s1 = peg$FAILED;
2497         if (peg$silentFails === 0) { peg$fail(peg$c101); }
2498       }
2499       if (s1 !== peg$FAILED) {
2500         if (input.substr(peg$currPos, 9).toLowerCase() === peg$c102) {
2501           s2 = input.substr(peg$currPos, 9);
2502           peg$currPos += 9;
2503         } else {
2504           s2 = peg$FAILED;
2505           if (peg$silentFails === 0) { peg$fail(peg$c103); }
2506         }
2507         if (s2 === peg$FAILED) {
2508           if (input.substr(peg$currPos, 10).toLowerCase() === peg$c104) {
2509             s2 = input.substr(peg$currPos, 10);
2510             peg$currPos += 10;
2511           } else {
2512             s2 = peg$FAILED;
2513             if (peg$silentFails === 0) { peg$fail(peg$c105); }
2514           }
2515           if (s2 === peg$FAILED) {
2516             if (input.substr(peg$currPos, 11).toLowerCase() === peg$c106) {
2517               s2 = input.substr(peg$currPos, 11);
2518               peg$currPos += 11;
2519             } else {
2520               s2 = peg$FAILED;
2521               if (peg$silentFails === 0) { peg$fail(peg$c107); }
2522             }
2523             if (s2 === peg$FAILED) {
2524               if (input.substr(peg$currPos, 8).toLowerCase() === peg$c108) {
2525                 s2 = input.substr(peg$currPos, 8);
2526                 peg$currPos += 8;
2527               } else {
2528                 s2 = peg$FAILED;
2529                 if (peg$silentFails === 0) { peg$fail(peg$c109); }
2530               }
2531               if (s2 === peg$FAILED) {
2532                 if (input.substr(peg$currPos, 7).toLowerCase() === peg$c110) {
2533                   s2 = input.substr(peg$currPos, 7);
2534                   peg$currPos += 7;
2535                 } else {
2536                   s2 = peg$FAILED;
2537                   if (peg$silentFails === 0) { peg$fail(peg$c111); }
2538                 }
2539               }
2540             }
2541           }
2542         }
2543         if (s2 !== peg$FAILED) {
2544           peg$savedPos = s0;
2545           s1 = peg$c112(s2);
2546           s0 = s1;
2547         } else {
2548           peg$currPos = s0;
2549           s0 = peg$FAILED;
2550         }
2551       } else {
2552         peg$currPos = s0;
2553         s0 = peg$FAILED;
2554       }
2555
2556       peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
2557
2558       return s0;
2559     }
2560
2561
2562       function nth(n) { return { type: 'nth-child', index: { type: 'literal', value: n } }; }
2563       function nthLast(n) { return { type: 'nth-last-child', index: { type: 'literal', value: n } }; }
2564       function strUnescape(s) {
2565         return s.replace(/\\(.)/g, function(match, ch) {
2566           switch(ch) {
2567             case 'b': return '\b';
2568             case 'f': return '\f';
2569             case 'n': return '\n';
2570             case 'r': return '\r';
2571             case 't': return '\t';
2572             case 'v': return '\v';
2573             default: return ch;
2574           }
2575         });
2576       }
2577
2578
2579     peg$result = peg$startRuleFunction();
2580
2581     if (peg$result !== peg$FAILED && peg$currPos === input.length) {
2582       return peg$result;
2583     } else {
2584       if (peg$result !== peg$FAILED && peg$currPos < input.length) {
2585         peg$fail(peg$endExpectation());
2586       }
2587
2588       throw peg$buildStructuredError(
2589         peg$maxFailExpected,
2590         peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
2591         peg$maxFailPos < input.length
2592           ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
2593           : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
2594       );
2595     }
2596   }
2597
2598   return {
2599     SyntaxError: peg$SyntaxError,
2600     parse:       peg$parse
2601   };
2602 });