state-machine-cat 10.1.8 → 10.1.10

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