hello-lights 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1065 @@
1
+ /*
2
+ * Generated by PEG.js 0.10.0.
3
+ *
4
+ * http://pegjs.org/
5
+ */
6
+
7
+ "use strict";
8
+
9
+ function peg$subclass(child, parent) {
10
+ function ctor() { this.constructor = child; }
11
+ ctor.prototype = parent.prototype;
12
+ child.prototype = new ctor();
13
+ }
14
+
15
+ function peg$SyntaxError(message, expected, found, location) {
16
+ this.message = message;
17
+ this.expected = expected;
18
+ this.found = found;
19
+ this.location = location;
20
+ this.name = "SyntaxError";
21
+
22
+ if (typeof Error.captureStackTrace === "function") {
23
+ Error.captureStackTrace(this, peg$SyntaxError);
24
+ }
25
+ }
26
+
27
+ peg$subclass(peg$SyntaxError, Error);
28
+
29
+ peg$SyntaxError.buildMessage = function(expected, found) {
30
+ var DESCRIBE_EXPECTATION_FNS = {
31
+ literal: function(expectation) {
32
+ return "\"" + literalEscape(expectation.text) + "\"";
33
+ },
34
+
35
+ "class": function(expectation) {
36
+ var escapedParts = "",
37
+ i;
38
+
39
+ for (i = 0; i < expectation.parts.length; i++) {
40
+ escapedParts += expectation.parts[i] instanceof Array
41
+ ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
42
+ : classEscape(expectation.parts[i]);
43
+ }
44
+
45
+ return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
46
+ },
47
+
48
+ any: function(expectation) {
49
+ return "any character";
50
+ },
51
+
52
+ end: function(expectation) {
53
+ return "end of input";
54
+ },
55
+
56
+ other: function(expectation) {
57
+ return expectation.description;
58
+ }
59
+ };
60
+
61
+ function hex(ch) {
62
+ return ch.charCodeAt(0).toString(16).toUpperCase();
63
+ }
64
+
65
+ function literalEscape(s) {
66
+ return s
67
+ .replace(/\\/g, '\\\\')
68
+ .replace(/"/g, '\\"')
69
+ .replace(/\0/g, '\\0')
70
+ .replace(/\t/g, '\\t')
71
+ .replace(/\n/g, '\\n')
72
+ .replace(/\r/g, '\\r')
73
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
74
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
75
+ }
76
+
77
+ function classEscape(s) {
78
+ return s
79
+ .replace(/\\/g, '\\\\')
80
+ .replace(/\]/g, '\\]')
81
+ .replace(/\^/g, '\\^')
82
+ .replace(/-/g, '\\-')
83
+ .replace(/\0/g, '\\0')
84
+ .replace(/\t/g, '\\t')
85
+ .replace(/\n/g, '\\n')
86
+ .replace(/\r/g, '\\r')
87
+ .replace(/[\x00-\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
88
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
89
+ }
90
+
91
+ function describeExpectation(expectation) {
92
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
93
+ }
94
+
95
+ function describeExpected(expected) {
96
+ var descriptions = new Array(expected.length),
97
+ i, j;
98
+
99
+ for (i = 0; i < expected.length; i++) {
100
+ descriptions[i] = describeExpectation(expected[i]);
101
+ }
102
+
103
+ descriptions.sort();
104
+
105
+ if (descriptions.length > 0) {
106
+ for (i = 1, j = 1; i < descriptions.length; i++) {
107
+ if (descriptions[i - 1] !== descriptions[i]) {
108
+ descriptions[j] = descriptions[i];
109
+ j++;
110
+ }
111
+ }
112
+ descriptions.length = j;
113
+ }
114
+
115
+ switch (descriptions.length) {
116
+ case 1:
117
+ return descriptions[0];
118
+
119
+ case 2:
120
+ return descriptions[0] + " or " + descriptions[1];
121
+
122
+ default:
123
+ return descriptions.slice(0, -1).join(", ")
124
+ + ", or "
125
+ + descriptions[descriptions.length - 1];
126
+ }
127
+ }
128
+
129
+ function describeFound(found) {
130
+ return found ? "\"" + literalEscape(found) + "\"" : "end of input";
131
+ }
132
+
133
+ return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
134
+ };
135
+
136
+ function peg$parse(input, options) {
137
+ options = options !== void 0 ? options : {};
138
+
139
+ var peg$FAILED = {},
140
+
141
+ peg$startRuleFunctions = { Start: peg$parseStart },
142
+ peg$startRuleFunction = peg$parseStart,
143
+
144
+ peg$c0 = function(filler1, command, filler2) {
145
+ return [
146
+ ...filler1,
147
+ ...command,
148
+ ...filler2
149
+ ];
150
+ },
151
+ peg$c1 = "(",
152
+ peg$c2 = peg$literalExpectation("(", false),
153
+ peg$c3 = ")",
154
+ peg$c4 = peg$literalExpectation(")", false),
155
+ peg$c5 = function(filler1, filler2, first, filler3, filler4, rest) {
156
+ return [
157
+ ...filler1,
158
+ { type: 'parens', text: '(' },
159
+ ...filler2,
160
+ ...first,
161
+ ...filler3,
162
+ { type: 'parens', text: ')' },
163
+ ...filler4,
164
+ ...flatten(rest || [])
165
+ ];
166
+ },
167
+ peg$c6 = function(name, args) {
168
+ return [
169
+ { type: 'command', text: name },
170
+ ...flatten(args || [])
171
+ ];
172
+ },
173
+ peg$c7 = function(filler, head, tail) {
174
+ return [
175
+ ...filler,
176
+ ...head,
177
+ ...flatten(tail || [])
178
+ ];
179
+ },
180
+ peg$c8 = function(text) { return [{ type: 'variable', text }]; },
181
+ peg$c9 = function(text) { return [{ type: 'identifier', text }]; },
182
+ peg$c10 = function(text) { return [{ type: 'number', text }]; },
183
+ peg$c11 = function(text) { return [{ type: 'string', text }]; },
184
+ peg$c12 = function(filler1, command, filler2) {
185
+ return [
186
+ { type: 'parens', text: '(' },
187
+ ...filler1,
188
+ ...command,
189
+ ...filler2,
190
+ { type: 'parens', text: ')' }
191
+ ]
192
+ },
193
+ peg$c13 = ":",
194
+ peg$c14 = peg$literalExpectation(":", false),
195
+ peg$c15 = function(name) { return ":" + name; },
196
+ peg$c16 = /^[a-z_]/i,
197
+ peg$c17 = peg$classExpectation([["a", "z"], "_"], false, true),
198
+ peg$c18 = /^[a-z_0-9\-]/i,
199
+ peg$c19 = peg$classExpectation([["a", "z"], "_", ["0", "9"], "-"], false, true),
200
+ peg$c20 = function(head, tail) { return head + tail.join(''); },
201
+ peg$c21 = /^[0-9]/,
202
+ peg$c22 = peg$classExpectation([["0", "9"]], false, false),
203
+ peg$c23 = function(digits) { return parseInt(digits.join(''), 10); },
204
+ peg$c24 = "\"",
205
+ peg$c25 = peg$literalExpectation("\"", false),
206
+ peg$c26 = function(contents) { return '"' + contents.join('') + '"'; },
207
+ peg$c27 = "\\",
208
+ peg$c28 = peg$literalExpectation("\\", false),
209
+ peg$c29 = peg$anyExpectation(),
210
+ peg$c30 = function(char) { return char; },
211
+ peg$c31 = /^[ \t\r\n]/,
212
+ peg$c32 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false),
213
+ peg$c33 = function(space) { return { type: 'space', text: space.join('') }; },
214
+ peg$c34 = ";",
215
+ peg$c35 = peg$literalExpectation(";", false),
216
+ peg$c36 = /^[^\r\n]/,
217
+ peg$c37 = peg$classExpectation(["\r", "\n"], true, false),
218
+ peg$c38 = /^[\r\n]/,
219
+ peg$c39 = peg$classExpectation(["\r", "\n"], false, false),
220
+ peg$c40 = function(comment, newline) { return { type: 'comment', text: ';' + comment.join('') + newline }; },
221
+ peg$c41 = function(comment) { return { type: 'comment', text: ';' + comment.join('') }; },
222
+
223
+ peg$currPos = 0,
224
+ peg$savedPos = 0,
225
+ peg$posDetailsCache = [{ line: 1, column: 1 }],
226
+ peg$maxFailPos = 0,
227
+ peg$maxFailExpected = [],
228
+ peg$silentFails = 0,
229
+
230
+ peg$result;
231
+
232
+ if ("startRule" in options) {
233
+ if (!(options.startRule in peg$startRuleFunctions)) {
234
+ throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
235
+ }
236
+
237
+ peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
238
+ }
239
+
240
+ function text() {
241
+ return input.substring(peg$savedPos, peg$currPos);
242
+ }
243
+
244
+ function location() {
245
+ return peg$computeLocation(peg$savedPos, peg$currPos);
246
+ }
247
+
248
+ function expected(description, location) {
249
+ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
250
+
251
+ throw peg$buildStructuredError(
252
+ [peg$otherExpectation(description)],
253
+ input.substring(peg$savedPos, peg$currPos),
254
+ location
255
+ );
256
+ }
257
+
258
+ function error(message, location) {
259
+ location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
260
+
261
+ throw peg$buildSimpleError(message, location);
262
+ }
263
+
264
+ function peg$literalExpectation(text, ignoreCase) {
265
+ return { type: "literal", text: text, ignoreCase: ignoreCase };
266
+ }
267
+
268
+ function peg$classExpectation(parts, inverted, ignoreCase) {
269
+ return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
270
+ }
271
+
272
+ function peg$anyExpectation() {
273
+ return { type: "any" };
274
+ }
275
+
276
+ function peg$endExpectation() {
277
+ return { type: "end" };
278
+ }
279
+
280
+ function peg$otherExpectation(description) {
281
+ return { type: "other", description: description };
282
+ }
283
+
284
+ function peg$computePosDetails(pos) {
285
+ var details = peg$posDetailsCache[pos], p;
286
+
287
+ if (details) {
288
+ return details;
289
+ } else {
290
+ p = pos - 1;
291
+ while (!peg$posDetailsCache[p]) {
292
+ p--;
293
+ }
294
+
295
+ details = peg$posDetailsCache[p];
296
+ details = {
297
+ line: details.line,
298
+ column: details.column
299
+ };
300
+
301
+ while (p < pos) {
302
+ if (input.charCodeAt(p) === 10) {
303
+ details.line++;
304
+ details.column = 1;
305
+ } else {
306
+ details.column++;
307
+ }
308
+
309
+ p++;
310
+ }
311
+
312
+ peg$posDetailsCache[pos] = details;
313
+ return details;
314
+ }
315
+ }
316
+
317
+ function peg$computeLocation(startPos, endPos) {
318
+ var startPosDetails = peg$computePosDetails(startPos),
319
+ endPosDetails = peg$computePosDetails(endPos);
320
+
321
+ return {
322
+ start: {
323
+ offset: startPos,
324
+ line: startPosDetails.line,
325
+ column: startPosDetails.column
326
+ },
327
+ end: {
328
+ offset: endPos,
329
+ line: endPosDetails.line,
330
+ column: endPosDetails.column
331
+ }
332
+ };
333
+ }
334
+
335
+ function peg$fail(expected) {
336
+ if (peg$currPos < peg$maxFailPos) { return; }
337
+
338
+ if (peg$currPos > peg$maxFailPos) {
339
+ peg$maxFailPos = peg$currPos;
340
+ peg$maxFailExpected = [];
341
+ }
342
+
343
+ peg$maxFailExpected.push(expected);
344
+ }
345
+
346
+ function peg$buildSimpleError(message, location) {
347
+ return new peg$SyntaxError(message, null, null, location);
348
+ }
349
+
350
+ function peg$buildStructuredError(expected, found, location) {
351
+ return new peg$SyntaxError(
352
+ peg$SyntaxError.buildMessage(expected, found),
353
+ expected,
354
+ found,
355
+ location
356
+ );
357
+ }
358
+
359
+ function peg$parseStart() {
360
+ var s0, s1, s2, s3;
361
+
362
+ s0 = peg$currPos;
363
+ s1 = peg$parse_();
364
+ if (s1 !== peg$FAILED) {
365
+ s2 = peg$parseCommand();
366
+ if (s2 !== peg$FAILED) {
367
+ s3 = peg$parse_();
368
+ if (s3 !== peg$FAILED) {
369
+ peg$savedPos = s0;
370
+ s1 = peg$c0(s1, s2, s3);
371
+ s0 = s1;
372
+ } else {
373
+ peg$currPos = s0;
374
+ s0 = peg$FAILED;
375
+ }
376
+ } else {
377
+ peg$currPos = s0;
378
+ s0 = peg$FAILED;
379
+ }
380
+ } else {
381
+ peg$currPos = s0;
382
+ s0 = peg$FAILED;
383
+ }
384
+ if (s0 === peg$FAILED) {
385
+ s0 = peg$parseCommands();
386
+ }
387
+
388
+ return s0;
389
+ }
390
+
391
+ function peg$parseCommands() {
392
+ var s0, s1, s2, s3, s4, s5, s6, s7, s8;
393
+
394
+ s0 = peg$currPos;
395
+ s1 = peg$parse_();
396
+ if (s1 !== peg$FAILED) {
397
+ if (input.charCodeAt(peg$currPos) === 40) {
398
+ s2 = peg$c1;
399
+ peg$currPos++;
400
+ } else {
401
+ s2 = peg$FAILED;
402
+ if (peg$silentFails === 0) { peg$fail(peg$c2); }
403
+ }
404
+ if (s2 !== peg$FAILED) {
405
+ s3 = peg$parse_();
406
+ if (s3 !== peg$FAILED) {
407
+ s4 = peg$parseCommand();
408
+ if (s4 !== peg$FAILED) {
409
+ s5 = peg$parse_();
410
+ if (s5 !== peg$FAILED) {
411
+ if (input.charCodeAt(peg$currPos) === 41) {
412
+ s6 = peg$c3;
413
+ peg$currPos++;
414
+ } else {
415
+ s6 = peg$FAILED;
416
+ if (peg$silentFails === 0) { peg$fail(peg$c4); }
417
+ }
418
+ if (s6 !== peg$FAILED) {
419
+ s7 = peg$parse_();
420
+ if (s7 !== peg$FAILED) {
421
+ s8 = peg$parseCommands();
422
+ if (s8 === peg$FAILED) {
423
+ s8 = null;
424
+ }
425
+ if (s8 !== peg$FAILED) {
426
+ peg$savedPos = s0;
427
+ s1 = peg$c5(s1, s3, s4, s5, s7, s8);
428
+ s0 = s1;
429
+ } else {
430
+ peg$currPos = s0;
431
+ s0 = peg$FAILED;
432
+ }
433
+ } else {
434
+ peg$currPos = s0;
435
+ s0 = peg$FAILED;
436
+ }
437
+ } else {
438
+ peg$currPos = s0;
439
+ s0 = peg$FAILED;
440
+ }
441
+ } else {
442
+ peg$currPos = s0;
443
+ s0 = peg$FAILED;
444
+ }
445
+ } else {
446
+ peg$currPos = s0;
447
+ s0 = peg$FAILED;
448
+ }
449
+ } else {
450
+ peg$currPos = s0;
451
+ s0 = peg$FAILED;
452
+ }
453
+ } else {
454
+ peg$currPos = s0;
455
+ s0 = peg$FAILED;
456
+ }
457
+ } else {
458
+ peg$currPos = s0;
459
+ s0 = peg$FAILED;
460
+ }
461
+
462
+ return s0;
463
+ }
464
+
465
+ function peg$parseCommand() {
466
+ var s0, s1, s2;
467
+
468
+ s0 = peg$currPos;
469
+ s1 = peg$parseIdentifier();
470
+ if (s1 !== peg$FAILED) {
471
+ s2 = peg$parseArguments();
472
+ if (s2 === peg$FAILED) {
473
+ s2 = null;
474
+ }
475
+ if (s2 !== peg$FAILED) {
476
+ peg$savedPos = s0;
477
+ s1 = peg$c6(s1, s2);
478
+ s0 = s1;
479
+ } else {
480
+ peg$currPos = s0;
481
+ s0 = peg$FAILED;
482
+ }
483
+ } else {
484
+ peg$currPos = s0;
485
+ s0 = peg$FAILED;
486
+ }
487
+
488
+ return s0;
489
+ }
490
+
491
+ function peg$parseArguments() {
492
+ var s0, s1, s2, s3;
493
+
494
+ s0 = peg$currPos;
495
+ s1 = peg$parse_();
496
+ if (s1 !== peg$FAILED) {
497
+ s2 = peg$parseArgument();
498
+ if (s2 !== peg$FAILED) {
499
+ s3 = peg$parseArguments();
500
+ if (s3 === peg$FAILED) {
501
+ s3 = null;
502
+ }
503
+ if (s3 !== peg$FAILED) {
504
+ peg$savedPos = s0;
505
+ s1 = peg$c7(s1, s2, s3);
506
+ s0 = s1;
507
+ } else {
508
+ peg$currPos = s0;
509
+ s0 = peg$FAILED;
510
+ }
511
+ } else {
512
+ peg$currPos = s0;
513
+ s0 = peg$FAILED;
514
+ }
515
+ } else {
516
+ peg$currPos = s0;
517
+ s0 = peg$FAILED;
518
+ }
519
+
520
+ return s0;
521
+ }
522
+
523
+ function peg$parseArgument() {
524
+ var s0, s1, s2, s3, s4, s5;
525
+
526
+ s0 = peg$currPos;
527
+ s1 = peg$parseVariable();
528
+ if (s1 !== peg$FAILED) {
529
+ peg$savedPos = s0;
530
+ s1 = peg$c8(s1);
531
+ }
532
+ s0 = s1;
533
+ if (s0 === peg$FAILED) {
534
+ s0 = peg$currPos;
535
+ s1 = peg$parseIdentifier();
536
+ if (s1 !== peg$FAILED) {
537
+ peg$savedPos = s0;
538
+ s1 = peg$c9(s1);
539
+ }
540
+ s0 = s1;
541
+ if (s0 === peg$FAILED) {
542
+ s0 = peg$currPos;
543
+ s1 = peg$parseNumber();
544
+ if (s1 !== peg$FAILED) {
545
+ peg$savedPos = s0;
546
+ s1 = peg$c10(s1);
547
+ }
548
+ s0 = s1;
549
+ if (s0 === peg$FAILED) {
550
+ s0 = peg$currPos;
551
+ s1 = peg$parseString();
552
+ if (s1 !== peg$FAILED) {
553
+ peg$savedPos = s0;
554
+ s1 = peg$c11(s1);
555
+ }
556
+ s0 = s1;
557
+ if (s0 === peg$FAILED) {
558
+ s0 = peg$currPos;
559
+ if (input.charCodeAt(peg$currPos) === 40) {
560
+ s1 = peg$c1;
561
+ peg$currPos++;
562
+ } else {
563
+ s1 = peg$FAILED;
564
+ if (peg$silentFails === 0) { peg$fail(peg$c2); }
565
+ }
566
+ if (s1 !== peg$FAILED) {
567
+ s2 = peg$parse_();
568
+ if (s2 !== peg$FAILED) {
569
+ s3 = peg$parseCommand();
570
+ if (s3 !== peg$FAILED) {
571
+ s4 = peg$parse_();
572
+ if (s4 !== peg$FAILED) {
573
+ if (input.charCodeAt(peg$currPos) === 41) {
574
+ s5 = peg$c3;
575
+ peg$currPos++;
576
+ } else {
577
+ s5 = peg$FAILED;
578
+ if (peg$silentFails === 0) { peg$fail(peg$c4); }
579
+ }
580
+ if (s5 !== peg$FAILED) {
581
+ peg$savedPos = s0;
582
+ s1 = peg$c12(s2, s3, s4);
583
+ s0 = s1;
584
+ } else {
585
+ peg$currPos = s0;
586
+ s0 = peg$FAILED;
587
+ }
588
+ } else {
589
+ peg$currPos = s0;
590
+ s0 = peg$FAILED;
591
+ }
592
+ } else {
593
+ peg$currPos = s0;
594
+ s0 = peg$FAILED;
595
+ }
596
+ } else {
597
+ peg$currPos = s0;
598
+ s0 = peg$FAILED;
599
+ }
600
+ } else {
601
+ peg$currPos = s0;
602
+ s0 = peg$FAILED;
603
+ }
604
+ }
605
+ }
606
+ }
607
+ }
608
+
609
+ return s0;
610
+ }
611
+
612
+ function peg$parseVariable() {
613
+ var s0, s1, s2;
614
+
615
+ s0 = peg$currPos;
616
+ if (input.charCodeAt(peg$currPos) === 58) {
617
+ s1 = peg$c13;
618
+ peg$currPos++;
619
+ } else {
620
+ s1 = peg$FAILED;
621
+ if (peg$silentFails === 0) { peg$fail(peg$c14); }
622
+ }
623
+ if (s1 !== peg$FAILED) {
624
+ s2 = peg$parseIdentifier();
625
+ if (s2 !== peg$FAILED) {
626
+ peg$savedPos = s0;
627
+ s1 = peg$c15(s2);
628
+ s0 = s1;
629
+ } else {
630
+ peg$currPos = s0;
631
+ s0 = peg$FAILED;
632
+ }
633
+ } else {
634
+ peg$currPos = s0;
635
+ s0 = peg$FAILED;
636
+ }
637
+
638
+ return s0;
639
+ }
640
+
641
+ function peg$parseIdentifier() {
642
+ var s0, s1, s2, s3;
643
+
644
+ s0 = peg$currPos;
645
+ if (peg$c16.test(input.charAt(peg$currPos))) {
646
+ s1 = input.charAt(peg$currPos);
647
+ peg$currPos++;
648
+ } else {
649
+ s1 = peg$FAILED;
650
+ if (peg$silentFails === 0) { peg$fail(peg$c17); }
651
+ }
652
+ if (s1 !== peg$FAILED) {
653
+ s2 = [];
654
+ if (peg$c18.test(input.charAt(peg$currPos))) {
655
+ s3 = input.charAt(peg$currPos);
656
+ peg$currPos++;
657
+ } else {
658
+ s3 = peg$FAILED;
659
+ if (peg$silentFails === 0) { peg$fail(peg$c19); }
660
+ }
661
+ while (s3 !== peg$FAILED) {
662
+ s2.push(s3);
663
+ if (peg$c18.test(input.charAt(peg$currPos))) {
664
+ s3 = input.charAt(peg$currPos);
665
+ peg$currPos++;
666
+ } else {
667
+ s3 = peg$FAILED;
668
+ if (peg$silentFails === 0) { peg$fail(peg$c19); }
669
+ }
670
+ }
671
+ if (s2 !== peg$FAILED) {
672
+ peg$savedPos = s0;
673
+ s1 = peg$c20(s1, s2);
674
+ s0 = s1;
675
+ } else {
676
+ peg$currPos = s0;
677
+ s0 = peg$FAILED;
678
+ }
679
+ } else {
680
+ peg$currPos = s0;
681
+ s0 = peg$FAILED;
682
+ }
683
+
684
+ return s0;
685
+ }
686
+
687
+ function peg$parseNumber() {
688
+ var s0, s1, s2;
689
+
690
+ s0 = peg$currPos;
691
+ s1 = [];
692
+ if (peg$c21.test(input.charAt(peg$currPos))) {
693
+ s2 = input.charAt(peg$currPos);
694
+ peg$currPos++;
695
+ } else {
696
+ s2 = peg$FAILED;
697
+ if (peg$silentFails === 0) { peg$fail(peg$c22); }
698
+ }
699
+ if (s2 !== peg$FAILED) {
700
+ while (s2 !== peg$FAILED) {
701
+ s1.push(s2);
702
+ if (peg$c21.test(input.charAt(peg$currPos))) {
703
+ s2 = input.charAt(peg$currPos);
704
+ peg$currPos++;
705
+ } else {
706
+ s2 = peg$FAILED;
707
+ if (peg$silentFails === 0) { peg$fail(peg$c22); }
708
+ }
709
+ }
710
+ } else {
711
+ s1 = peg$FAILED;
712
+ }
713
+ if (s1 !== peg$FAILED) {
714
+ peg$savedPos = s0;
715
+ s1 = peg$c23(s1);
716
+ }
717
+ s0 = s1;
718
+
719
+ return s0;
720
+ }
721
+
722
+ function peg$parseString() {
723
+ var s0, s1, s2, s3;
724
+
725
+ s0 = peg$currPos;
726
+ if (input.charCodeAt(peg$currPos) === 34) {
727
+ s1 = peg$c24;
728
+ peg$currPos++;
729
+ } else {
730
+ s1 = peg$FAILED;
731
+ if (peg$silentFails === 0) { peg$fail(peg$c25); }
732
+ }
733
+ if (s1 !== peg$FAILED) {
734
+ s2 = [];
735
+ s3 = peg$parseStringContents();
736
+ while (s3 !== peg$FAILED) {
737
+ s2.push(s3);
738
+ s3 = peg$parseStringContents();
739
+ }
740
+ if (s2 !== peg$FAILED) {
741
+ if (input.charCodeAt(peg$currPos) === 34) {
742
+ s3 = peg$c24;
743
+ peg$currPos++;
744
+ } else {
745
+ s3 = peg$FAILED;
746
+ if (peg$silentFails === 0) { peg$fail(peg$c25); }
747
+ }
748
+ if (s3 !== peg$FAILED) {
749
+ peg$savedPos = s0;
750
+ s1 = peg$c26(s2);
751
+ s0 = s1;
752
+ } else {
753
+ peg$currPos = s0;
754
+ s0 = peg$FAILED;
755
+ }
756
+ } else {
757
+ peg$currPos = s0;
758
+ s0 = peg$FAILED;
759
+ }
760
+ } else {
761
+ peg$currPos = s0;
762
+ s0 = peg$FAILED;
763
+ }
764
+
765
+ return s0;
766
+ }
767
+
768
+ function peg$parseStringContents() {
769
+ var s0, s1, s2;
770
+
771
+ s0 = peg$currPos;
772
+ s1 = peg$currPos;
773
+ peg$silentFails++;
774
+ if (input.charCodeAt(peg$currPos) === 34) {
775
+ s2 = peg$c24;
776
+ peg$currPos++;
777
+ } else {
778
+ s2 = peg$FAILED;
779
+ if (peg$silentFails === 0) { peg$fail(peg$c25); }
780
+ }
781
+ if (s2 === peg$FAILED) {
782
+ if (input.charCodeAt(peg$currPos) === 92) {
783
+ s2 = peg$c27;
784
+ peg$currPos++;
785
+ } else {
786
+ s2 = peg$FAILED;
787
+ if (peg$silentFails === 0) { peg$fail(peg$c28); }
788
+ }
789
+ }
790
+ peg$silentFails--;
791
+ if (s2 === peg$FAILED) {
792
+ s1 = void 0;
793
+ } else {
794
+ peg$currPos = s1;
795
+ s1 = peg$FAILED;
796
+ }
797
+ if (s1 !== peg$FAILED) {
798
+ if (input.length > peg$currPos) {
799
+ s2 = input.charAt(peg$currPos);
800
+ peg$currPos++;
801
+ } else {
802
+ s2 = peg$FAILED;
803
+ if (peg$silentFails === 0) { peg$fail(peg$c29); }
804
+ }
805
+ if (s2 !== peg$FAILED) {
806
+ peg$savedPos = s0;
807
+ s1 = peg$c30(s2);
808
+ s0 = s1;
809
+ } else {
810
+ peg$currPos = s0;
811
+ s0 = peg$FAILED;
812
+ }
813
+ } else {
814
+ peg$currPos = s0;
815
+ s0 = peg$FAILED;
816
+ }
817
+ if (s0 === peg$FAILED) {
818
+ s0 = peg$currPos;
819
+ if (input.charCodeAt(peg$currPos) === 92) {
820
+ s1 = peg$c27;
821
+ peg$currPos++;
822
+ } else {
823
+ s1 = peg$FAILED;
824
+ if (peg$silentFails === 0) { peg$fail(peg$c28); }
825
+ }
826
+ if (s1 !== peg$FAILED) {
827
+ s2 = peg$parseEscapeChar();
828
+ if (s2 !== peg$FAILED) {
829
+ peg$savedPos = s0;
830
+ s1 = peg$c30(s2);
831
+ s0 = s1;
832
+ } else {
833
+ peg$currPos = s0;
834
+ s0 = peg$FAILED;
835
+ }
836
+ } else {
837
+ peg$currPos = s0;
838
+ s0 = peg$FAILED;
839
+ }
840
+ }
841
+
842
+ return s0;
843
+ }
844
+
845
+ function peg$parseEscapeChar() {
846
+ var s0;
847
+
848
+ if (input.charCodeAt(peg$currPos) === 34) {
849
+ s0 = peg$c24;
850
+ peg$currPos++;
851
+ } else {
852
+ s0 = peg$FAILED;
853
+ if (peg$silentFails === 0) { peg$fail(peg$c25); }
854
+ }
855
+ if (s0 === peg$FAILED) {
856
+ if (input.charCodeAt(peg$currPos) === 92) {
857
+ s0 = peg$c27;
858
+ peg$currPos++;
859
+ } else {
860
+ s0 = peg$FAILED;
861
+ if (peg$silentFails === 0) { peg$fail(peg$c28); }
862
+ }
863
+ }
864
+
865
+ return s0;
866
+ }
867
+
868
+ function peg$parse_() {
869
+ var s0, s1;
870
+
871
+ s0 = [];
872
+ s1 = peg$parseFiller();
873
+ while (s1 !== peg$FAILED) {
874
+ s0.push(s1);
875
+ s1 = peg$parseFiller();
876
+ }
877
+
878
+ return s0;
879
+ }
880
+
881
+ function peg$parseFiller() {
882
+ var s0, s1, s2, s3;
883
+
884
+ s0 = peg$currPos;
885
+ s1 = [];
886
+ if (peg$c31.test(input.charAt(peg$currPos))) {
887
+ s2 = input.charAt(peg$currPos);
888
+ peg$currPos++;
889
+ } else {
890
+ s2 = peg$FAILED;
891
+ if (peg$silentFails === 0) { peg$fail(peg$c32); }
892
+ }
893
+ if (s2 !== peg$FAILED) {
894
+ while (s2 !== peg$FAILED) {
895
+ s1.push(s2);
896
+ if (peg$c31.test(input.charAt(peg$currPos))) {
897
+ s2 = input.charAt(peg$currPos);
898
+ peg$currPos++;
899
+ } else {
900
+ s2 = peg$FAILED;
901
+ if (peg$silentFails === 0) { peg$fail(peg$c32); }
902
+ }
903
+ }
904
+ } else {
905
+ s1 = peg$FAILED;
906
+ }
907
+ if (s1 !== peg$FAILED) {
908
+ peg$savedPos = s0;
909
+ s1 = peg$c33(s1);
910
+ }
911
+ s0 = s1;
912
+ if (s0 === peg$FAILED) {
913
+ s0 = peg$currPos;
914
+ if (input.charCodeAt(peg$currPos) === 59) {
915
+ s1 = peg$c34;
916
+ peg$currPos++;
917
+ } else {
918
+ s1 = peg$FAILED;
919
+ if (peg$silentFails === 0) { peg$fail(peg$c35); }
920
+ }
921
+ if (s1 !== peg$FAILED) {
922
+ s2 = [];
923
+ if (peg$c36.test(input.charAt(peg$currPos))) {
924
+ s3 = input.charAt(peg$currPos);
925
+ peg$currPos++;
926
+ } else {
927
+ s3 = peg$FAILED;
928
+ if (peg$silentFails === 0) { peg$fail(peg$c37); }
929
+ }
930
+ while (s3 !== peg$FAILED) {
931
+ s2.push(s3);
932
+ if (peg$c36.test(input.charAt(peg$currPos))) {
933
+ s3 = input.charAt(peg$currPos);
934
+ peg$currPos++;
935
+ } else {
936
+ s3 = peg$FAILED;
937
+ if (peg$silentFails === 0) { peg$fail(peg$c37); }
938
+ }
939
+ }
940
+ if (s2 !== peg$FAILED) {
941
+ if (peg$c38.test(input.charAt(peg$currPos))) {
942
+ s3 = input.charAt(peg$currPos);
943
+ peg$currPos++;
944
+ } else {
945
+ s3 = peg$FAILED;
946
+ if (peg$silentFails === 0) { peg$fail(peg$c39); }
947
+ }
948
+ if (s3 !== peg$FAILED) {
949
+ peg$savedPos = s0;
950
+ s1 = peg$c40(s2, s3);
951
+ s0 = s1;
952
+ } else {
953
+ peg$currPos = s0;
954
+ s0 = peg$FAILED;
955
+ }
956
+ } else {
957
+ peg$currPos = s0;
958
+ s0 = peg$FAILED;
959
+ }
960
+ } else {
961
+ peg$currPos = s0;
962
+ s0 = peg$FAILED;
963
+ }
964
+ if (s0 === peg$FAILED) {
965
+ s0 = peg$currPos;
966
+ if (input.charCodeAt(peg$currPos) === 59) {
967
+ s1 = peg$c34;
968
+ peg$currPos++;
969
+ } else {
970
+ s1 = peg$FAILED;
971
+ if (peg$silentFails === 0) { peg$fail(peg$c35); }
972
+ }
973
+ if (s1 !== peg$FAILED) {
974
+ s2 = [];
975
+ if (peg$c36.test(input.charAt(peg$currPos))) {
976
+ s3 = input.charAt(peg$currPos);
977
+ peg$currPos++;
978
+ } else {
979
+ s3 = peg$FAILED;
980
+ if (peg$silentFails === 0) { peg$fail(peg$c37); }
981
+ }
982
+ while (s3 !== peg$FAILED) {
983
+ s2.push(s3);
984
+ if (peg$c36.test(input.charAt(peg$currPos))) {
985
+ s3 = input.charAt(peg$currPos);
986
+ peg$currPos++;
987
+ } else {
988
+ s3 = peg$FAILED;
989
+ if (peg$silentFails === 0) { peg$fail(peg$c37); }
990
+ }
991
+ }
992
+ if (s2 !== peg$FAILED) {
993
+ s3 = peg$parseEOF();
994
+ if (s3 !== peg$FAILED) {
995
+ peg$savedPos = s0;
996
+ s1 = peg$c41(s2);
997
+ s0 = s1;
998
+ } else {
999
+ peg$currPos = s0;
1000
+ s0 = peg$FAILED;
1001
+ }
1002
+ } else {
1003
+ peg$currPos = s0;
1004
+ s0 = peg$FAILED;
1005
+ }
1006
+ } else {
1007
+ peg$currPos = s0;
1008
+ s0 = peg$FAILED;
1009
+ }
1010
+ }
1011
+ }
1012
+
1013
+ return s0;
1014
+ }
1015
+
1016
+ function peg$parseEOF() {
1017
+ var s0, s1;
1018
+
1019
+ s0 = peg$currPos;
1020
+ peg$silentFails++;
1021
+ if (input.length > peg$currPos) {
1022
+ s1 = input.charAt(peg$currPos);
1023
+ peg$currPos++;
1024
+ } else {
1025
+ s1 = peg$FAILED;
1026
+ if (peg$silentFails === 0) { peg$fail(peg$c29); }
1027
+ }
1028
+ peg$silentFails--;
1029
+ if (s1 === peg$FAILED) {
1030
+ s0 = void 0;
1031
+ } else {
1032
+ peg$currPos = s0;
1033
+ s0 = peg$FAILED;
1034
+ }
1035
+
1036
+ return s0;
1037
+ }
1038
+
1039
+
1040
+ const flatten = arr => arr.reduce((acc, val) => acc.concat(val), []);
1041
+
1042
+
1043
+ peg$result = peg$startRuleFunction();
1044
+
1045
+ if (peg$result !== peg$FAILED && peg$currPos === input.length) {
1046
+ return peg$result;
1047
+ } else {
1048
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1049
+ peg$fail(peg$endExpectation());
1050
+ }
1051
+
1052
+ throw peg$buildStructuredError(
1053
+ peg$maxFailExpected,
1054
+ peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
1055
+ peg$maxFailPos < input.length
1056
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1057
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
1058
+ );
1059
+ }
1060
+ }
1061
+
1062
+ module.exports = {
1063
+ SyntaxError: peg$SyntaxError,
1064
+ parse: peg$parse
1065
+ };