source: imaps-frontend/node_modules/esquery/parser.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

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