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