state-machine-cat 12.0.21 → 12.0.23

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,243 +1,241 @@
1
- function peg$subclass(child, parent) {
2
- function C() {
3
- this.constructor = child;
4
- }
5
- C.prototype = parent.prototype;
6
- child.prototype = new C();
7
- }
8
- function peg$SyntaxError(message, expected, found, location) {
9
- var self = Error.call(this, message);
10
- if (Object.setPrototypeOf) {
11
- Object.setPrototypeOf(self, peg$SyntaxError.prototype);
12
- }
13
- self.expected = expected;
14
- self.found = found;
15
- self.location = location;
16
- self.name = "SyntaxError";
17
- return self;
18
- }
19
- peg$subclass(peg$SyntaxError, Error);
20
- function peg$padEnd(str, targetLength, padString) {
21
- padString = padString || " ";
22
- if (str.length > targetLength) {
1
+ class peg$SyntaxError extends SyntaxError {
2
+ constructor(message, expected, found, location) {
3
+ super(message);
4
+ this.expected = expected;
5
+ this.found = found;
6
+ this.location = location;
7
+ this.name = "SyntaxError";
8
+ }
9
+ format(sources) {
10
+ let str = "Error: " + this.message;
11
+ if (this.location) {
12
+ let src = null;
13
+ const st = sources.find((s) => s.source === this.location.source);
14
+ if (st) {
15
+ src = st.text.split(/\r\n|\n|\r/g);
16
+ }
17
+ const s = this.location.start;
18
+ const offset_s =
19
+ this.location.source &&
20
+ typeof this.location.source.offset === "function"
21
+ ? this.location.source.offset(s)
22
+ : s;
23
+ const loc =
24
+ this.location.source + ":" + offset_s.line + ":" + offset_s.column;
25
+ if (src) {
26
+ const e = this.location.end;
27
+ const filler = "".padEnd(offset_s.line.toString().length, " ");
28
+ const line = src[s.line - 1];
29
+ const last = s.line === e.line ? e.column : line.length + 1;
30
+ const hatLen = last - s.column || 1;
31
+ str +=
32
+ "\n --> " +
33
+ loc +
34
+ "\n" +
35
+ filler +
36
+ " |\n" +
37
+ offset_s.line +
38
+ " | " +
39
+ line +
40
+ "\n" +
41
+ filler +
42
+ " | " +
43
+ "".padEnd(s.column - 1, " ") +
44
+ "".padEnd(hatLen, "^");
45
+ } else {
46
+ str += "\n at " + loc;
47
+ }
48
+ }
23
49
  return str;
24
50
  }
25
- targetLength -= str.length;
26
- padString += padString.repeat(targetLength);
27
- return str + padString.slice(0, targetLength);
28
- }
29
- peg$SyntaxError.prototype.format = function (sources) {
30
- var str = "Error: " + this.message;
31
- if (this.location) {
32
- var src = null;
33
- var k;
34
- for (k = 0; k < sources.length; k++) {
35
- if (sources[k].source === this.location.source) {
36
- src = sources[k].text.split(/\r\n|\n|\r/g);
37
- break;
38
- }
39
- }
40
- var s = this.location.start;
41
- var offset_s =
42
- this.location.source && typeof this.location.source.offset === "function"
43
- ? this.location.source.offset(s)
44
- : s;
45
- var loc =
46
- this.location.source + ":" + offset_s.line + ":" + offset_s.column;
47
- if (src) {
48
- var e = this.location.end;
49
- var filler = peg$padEnd("", offset_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 +=
54
- "\n --> " +
55
- loc +
56
- "\n" +
57
- filler +
58
- " |\n" +
59
- offset_s.line +
60
- " | " +
61
- line +
62
- "\n" +
63
- filler +
64
- " | " +
65
- peg$padEnd("", s.column - 1, " ") +
66
- peg$padEnd("", hatLen, "^");
67
- } else {
68
- str += "\n at " + loc;
51
+ static buildMessage(expected, found) {
52
+ function hex(ch) {
53
+ return ch.codePointAt(0).toString(16).toUpperCase();
54
+ }
55
+ const nonPrintable = Object.prototype.hasOwnProperty.call(
56
+ RegExp.prototype,
57
+ "unicode",
58
+ )
59
+ ? new RegExp("[\\p{C}\\p{Mn}\\p{Mc}]", "gu")
60
+ : null;
61
+ function unicodeEscape(s) {
62
+ if (nonPrintable) {
63
+ return s.replace(nonPrintable, (ch) => "\\u{" + hex(ch) + "}");
64
+ }
65
+ return s;
66
+ }
67
+ function literalEscape(s) {
68
+ return unicodeEscape(
69
+ s
70
+ .replace(/\\/g, "\\\\")
71
+ .replace(/"/g, '\\"')
72
+ .replace(/\0/g, "\\0")
73
+ .replace(/\t/g, "\\t")
74
+ .replace(/\n/g, "\\n")
75
+ .replace(/\r/g, "\\r")
76
+ .replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch))
77
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch)),
78
+ );
69
79
  }
70
- }
71
- return str;
72
- };
73
- peg$SyntaxError.buildMessage = function (expected, found) {
74
- var DESCRIBE_EXPECTATION_FNS = {
75
- literal: function (expectation) {
76
- return '"' + literalEscape(expectation.text) + '"';
77
- },
78
- class: function (expectation) {
79
- var escapedParts = expectation.parts.map(function (part) {
80
- return Array.isArray(part)
81
- ? classEscape(part[0]) + "-" + classEscape(part[1])
82
- : classEscape(part);
83
- });
84
- return (
85
- "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"
80
+ function classEscape(s) {
81
+ return unicodeEscape(
82
+ s
83
+ .replace(/\\/g, "\\\\")
84
+ .replace(/\]/g, "\\]")
85
+ .replace(/\^/g, "\\^")
86
+ .replace(/-/g, "\\-")
87
+ .replace(/\0/g, "\\0")
88
+ .replace(/\t/g, "\\t")
89
+ .replace(/\n/g, "\\n")
90
+ .replace(/\r/g, "\\r")
91
+ .replace(/[\x00-\x0F]/g, (ch) => "\\x0" + hex(ch))
92
+ .replace(/[\x10-\x1F\x7F-\x9F]/g, (ch) => "\\x" + hex(ch)),
86
93
  );
87
- },
88
- any: function () {
89
- return "any character";
90
- },
91
- end: function () {
92
- return "end of input";
93
- },
94
- other: function (expectation) {
95
- return expectation.description;
96
- },
97
- };
98
- function hex(ch) {
99
- return ch.charCodeAt(0).toString(16).toUpperCase();
100
- }
101
- function literalEscape(s) {
102
- return s
103
- .replace(/\\/g, "\\\\")
104
- .replace(/"/g, '\\"')
105
- .replace(/\0/g, "\\0")
106
- .replace(/\t/g, "\\t")
107
- .replace(/\n/g, "\\n")
108
- .replace(/\r/g, "\\r")
109
- .replace(/[\x00-\x0F]/g, function (ch) {
110
- return "\\x0" + hex(ch);
111
- })
112
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
113
- 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) {
127
- return "\\x0" + hex(ch);
128
- })
129
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
130
- return "\\x" + hex(ch);
131
- });
132
- }
133
- function describeExpectation(expectation) {
134
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
135
- }
136
- function describeExpected(expected) {
137
- var descriptions = expected.map(describeExpectation);
138
- var i, j;
139
- descriptions.sort();
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
94
  }
149
- switch (descriptions.length) {
150
- case 1:
151
- return descriptions[0];
152
- case 2:
153
- return descriptions[0] + " or " + descriptions[1];
154
- default:
95
+ const DESCRIBE_EXPECTATION_FNS = {
96
+ literal(expectation) {
97
+ return '"' + literalEscape(expectation.text) + '"';
98
+ },
99
+ class(expectation) {
100
+ const escapedParts = expectation.parts.map((part) =>
101
+ Array.isArray(part)
102
+ ? classEscape(part[0]) + "-" + classEscape(part[1])
103
+ : classEscape(part),
104
+ );
155
105
  return (
156
- descriptions.slice(0, -1).join(", ") +
157
- ", or " +
158
- descriptions[descriptions.length - 1]
106
+ "[" +
107
+ (expectation.inverted ? "^" : "") +
108
+ escapedParts.join("") +
109
+ "]" +
110
+ (expectation.unicode ? "u" : "")
159
111
  );
160
- }
161
- }
162
- function describeFound(found) {
163
- return found ? '"' + literalEscape(found) + '"' : "end of input";
112
+ },
113
+ any() {
114
+ return "any character";
115
+ },
116
+ end() {
117
+ return "end of input";
118
+ },
119
+ other(expectation) {
120
+ return expectation.description;
121
+ },
122
+ };
123
+ function describeExpectation(expectation) {
124
+ return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
125
+ }
126
+ function describeExpected(expected) {
127
+ const descriptions = expected.map(describeExpectation);
128
+ descriptions.sort();
129
+ if (descriptions.length > 0) {
130
+ let j = 1;
131
+ for (let i = 1; i < descriptions.length; i++) {
132
+ if (descriptions[i - 1] !== descriptions[i]) {
133
+ descriptions[j] = descriptions[i];
134
+ j++;
135
+ }
136
+ }
137
+ descriptions.length = j;
138
+ }
139
+ switch (descriptions.length) {
140
+ case 1:
141
+ return descriptions[0];
142
+ case 2:
143
+ return descriptions[0] + " or " + descriptions[1];
144
+ default:
145
+ return (
146
+ descriptions.slice(0, -1).join(", ") +
147
+ ", or " +
148
+ descriptions[descriptions.length - 1]
149
+ );
150
+ }
151
+ }
152
+ function describeFound(found) {
153
+ return found ? '"' + literalEscape(found) + '"' : "end of input";
154
+ }
155
+ return (
156
+ "Expected " +
157
+ describeExpected(expected) +
158
+ " but " +
159
+ describeFound(found) +
160
+ " found."
161
+ );
164
162
  }
