@evervault/eql 0.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.
package/dist/index.mjs ADDED
@@ -0,0 +1,968 @@
1
+ // @generated by Peggy 4.0.2.
2
+ //
3
+ // https://peggyjs.org/
4
+
5
+
6
+ function peg$subclass(child, parent) {
7
+ function C() { this.constructor = child; }
8
+ C.prototype = parent.prototype;
9
+ child.prototype = new C();
10
+ }
11
+
12
+ function peg$SyntaxError(message, expected, found, location) {
13
+ var self = Error.call(this, message);
14
+ // istanbul ignore next Check is a necessary evil to support older environments
15
+ if (Object.setPrototypeOf) {
16
+ Object.setPrototypeOf(self, peg$SyntaxError.prototype);
17
+ }
18
+ self.expected = expected;
19
+ self.found = found;
20
+ self.location = location;
21
+ self.name = "SyntaxError";
22
+ return self;
23
+ }
24
+
25
+ peg$subclass(peg$SyntaxError, Error);
26
+
27
+ function peg$padEnd(str, targetLength, padString) {
28
+ padString = padString || " ";
29
+ if (str.length > targetLength) { return str; }
30
+ targetLength -= str.length;
31
+ padString += padString.repeat(targetLength);
32
+ return str + padString.slice(0, targetLength);
33
+ }
34
+
35
+ peg$SyntaxError.prototype.format = function(sources) {
36
+ var str = "Error: " + this.message;
37
+ if (this.location) {
38
+ var src = null;
39
+ var k;
40
+ for (k = 0; k < sources.length; k++) {
41
+ if (sources[k].source === this.location.source) {
42
+ src = sources[k].text.split(/\r\n|\n|\r/g);
43
+ break;
44
+ }
45
+ }
46
+ var s = this.location.start;
47
+ var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
48
+ ? this.location.source.offset(s)
49
+ : s;
50
+ var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
51
+ if (src) {
52
+ var e = this.location.end;
53
+ var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
54
+ var line = src[s.line - 1];
55
+ var last = s.line === e.line ? e.column : line.length + 1;
56
+ var hatLen = (last - s.column) || 1;
57
+ str += "\n --> " + loc + "\n"
58
+ + filler + " |\n"
59
+ + offset_s.line + " | " + line + "\n"
60
+ + filler + " | " + peg$padEnd("", s.column - 1, ' ')
61
+ + peg$padEnd("", hatLen, "^");
62
+ } else {
63
+ str += "\n at " + loc;
64
+ }
65
+ }
66
+ return str;
67
+ };
68
+
69
+ peg$SyntaxError.buildMessage = function(expected, found) {
70
+ var DESCRIBE_EXPECTATION_FNS = {
71
+ literal: function(expectation) {
72
+ return "\"" + literalEscape(expectation.text) + "\"";
73
+ },
74
+
75
+ class: function(expectation) {
76
+ var escapedParts = expectation.parts.map(function(part) {
77
+ return Array.isArray(part)
78
+ ? classEscape(part[0]) + "-" + classEscape(part[1])
79
+ : classEscape(part);
80
+ });
81
+
82
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
83
+ },
84
+
85
+ any: function() {
86
+ return "any character";
87
+ },
88
+
89
+ end: function() {
90
+ return "end of input";
91
+ },
92
+
93
+ other: function(expectation) {
94
+ return expectation.description;
95
+ }
96
+ };
97
+
98
+ function hex(ch) {
99
+ return ch.charCodeAt(0).toString(16).toUpperCase();
100
+ }
101
+
102
+ function literalEscape(s) {
103
+ return s
104
+ .replace(/\\/g, "\\\\")
105
+ .replace(/"/g, "\\\"")
106
+ .replace(/\0/g, "\\0")
107
+ .replace(/\t/g, "\\t")
108
+ .replace(/\n/g, "\\n")
109
+ .replace(/\r/g, "\\r")
110
+ .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
111
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
112
+ }
113
+
114
+ function classEscape(s) {
115
+ return s
116
+ .replace(/\\/g, "\\\\")
117
+ .replace(/\]/g, "\\]")
118
+ .replace(/\^/g, "\\^")
119
+ .replace(/-/g, "\\-")
120
+ .replace(/\0/g, "\\0")
121
+ .replace(/\t/g, "\\t")
122
+ .replace(/\n/g, "\\n")
123
+ .replace(/\r/g, "\\r")
124
+ .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); })
125
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); });
126
+ }
127
+
128
+ function describeExpectation(expectation) {
129
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
130
+ }
131
+
132
+ function describeExpected(expected) {
133
+ var descriptions = expected.map(describeExpectation);
134
+ var i, j;
135
+
136
+ descriptions.sort();
137
+
138
+ if (descriptions.length > 0) {
139
+ for (i = 1, j = 1; i < descriptions.length; i++) {
140
+ if (descriptions[i - 1] !== descriptions[i]) {
141
+ descriptions[j] = descriptions[i];
142
+ j++;
143
+ }
144
+ }
145
+ descriptions.length = j;
146
+ }
147
+
148
+ switch (descriptions.length) {
149
+ case 1:
150
+ return descriptions[0];
151
+
152
+ case 2:
153
+ return descriptions[0] + " or " + descriptions[1];
154
+
155
+ default:
156
+ return descriptions.slice(0, -1).join(", ")
157
+ + ", or "
158
+ + descriptions[descriptions.length - 1];
159
+ }
160
+ }
161
+
162
+ function describeFound(found) {
163
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
164
+ }
165
+
166
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
167
+ };
168
+
169
+ function peg$parse(input, options) {
170
+ options = options !== undefined ? options : {};
171
+
172
+ var peg$FAILED = {};
173
+ var peg$source = options.grammarSource;
174
+
175
+ var peg$startRuleFunctions = { Query: peg$parseQuery };
176
+ var peg$startRuleFunction = peg$parseQuery;
177
+
178
+ var peg$c0 = "OR";
179
+ var peg$c1 = "or";
180
+ var peg$c2 = "AND";
181
+ var peg$c3 = "and";
182
+ var peg$c4 = "(";
183
+ var peg$c5 = ")";
184
+ var peg$c6 = "=";
185
+ var peg$c7 = "!=";
186
+ var peg$c8 = ":";
187
+ var peg$c9 = "!:";
188
+ var peg$c10 = ">";
189
+ var peg$c11 = ">=";
190
+ var peg$c12 = "<";
191
+ var peg$c13 = "<=";
192
+ var peg$c14 = ".";
193
+ var peg$c15 = "\"";
194
+
195
+ var peg$r0 = /^[a-zA-Z0-9_]/;
196
+ var peg$r1 = /^[0-9]/;
197
+ var peg$r2 = /^[^"]/;
198
+ var peg$r3 = /^[ \t\n\r]/;
199
+
200
+ var peg$e0 = peg$literalExpectation("OR", false);
201
+ var peg$e1 = peg$literalExpectation("or", false);
202
+ var peg$e2 = peg$literalExpectation("AND", false);
203
+ var peg$e3 = peg$literalExpectation("and", false);
204
+ var peg$e4 = peg$literalExpectation("(", false);
205
+ var peg$e5 = peg$literalExpectation(")", false);
206
+ var peg$e6 = peg$literalExpectation("=", false);
207
+ var peg$e7 = peg$literalExpectation("!=", false);
208
+ var peg$e8 = peg$literalExpectation(":", false);
209
+ var peg$e9 = peg$literalExpectation("!:", false);
210
+ var peg$e10 = peg$literalExpectation(">", false);
211
+ var peg$e11 = peg$literalExpectation(">=", false);
212
+ var peg$e12 = peg$literalExpectation("<", false);
213
+ var peg$e13 = peg$literalExpectation("<=", false);
214
+ var peg$e14 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"], "_"], false, false);
215
+ var peg$e15 = peg$literalExpectation(".", false);
216
+ var peg$e16 = peg$otherExpectation("integer");
217
+ var peg$e17 = peg$classExpectation([["0", "9"]], false, false);
218
+ var peg$e18 = peg$literalExpectation("\"", false);
219
+ var peg$e19 = peg$classExpectation(["\""], true, false);
220
+ var peg$e20 = peg$otherExpectation("whitespace");
221
+ var peg$e21 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false);
222
+
223
+ var peg$f0 = function(left, right) {
224
+ return { type: 'compound', operator: 'OR', left, right }
225
+ };
226
+ var peg$f1 = function(left, right) {
227
+ return { type: 'compound', operator: 'AND', left, right }
228
+ };
229
+ var peg$f2 = function(first, rest) {
230
+ let result = first;
231
+ for (const [_, comp] of rest) {
232
+ result = { type: 'compound', operator: 'AND', left: result, right: comp };
233
+ }
234
+ return result;
235
+ };
236
+ var peg$f3 = function(left, operator, right) {
237
+ return { type: 'comparison', operator, left, right }
238
+ };
239
+ var peg$f4 = function(exp) {
240
+ return exp;
241
+ };
242
+ var peg$f5 = function(chars) {
243
+ return chars.join('')
244
+ };
245
+ var peg$f6 = function(identifier) {
246
+ return "." + identifier
247
+ };
248
+ var peg$f7 = function(first, rest) {
249
+ return first + rest.join('')
250
+ };
251
+ var peg$f8 = function() { return parseInt(text(), 10); };
252
+ var peg$f9 = function(chars) {
253
+ return chars.join('');
254
+ };
255
+ var peg$currPos = options.peg$currPos | 0;
256
+ var peg$savedPos = peg$currPos;
257
+ var peg$posDetailsCache = [{ line: 1, column: 1 }];
258
+ var peg$maxFailPos = peg$currPos;
259
+ var peg$maxFailExpected = options.peg$maxFailExpected || [];
260
+ var peg$silentFails = options.peg$silentFails | 0;
261
+
262
+ var peg$result;
263
+
264
+ if (options.startRule) {
265
+ if (!(options.startRule in peg$startRuleFunctions)) {
266
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
267
+ }
268
+
269
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
270
+ }
271
+
272
+ function text() {
273
+ return input.substring(peg$savedPos, peg$currPos);
274
+ }
275
+
276
+ function offset() {
277
+ return peg$savedPos;
278
+ }
279
+
280
+ function range() {
281
+ return {
282
+ source: peg$source,
283
+ start: peg$savedPos,
284
+ end: peg$currPos
285
+ };
286
+ }
287
+
288
+ function location() {
289
+ return peg$computeLocation(peg$savedPos, peg$currPos);
290
+ }
291
+
292
+ function expected(description, location) {
293
+ location = location !== undefined
294
+ ? location
295
+ : peg$computeLocation(peg$savedPos, peg$currPos);
296
+
297
+ throw peg$buildStructuredError(
298
+ [peg$otherExpectation(description)],
299
+ input.substring(peg$savedPos, peg$currPos),
300
+ location
301
+ );
302
+ }
303
+
304
+ function error(message, location) {
305
+ location = location !== undefined
306
+ ? location
307
+ : peg$computeLocation(peg$savedPos, peg$currPos);
308
+
309
+ throw peg$buildSimpleError(message, location);
310
+ }
311
+
312
+ function peg$literalExpectation(text, ignoreCase) {
313
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
314
+ }
315
+
316
+ function peg$classExpectation(parts, inverted, ignoreCase) {
317
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
318
+ }
319
+
320
+ function peg$anyExpectation() {
321
+ return { type: "any" };
322
+ }
323
+
324
+ function peg$endExpectation() {
325
+ return { type: "end" };
326
+ }
327
+
328
+ function peg$otherExpectation(description) {
329
+ return { type: "other", description: description };
330
+ }
331
+
332
+ function peg$computePosDetails(pos) {
333
+ var details = peg$posDetailsCache[pos];
334
+ var p;
335
+
336
+ if (details) {
337
+ return details;
338
+ } else {
339
+ if (pos >= peg$posDetailsCache.length) {
340
+ p = peg$posDetailsCache.length - 1;
341
+ } else {
342
+ p = pos;
343
+ while (!peg$posDetailsCache[--p]) {}
344
+ }
345
+
346
+ details = peg$posDetailsCache[p];
347
+ details = {
348
+ line: details.line,
349
+ column: details.column
350
+ };
351
+
352
+ while (p < pos) {
353
+ if (input.charCodeAt(p) === 10) {
354
+ details.line++;
355
+ details.column = 1;
356
+ } else {
357
+ details.column++;
358
+ }
359
+
360
+ p++;
361
+ }
362
+
363
+ peg$posDetailsCache[pos] = details;
364
+
365
+ return details;
366
+ }
367
+ }
368
+
369
+ function peg$computeLocation(startPos, endPos, offset) {
370
+ var startPosDetails = peg$computePosDetails(startPos);
371
+ var endPosDetails = peg$computePosDetails(endPos);
372
+
373
+ var res = {
374
+ source: peg$source,
375
+ start: {
376
+ offset: startPos,
377
+ line: startPosDetails.line,
378
+ column: startPosDetails.column
379
+ },
380
+ end: {
381
+ offset: endPos,
382
+ line: endPosDetails.line,
383
+ column: endPosDetails.column
384
+ }
385
+ };
386
+ if (offset && peg$source && (typeof peg$source.offset === "function")) {
387
+ res.start = peg$source.offset(res.start);
388
+ res.end = peg$source.offset(res.end);
389
+ }
390
+ return res;
391
+ }
392
+
393
+ function peg$fail(expected) {
394
+ if (peg$currPos < peg$maxFailPos) { return; }
395
+
396
+ if (peg$currPos > peg$maxFailPos) {
397
+ peg$maxFailPos = peg$currPos;
398
+ peg$maxFailExpected = [];
399
+ }
400
+
401
+ peg$maxFailExpected.push(expected);
402
+ }
403
+
404
+ function peg$buildSimpleError(message, location) {
405
+ return new peg$SyntaxError(message, null, null, location);
406
+ }
407
+
408
+ function peg$buildStructuredError(expected, found, location) {
409
+ return new peg$SyntaxError(
410
+ peg$SyntaxError.buildMessage(expected, found),
411
+ expected,
412
+ found,
413
+ location
414
+ );
415
+ }
416
+
417
+ function peg$parseQuery() {
418
+ var s0;
419
+
420
+ s0 = peg$parseOR();
421
+
422
+ return s0;
423
+ }
424
+
425
+ function peg$parseOR() {
426
+ var s0, s1, s2, s3, s4, s5;
427
+
428
+ s0 = peg$currPos;
429
+ s1 = peg$parseAND();
430
+ if (s1 !== peg$FAILED) {
431
+ s2 = peg$parse_();
432
+ if (input.substr(peg$currPos, 2) === peg$c0) {
433
+ s3 = peg$c0;
434
+ peg$currPos += 2;
435
+ } else {
436
+ s3 = peg$FAILED;
437
+ if (peg$silentFails === 0) { peg$fail(peg$e0); }
438
+ }
439
+ if (s3 === peg$FAILED) {
440
+ if (input.substr(peg$currPos, 2) === peg$c1) {
441
+ s3 = peg$c1;
442
+ peg$currPos += 2;
443
+ } else {
444
+ s3 = peg$FAILED;
445
+ if (peg$silentFails === 0) { peg$fail(peg$e1); }
446
+ }
447
+ }
448
+ if (s3 !== peg$FAILED) {
449
+ s4 = peg$parse_();
450
+ s5 = peg$parseOR();
451
+ if (s5 !== peg$FAILED) {
452
+ peg$savedPos = s0;
453
+ s0 = peg$f0(s1, s5);
454
+ } else {
455
+ peg$currPos = s0;
456
+ s0 = peg$FAILED;
457
+ }
458
+ } else {
459
+ peg$currPos = s0;
460
+ s0 = peg$FAILED;
461
+ }
462
+ } else {
463
+ peg$currPos = s0;
464
+ s0 = peg$FAILED;
465
+ }
466
+ if (s0 === peg$FAILED) {
467
+ s0 = peg$parseAND();
468
+ }
469
+
470
+ return s0;
471
+ }
472
+
473
+ function peg$parseAND() {
474
+ var s0, s1, s2, s3, s4, s5;
475
+
476
+ s0 = peg$currPos;
477
+ s1 = peg$parseComparison();
478
+ if (s1 !== peg$FAILED) {
479
+ s2 = peg$parse_();
480
+ if (input.substr(peg$currPos, 3) === peg$c2) {
481
+ s3 = peg$c2;
482
+ peg$currPos += 3;
483
+ } else {
484
+ s3 = peg$FAILED;
485
+ if (peg$silentFails === 0) { peg$fail(peg$e2); }
486
+ }
487
+ if (s3 === peg$FAILED) {
488
+ if (input.substr(peg$currPos, 3) === peg$c3) {
489
+ s3 = peg$c3;
490
+ peg$currPos += 3;
491
+ } else {
492
+ s3 = peg$FAILED;
493
+ if (peg$silentFails === 0) { peg$fail(peg$e3); }
494
+ }
495
+ }
496
+ if (s3 !== peg$FAILED) {
497
+ s4 = peg$parse_();
498
+ s5 = peg$parseAND();
499
+ if (s5 !== peg$FAILED) {
500
+ peg$savedPos = s0;
501
+ s0 = peg$f1(s1, s5);
502
+ } else {
503
+ peg$currPos = s0;
504
+ s0 = peg$FAILED;
505
+ }
506
+ } else {
507
+ peg$currPos = s0;
508
+ s0 = peg$FAILED;
509
+ }
510
+ } else {
511
+ peg$currPos = s0;
512
+ s0 = peg$FAILED;
513
+ }
514
+ if (s0 === peg$FAILED) {
515
+ s0 = peg$parseImplicitAnd();
516
+ if (s0 === peg$FAILED) {
517
+ s0 = peg$parseComparison();
518
+ }
519
+ }
520
+
521
+ return s0;
522
+ }
523
+
524
+ function peg$parseImplicitAnd() {
525
+ var s0, s1, s2, s3, s4, s5;
526
+
527
+ s0 = peg$currPos;
528
+ s1 = peg$parseComparison();
529
+ if (s1 !== peg$FAILED) {
530
+ s2 = [];
531
+ s3 = peg$currPos;
532
+ s4 = peg$parse_();
533
+ s5 = peg$parseComparison();
534
+ if (s5 !== peg$FAILED) {
535
+ s4 = [s4, s5];
536
+ s3 = s4;
537
+ } else {
538
+ peg$currPos = s3;
539
+ s3 = peg$FAILED;
540
+ }
541
+ while (s3 !== peg$FAILED) {
542
+ s2.push(s3);
543
+ s3 = peg$currPos;
544
+ s4 = peg$parse_();
545
+ s5 = peg$parseComparison();
546
+ if (s5 !== peg$FAILED) {
547
+ s4 = [s4, s5];
548
+ s3 = s4;
549
+ } else {
550
+ peg$currPos = s3;
551
+ s3 = peg$FAILED;
552
+ }
553
+ }
554
+ peg$savedPos = s0;
555
+ s0 = peg$f2(s1, s2);
556
+ } else {
557
+ peg$currPos = s0;
558
+ s0 = peg$FAILED;
559
+ }
560
+
561
+ return s0;
562
+ }
563
+
564
+ function peg$parseComparison() {
565
+ var s0, s1, s2, s3, s4, s5;
566
+
567
+ s0 = peg$currPos;
568
+ s1 = peg$parseKey();
569
+ if (s1 !== peg$FAILED) {
570
+ s2 = peg$parse_();
571
+ s3 = peg$parseOperator();
572
+ if (s3 !== peg$FAILED) {
573
+ s4 = peg$parse_();
574
+ s5 = peg$parseValue();
575
+ if (s5 !== peg$FAILED) {
576
+ peg$savedPos = s0;
577
+ s0 = peg$f3(s1, s3, s5);
578
+ } else {
579
+ peg$currPos = s0;
580
+ s0 = peg$FAILED;
581
+ }
582
+ } else {
583
+ peg$currPos = s0;
584
+ s0 = peg$FAILED;
585
+ }
586
+ } else {
587
+ peg$currPos = s0;
588
+ s0 = peg$FAILED;
589
+ }
590
+ if (s0 === peg$FAILED) {
591
+ s0 = peg$currPos;
592
+ if (input.charCodeAt(peg$currPos) === 40) {
593
+ s1 = peg$c4;
594
+ peg$currPos++;
595
+ } else {
596
+ s1 = peg$FAILED;
597
+ if (peg$silentFails === 0) { peg$fail(peg$e4); }
598
+ }
599
+ if (s1 !== peg$FAILED) {
600
+ s2 = peg$parse_();
601
+ s3 = peg$parseOR();
602
+ if (s3 !== peg$FAILED) {
603
+ s4 = peg$parse_();
604
+ if (input.charCodeAt(peg$currPos) === 41) {
605
+ s5 = peg$c5;
606
+ peg$currPos++;
607
+ } else {
608
+ s5 = peg$FAILED;
609
+ if (peg$silentFails === 0) { peg$fail(peg$e5); }
610
+ }
611
+ if (s5 !== peg$FAILED) {
612
+ peg$savedPos = s0;
613
+ s0 = peg$f4(s3);
614
+ } else {
615
+ peg$currPos = s0;
616
+ s0 = peg$FAILED;
617
+ }
618
+ } else {
619
+ peg$currPos = s0;
620
+ s0 = peg$FAILED;
621
+ }
622
+ } else {
623
+ peg$currPos = s0;
624
+ s0 = peg$FAILED;
625
+ }
626
+ }
627
+
628
+ return s0;
629
+ }
630
+
631
+ function peg$parseOperator() {
632
+ var s0;
633
+
634
+ if (input.charCodeAt(peg$currPos) === 61) {
635
+ s0 = peg$c6;
636
+ peg$currPos++;
637
+ } else {
638
+ s0 = peg$FAILED;
639
+ if (peg$silentFails === 0) { peg$fail(peg$e6); }
640
+ }
641
+ if (s0 === peg$FAILED) {
642
+ if (input.substr(peg$currPos, 2) === peg$c7) {
643
+ s0 = peg$c7;
644
+ peg$currPos += 2;
645
+ } else {
646
+ s0 = peg$FAILED;
647
+ if (peg$silentFails === 0) { peg$fail(peg$e7); }
648
+ }
649
+ if (s0 === peg$FAILED) {
650
+ if (input.charCodeAt(peg$currPos) === 58) {
651
+ s0 = peg$c8;
652
+ peg$currPos++;
653
+ } else {
654
+ s0 = peg$FAILED;
655
+ if (peg$silentFails === 0) { peg$fail(peg$e8); }
656
+ }
657
+ if (s0 === peg$FAILED) {
658
+ if (input.substr(peg$currPos, 2) === peg$c9) {
659
+ s0 = peg$c9;
660
+ peg$currPos += 2;
661
+ } else {
662
+ s0 = peg$FAILED;
663
+ if (peg$silentFails === 0) { peg$fail(peg$e9); }
664
+ }
665
+ if (s0 === peg$FAILED) {
666
+ if (input.charCodeAt(peg$currPos) === 62) {
667
+ s0 = peg$c10;
668
+ peg$currPos++;
669
+ } else {
670
+ s0 = peg$FAILED;
671
+ if (peg$silentFails === 0) { peg$fail(peg$e10); }
672
+ }
673
+ if (s0 === peg$FAILED) {
674
+ if (input.substr(peg$currPos, 2) === peg$c11) {
675
+ s0 = peg$c11;
676
+ peg$currPos += 2;
677
+ } else {
678
+ s0 = peg$FAILED;
679
+ if (peg$silentFails === 0) { peg$fail(peg$e11); }
680
+ }
681
+ if (s0 === peg$FAILED) {
682
+ if (input.charCodeAt(peg$currPos) === 60) {
683
+ s0 = peg$c12;
684
+ peg$currPos++;
685
+ } else {
686
+ s0 = peg$FAILED;
687
+ if (peg$silentFails === 0) { peg$fail(peg$e12); }
688
+ }
689
+ if (s0 === peg$FAILED) {
690
+ if (input.substr(peg$currPos, 2) === peg$c13) {
691
+ s0 = peg$c13;
692
+ peg$currPos += 2;
693
+ } else {
694
+ s0 = peg$FAILED;
695
+ if (peg$silentFails === 0) { peg$fail(peg$e13); }
696
+ }
697
+ }
698
+ }
699
+ }
700
+ }
701
+ }
702
+ }
703
+ }
704
+
705
+ return s0;
706
+ }
707
+
708
+ function peg$parseIdentifier() {
709
+ var s0, s1, s2;
710
+
711
+ s0 = peg$currPos;
712
+ s1 = [];
713
+ s2 = input.charAt(peg$currPos);
714
+ if (peg$r0.test(s2)) {
715
+ peg$currPos++;
716
+ } else {
717
+ s2 = peg$FAILED;
718
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
719
+ }
720
+ if (s2 !== peg$FAILED) {
721
+ while (s2 !== peg$FAILED) {
722
+ s1.push(s2);
723
+ s2 = input.charAt(peg$currPos);
724
+ if (peg$r0.test(s2)) {
725
+ peg$currPos++;
726
+ } else {
727
+ s2 = peg$FAILED;
728
+ if (peg$silentFails === 0) { peg$fail(peg$e14); }
729
+ }
730
+ }
731
+ } else {
732
+ s1 = peg$FAILED;
733
+ }
734
+ if (s1 !== peg$FAILED) {
735
+ peg$savedPos = s0;
736
+ s1 = peg$f5(s1);
737
+ }
738
+ s0 = s1;
739
+
740
+ return s0;
741
+ }
742
+
743
+ function peg$parseDotSegment() {
744
+ var s0, s1, s2;
745
+
746
+ s0 = peg$currPos;
747
+ if (input.charCodeAt(peg$currPos) === 46) {
748
+ s1 = peg$c14;
749
+ peg$currPos++;
750
+ } else {
751
+ s1 = peg$FAILED;
752
+ if (peg$silentFails === 0) { peg$fail(peg$e15); }
753
+ }
754
+ if (s1 !== peg$FAILED) {
755
+ s2 = peg$parseIdentifier();
756
+ if (s2 !== peg$FAILED) {
757
+ peg$savedPos = s0;
758
+ s0 = peg$f6(s2);
759
+ } else {
760
+ peg$currPos = s0;
761
+ s0 = peg$FAILED;
762
+ }
763
+ } else {
764
+ peg$currPos = s0;
765
+ s0 = peg$FAILED;
766
+ }
767
+
768
+ return s0;
769
+ }
770
+
771
+ function peg$parseKey() {
772
+ var s0, s1, s2, s3;
773
+
774
+ s0 = peg$currPos;
775
+ s1 = peg$parseIdentifier();
776
+ if (s1 !== peg$FAILED) {
777
+ s2 = [];
778
+ s3 = peg$parseDotSegment();
779
+ while (s3 !== peg$FAILED) {
780
+ s2.push(s3);
781
+ s3 = peg$parseDotSegment();
782
+ }
783
+ peg$savedPos = s0;
784
+ s0 = peg$f7(s1, s2);
785
+ } else {
786
+ peg$currPos = s0;
787
+ s0 = peg$FAILED;
788
+ }
789
+
790
+ return s0;
791
+ }
792
+
793
+ function peg$parseValue() {
794
+ var s0;
795
+
796
+ s0 = peg$parseIdentifier();
797
+ if (s0 === peg$FAILED) {
798
+ s0 = peg$parseInteger();
799
+ if (s0 === peg$FAILED) {
800
+ s0 = peg$parseString();
801
+ }
802
+ }
803
+
804
+ return s0;
805
+ }
806
+
807
+ function peg$parseInteger() {
808
+ var s0, s1, s2, s3;
809
+
810
+ peg$silentFails++;
811
+ s0 = peg$currPos;
812
+ s1 = peg$parse_();
813
+ s2 = [];
814
+ s3 = input.charAt(peg$currPos);
815
+ if (peg$r1.test(s3)) {
816
+ peg$currPos++;
817
+ } else {
818
+ s3 = peg$FAILED;
819
+ if (peg$silentFails === 0) { peg$fail(peg$e17); }
820
+ }
821
+ if (s3 !== peg$FAILED) {
822
+ while (s3 !== peg$FAILED) {
823
+ s2.push(s3);
824
+ s3 = input.charAt(peg$currPos);
825
+ if (peg$r1.test(s3)) {
826
+ peg$currPos++;
827
+ } else {
828
+ s3 = peg$FAILED;
829
+ if (peg$silentFails === 0) { peg$fail(peg$e17); }
830
+ }
831
+ }
832
+ } else {
833
+ s2 = peg$FAILED;
834
+ }
835
+ if (s2 !== peg$FAILED) {
836
+ peg$savedPos = s0;
837
+ s0 = peg$f8();
838
+ } else {
839
+ peg$currPos = s0;
840
+ s0 = peg$FAILED;
841
+ }
842
+ peg$silentFails--;
843
+ if (s0 === peg$FAILED) {
844
+ s1 = peg$FAILED;
845
+ if (peg$silentFails === 0) { peg$fail(peg$e16); }
846
+ }
847
+
848
+ return s0;
849
+ }
850
+
851
+ function peg$parseString() {
852
+ var s0, s1, s2, s3;
853
+
854
+ s0 = peg$currPos;
855
+ if (input.charCodeAt(peg$currPos) === 34) {
856
+ s1 = peg$c15;
857
+ peg$currPos++;
858
+ } else {
859
+ s1 = peg$FAILED;
860
+ if (peg$silentFails === 0) { peg$fail(peg$e18); }
861
+ }
862
+ if (s1 !== peg$FAILED) {
863
+ s2 = [];
864
+ s3 = input.charAt(peg$currPos);
865
+ if (peg$r2.test(s3)) {
866
+ peg$currPos++;
867
+ } else {
868
+ s3 = peg$FAILED;
869
+ if (peg$silentFails === 0) { peg$fail(peg$e19); }
870
+ }
871
+ while (s3 !== peg$FAILED) {
872
+ s2.push(s3);
873
+ s3 = input.charAt(peg$currPos);
874
+ if (peg$r2.test(s3)) {
875
+ peg$currPos++;
876
+ } else {
877
+ s3 = peg$FAILED;
878
+ if (peg$silentFails === 0) { peg$fail(peg$e19); }
879
+ }
880
+ }
881
+ if (input.charCodeAt(peg$currPos) === 34) {
882
+ s3 = peg$c15;
883
+ peg$currPos++;
884
+ } else {
885
+ s3 = peg$FAILED;
886
+ if (peg$silentFails === 0) { peg$fail(peg$e18); }
887
+ }
888
+ if (s3 !== peg$FAILED) {
889
+ peg$savedPos = s0;
890
+ s0 = peg$f9(s2);
891
+ } else {
892
+ peg$currPos = s0;
893
+ s0 = peg$FAILED;
894
+ }
895
+ } else {
896
+ peg$currPos = s0;
897
+ s0 = peg$FAILED;
898
+ }
899
+
900
+ return s0;
901
+ }
902
+
903
+ function peg$parse_() {
904
+ var s0, s1;
905
+
906
+ peg$silentFails++;
907
+ s0 = [];
908
+ s1 = input.charAt(peg$currPos);
909
+ if (peg$r3.test(s1)) {
910
+ peg$currPos++;
911
+ } else {
912
+ s1 = peg$FAILED;
913
+ if (peg$silentFails === 0) { peg$fail(peg$e21); }
914
+ }
915
+ while (s1 !== peg$FAILED) {
916
+ s0.push(s1);
917
+ s1 = input.charAt(peg$currPos);
918
+ if (peg$r3.test(s1)) {
919
+ peg$currPos++;
920
+ } else {
921
+ s1 = peg$FAILED;
922
+ if (peg$silentFails === 0) { peg$fail(peg$e21); }
923
+ }
924
+ }
925
+ peg$silentFails--;
926
+ s1 = peg$FAILED;
927
+ if (peg$silentFails === 0) { peg$fail(peg$e20); }
928
+
929
+ return s0;
930
+ }
931
+
932
+ peg$result = peg$startRuleFunction();
933
+
934
+ if (options.peg$library) {
935
+ return /** @type {any} */ ({
936
+ peg$result,
937
+ peg$currPos,
938
+ peg$FAILED,
939
+ peg$maxFailExpected,
940
+ peg$maxFailPos
941
+ });
942
+ }
943
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
944
+ return peg$result;
945
+ } else {
946
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
947
+ peg$fail(peg$endExpectation());
948
+ }
949
+
950
+ throw peg$buildStructuredError(
951
+ peg$maxFailExpected,
952
+ peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
953
+ peg$maxFailPos < input.length
954
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
955
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
956
+ );
957
+ }
958
+ }
959
+
960
+ const peg$allowedStartRules = [
961
+ "Query"
962
+ ];
963
+
964
+ export {
965
+ peg$allowedStartRules as StartRules,
966
+ peg$SyntaxError as SyntaxError,
967
+ peg$parse as parse
968
+ };