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