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