@loancrate/json-selector 2.0.0 → 2.1.0

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