165
- return (
166
- "Expected " +
167
- describeExpected(expected) +
168
- " but " +
169
- describeFound(found) +
170
- " found."
171
- );
172
- };
163
+ }
173
164
  function peg$parse(input, options) {
174
165
  options = options !== undefined ? options : {};
175
- var peg$FAILED = {};
176
- var peg$source = options.grammarSource;
177
- var peg$startRuleFunctions = { properties: peg$parseproperties };
178
- var peg$startRuleFunction = peg$parseproperties;
179
- var peg$c0 = "=";
180
- var peg$c1 = '"';
181
- var peg$c2 = '\\"';
182
- var peg$c3 = "true";
183
- var peg$c4 = "false";
184
- var peg$c5 = ".";
185
- var peg$r0 = /^[\t-\n\r =]/;
186
- var peg$r1 = /^[0-9]/;
187
- var peg$r2 = /^[ \t\n\r]/;
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$classExpectation(
166
+ const peg$FAILED = {};
167
+ const peg$source = options.grammarSource;
168
+ const peg$startRuleFunctions = {
169
+ properties: peg$parseproperties,
170
+ };
171
+ let peg$startRuleFunction = peg$parseproperties;
172
+ const peg$c0 = "=";
173
+ const peg$c1 = '"';
174
+ const peg$c2 = '\\"';
175
+ const peg$c3 = "true";
176
+ const peg$c4 = "false";
177
+ const peg$c5 = ".";
178
+ const peg$r0 = /^[\t-\n\r =]/;
179
+ const peg$r1 = /^[0-9]/;
180
+ const peg$r2 = /^[ \t\n\r]/;
181
+ const peg$e0 = peg$otherExpectation("name value pair");
182
+ const peg$e1 = peg$literalExpectation("=", false);
183
+ const peg$e2 = peg$otherExpectation("valid value");
184
+ const peg$e3 = peg$otherExpectation("a quoted or unquoted string");
185
+ const peg$e4 = peg$otherExpectation("double quoted string");
186
+ const peg$e5 = peg$literalExpectation('"', false);
187
+ const peg$e6 = peg$literalExpectation('\\"', false);
188
+ const peg$e7 = peg$anyExpectation();
189
+ const peg$e8 = peg$classExpectation(
197
190
  [["\t", "\n"], "\r", " ", "="],
198
191
  false,
199
192
  false,
193
+ false,
200
194
  );
201
- var peg$e9 = peg$otherExpectation("boolean");
202
- var peg$e10 = peg$literalExpectation("true", false);
203
- var peg$e11 = peg$literalExpectation("false", false);
204
- var peg$e12 = peg$otherExpectation("integer");
205
- var peg$e13 = peg$classExpectation([["0", "9"]], false, false);
206
- var peg$e14 = peg$otherExpectation("number");
207
- var peg$e15 = peg$literalExpectation(".", false);
208
- var peg$e16 = peg$otherExpectation("whitespace");
209
- var peg$e17 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false);
210
- var peg$f0 = function (name, value) {
195
+ const peg$e9 = peg$otherExpectation("boolean");
196
+ const peg$e10 = peg$literalExpectation("true", false);
197
+ const peg$e11 = peg$literalExpectation("false", false);
198
+ const peg$e12 = peg$otherExpectation("integer");
199
+ const peg$e13 = peg$classExpectation([["0", "9"]], false, false, false);
200
+ const peg$e14 = peg$otherExpectation("number");
201
+ const peg$e15 = peg$literalExpectation(".", false);
202
+ const peg$e16 = peg$classExpectation(
203
+ [" ", "\t", "\n", "\r"],
204
+ false,
205
+ false,
206
+ false,
207
+ );
208
+ function peg$f0(name, value) {
211
209
  return { name, value };
212
- };
213
- var peg$f1 = function (s) {
210
+ }
211
+ function peg$f1(s) {
214
212
  return s.join("");
215
- };
216
- var peg$f2 = function (c) {
213
+ }
214
+ function peg$f2(c) {
217
215
  return c;
218
- };
219
- var peg$f3 = function (s) {
216
+ }
217
+ function peg$f3(s) {
220
218
  return text();
221
- };
222
- var peg$f4 = function (c) {
219
+ }
220
+ function peg$f4(c) {
223
221
  return c;
224
- };
225
- var peg$f5 = function (bool) {
222
+ }
223
+ function peg$f5(bool) {
226
224
  return bool === "true";
227
- };
228
- var peg$f6 = function () {
225
+ }
226
+ function peg$f6() {
229
227
  return parseInt(text(), 10);
230
- };
231
- var peg$f7 = function () {
228
+ }
229
+ function peg$f7() {
232
230
  return parseFloat(text());
233
- };
234
- var peg$currPos = options.peg$currPos | 0;
235
- var peg$savedPos = peg$currPos;
236
- var peg$posDetailsCache = [{ line: 1, column: 1 }];
237
- var peg$maxFailPos = peg$currPos;
238
- var peg$maxFailExpected = options.peg$maxFailExpected || [];
239
- var peg$silentFails = options.peg$silentFails | 0;
240
- var peg$result;
231
+ }
232
+ let peg$currPos = options.peg$currPos | 0;
233
+ let peg$savedPos = peg$currPos;
234
+ const peg$posDetailsCache = [{ line: 1, column: 1 }];
235
+ let peg$maxFailPos = peg$currPos;
236
+ let peg$maxFailExpected = options.peg$maxFailExpected || [];
237
+ let peg$silentFails = options.peg$silentFails | 0;
238
+ let peg$result;
241
239
  if (options.startRule) {
242
240
  if (!(options.startRule in peg$startRuleFunctions)) {
243
241
  throw new Error(
@@ -280,16 +278,18 @@ function peg$parse(input, options) {
280
278
  : peg$computeLocation(peg$savedPos, peg$currPos);
281
279
  throw peg$buildSimpleError(message, location);
282
280
  }
281
+ function peg$getUnicode(pos = peg$currPos) {
282
+ const cp = input.codePointAt(pos);
283
+ if (cp === undefined) {
284
+ return "";
285
+ }
286
+ return String.fromCodePoint(cp);
287
+ }
283
288
  function peg$literalExpectation(text, ignoreCase) {
284
- return { type: "literal", text: text, ignoreCase: ignoreCase };
289
+ return { type: "literal", text, ignoreCase };
285
290
  }
286
- function peg$classExpectation(parts, inverted, ignoreCase) {
287
- return {
288
- type: "class",
289
- parts: parts,
290
- inverted: inverted,
291
- ignoreCase: ignoreCase,
292
- };
291
+ function peg$classExpectation(parts, inverted, ignoreCase, unicode) {
292
+ return { type: "class", parts, inverted, ignoreCase, unicode };
293
293
  }
294
294
  function peg$anyExpectation() {
295
295
  return { type: "any" };
@@ -298,11 +298,11 @@ function peg$parse(input, options) {
298
298
  return { type: "end" };
299
299
  }
300
300
  function peg$otherExpectation(description) {
301
- return { type: "other", description: description };
301
+ return { type: "other", description };
302
302
  }
303
303
  function peg$computePosDetails(pos) {
304
- var details = peg$posDetailsCache[pos];
305
- var p;
304
+ let details = peg$posDetailsCache[pos];
305
+ let p;
306
306
  if (details) {
307
307
  return details;
308
308
  } else {
@@ -331,9 +331,9 @@ function peg$parse(input, options) {
331
331
  }
332
332
  }
333
333
  function peg$computeLocation(startPos, endPos, offset) {
334
- var startPosDetails = peg$computePosDetails(startPos);
335
- var endPosDetails = peg$computePosDetails(endPos);
336
- var res = {
334
+ const startPosDetails = peg$computePosDetails(startPos);
335
+ const endPosDetails = peg$computePosDetails(endPos);
336
+ const res = {
337
337
  source: peg$source,
338
338
  start: {
339
339
  offset: startPos,
@@ -374,7 +374,7 @@ function peg$parse(input, options) {
374
374
  );
375
375
  }
376
376
  function peg$parseproperties() {
377
- var s0, s1;
377
+ let s0, s1;
378
378
  s0 = [];
379
379
  s1 = peg$parsenamevaluepair();
380
380
  if (s1 !== peg$FAILED) {
@@ -388,7 +388,7 @@ function peg$parse(input, options) {
388
388
  return s0;
389
389
  }
390
390
  function peg$parsenamevaluepair() {
391
- var s0, s1, s2, s3, s4, s5, s6, s7;
391
+ let s0, s1, s2, s3, s4, s5, s6, s7;
392
392
  peg$silentFails++;
393
393
  s0 = peg$currPos;
394
394
  s1 = peg$parse_();
@@ -433,7 +433,7 @@ function peg$parse(input, options) {
433
433
  return s0;
434
434
  }
435
435
  function peg$parseval() {
436
- var s0, s1;
436
+ let s0, s1;
437
437
  peg$silentFails++;
438
438
  s0 = peg$parsenumber();
439
439
  if (s0 === peg$FAILED) {
@@ -452,7 +452,7 @@ function peg$parse(input, options) {
452
452
  return s0;
453
453
  }
454
454
  function peg$parsestring() {
455
- var s0, s1;
455
+ let s0, s1;
456
456
  peg$silentFails++;
457
457
  s0 = peg$parsequotedstring();
458
458
  if (s0 === peg$FAILED) {
@@ -468,7 +468,7 @@ function peg$parse(input, options) {
468
468
  return s0;
469
469
  }
470
470
  function peg$parsequotedstring() {
471
- var s0, s1, s2, s3;
471
+ let s0, s1, s2, s3;
472
472
  peg$silentFails++;
473
473
  s0 = peg$currPos;
474
474
  if (input.charCodeAt(peg$currPos) === 34) {
@@ -517,7 +517,7 @@ function peg$parse(input, options) {
517
517
  return s0;
518
518
  }
519
519
  function peg$parsequotedstringcontent() {
520
- var s0, s1, s2, s3;
520
+ let s0, s1, s2, s3;
521
521
  s0 = [];
522
522
  s1 = peg$currPos;
523
523
  s2 = peg$currPos;
@@ -631,7 +631,7 @@ function peg$parse(input, options) {
631
631
  return s0;
632
632
  }
633
633
  function peg$parseunquotedstring() {
634
- var s0, s1;
634
+ let s0, s1;
635
635
  s0 = peg$currPos;
636
636
  s1 = peg$parseunquotedstringcontent();
637
637
  if (s1 !== peg$FAILED) {
@@ -642,7 +642,7 @@ function peg$parse(input, options) {
642
642
  return s0;
643
643
  }
644
644
  function peg$parseunquotedstringcontent() {
645
- var s0, s1, s2, s3;
645
+ let s0, s1, s2, s3;
646
646
  s0 = [];
647
647
  s1 = peg$currPos;
648
648
  s2 = peg$currPos;
@@ -734,7 +734,7 @@ function peg$parse(input, options) {
734
734
  return s0;
735
735
  }
736
736
  function peg$parseboolean() {
737
- var s0, s1;
737
+ let s0, s1;
738
738
  peg$silentFails++;
739
739
  s0 = peg$currPos;
740
740
  if (input.substr(peg$currPos, 4) === peg$c3) {
@@ -772,7 +772,7 @@ function peg$parse(input, options) {
772
772
  return s0;
773
773
  }
774
774
  function peg$parseinteger() {
775
- var s0, s1, s2;
775
+ let s0, s1, s2;
776
776
  peg$silentFails++;
777
777
  s0 = peg$currPos;
778
778
  s1 = [];
@@ -816,7 +816,7 @@ function peg$parse(input, options) {
816
816
  return s0;
817
817
  }
818
818
  function peg$parsenumber() {
819
- var s0, s1, s2, s3, s4;
819
+ let s0, s1, s2, s3, s4;
820
820
  peg$silentFails++;
821
821
  s0 = peg$currPos;
822
822
  s1 = peg$parseinteger();
@@ -863,7 +863,7 @@ function peg$parse(input, options) {
863
863
  return s0;
864
864
  }
865
865
  function peg$parse_() {
866
- var s0, s1;
866
+ let s0, s1;
867
867
  peg$silentFails++;
868
868
  s0 = [];
869
869
  s1 = input.charAt(peg$currPos);
@@ -872,7 +872,7 @@ function peg$parse(input, options) {
872
872
  } else {
873
873
  s1 = peg$FAILED;
874
874
  if (peg$silentFails === 0) {
875
- peg$fail(peg$e17);
875
+ peg$fail(peg$e16);
876
876
  }
877
877
  }
878
878
  while (s1 !== peg$FAILED) {
@@ -883,18 +883,27 @@ function peg$parse(input, options) {
883
883
  } else {
884
884
  s1 = peg$FAILED;
885
885
  if (peg$silentFails === 0) {
886
- peg$fail(peg$e17);
886
+ peg$fail(peg$e16);
887
887
  }
888
888
  }
889
889
  }
890
890
  peg$silentFails--;
891
- s1 = peg$FAILED;
892
- if (peg$silentFails === 0) {
893
- peg$fail(peg$e16);
894
- }
895
891
  return s0;
896
892
  }
897
893
  peg$result = peg$startRuleFunction();
894
+ const peg$success = peg$result !== peg$FAILED && peg$currPos === input.length;
895
+ function peg$throw() {
896
+ if (peg$result !== peg$FAILED && peg$currPos < input.length) {
897
+ peg$fail(peg$endExpectation());
898
+ }
899
+ throw peg$buildStructuredError(
900
+ peg$maxFailExpected,
901
+ peg$maxFailPos < input.length ? peg$getUnicode(peg$maxFailPos) : null,
902
+ peg$maxFailPos < input.length
903
+ ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
904
+ : peg$computeLocation(peg$maxFailPos, peg$maxFailPos),
905
+ );
906
+ }
898
907
  if (options.peg$library) {
899
908
  return {
900
909
  peg$result,
@@ -902,21 +911,14 @@ function peg$parse(input, options) {
902
911
  peg$FAILED,
903
912
  peg$maxFailExpected,
904
913
  peg$maxFailPos,
914
+ peg$success,
915
+ peg$throw: peg$success ? undefined : peg$throw,
905
916
  };
906
917
  }
907
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
918
+ if (peg$success) {
908
919
  return peg$result;
909
920
  } else {
910
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
911
- peg$fail(peg$endExpectation());
912
- }
913
- throw peg$buildStructuredError(
914
- peg$maxFailExpected,
915
- peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
916
- peg$maxFailPos < input.length
917
- ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
918
- : peg$computeLocation(peg$maxFailPos, peg$maxFailPos),
919
- );
921
+ peg$throw();
920
922
  }
921
923
  }
922
924
  const peg$allowedStartRules = ["properties"];