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