@ax-llm/ax 9.0.57 → 9.0.60

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.
Files changed (43) hide show
  1. package/ai/google-gemini/api.js +7 -4
  2. package/ai/google-gemini/api.js.map +1 -1
  3. package/ai/google-gemini/types.d.ts +6 -2
  4. package/ai/google-gemini/types.js +1 -1
  5. package/ai/google-gemini/types.js.map +1 -1
  6. package/cjs/ai/google-gemini/api.js +7 -4
  7. package/cjs/ai/google-gemini/api.js.map +1 -1
  8. package/cjs/ai/google-gemini/types.d.ts +6 -2
  9. package/cjs/ai/google-gemini/types.js +1 -1
  10. package/cjs/ai/google-gemini/types.js.map +1 -1
  11. package/cjs/dsp/datetime.d.ts +1 -0
  12. package/cjs/dsp/datetime.js +7 -0
  13. package/cjs/dsp/datetime.js.map +1 -1
  14. package/cjs/dsp/extract.js +7 -3
  15. package/cjs/dsp/extract.js.map +1 -1
  16. package/cjs/dsp/index.d.ts +1 -1
  17. package/cjs/dsp/parser.d.ts +33 -80
  18. package/cjs/dsp/parser.js +148 -1566
  19. package/cjs/dsp/parser.js.map +1 -1
  20. package/cjs/dsp/prompt.js +13 -2
  21. package/cjs/dsp/prompt.js.map +1 -1
  22. package/cjs/dsp/sig.d.ts +2 -1
  23. package/cjs/dsp/sig.js +7 -7
  24. package/cjs/dsp/sig.js.map +1 -1
  25. package/cjs/dsp/util.js +4 -0
  26. package/cjs/dsp/util.js.map +1 -1
  27. package/dsp/datetime.d.ts +1 -0
  28. package/dsp/datetime.js +5 -0
  29. package/dsp/datetime.js.map +1 -1
  30. package/dsp/extract.js +7 -3
  31. package/dsp/extract.js.map +1 -1
  32. package/dsp/index.d.ts +1 -1
  33. package/dsp/parser.d.ts +33 -80
  34. package/dsp/parser.js +147 -1565
  35. package/dsp/parser.js.map +1 -1
  36. package/dsp/prompt.js +13 -2
  37. package/dsp/prompt.js.map +1 -1
  38. package/dsp/sig.d.ts +2 -1
  39. package/dsp/sig.js +8 -8
  40. package/dsp/sig.js.map +1 -1
  41. package/dsp/util.js +4 -0
  42. package/dsp/util.js.map +1 -1
  43. package/package.json +1 -1
package/dsp/parser.js CHANGED
@@ -1,1584 +1,166 @@
1
- /* eslint-disable */
2
- const peggyParser = // Generated by Peggy 3.0.2.
3
-
4
- //
5
- // https://peggyjs.org/
6
- // @ts-ignore
7
- (function () {
8
- // @ts-ignore
9
- "use strict";
10
- // @ts-ignore
11
- function peg$subclass(child, parent) {
12
- // @ts-ignore
13
- function C() { this.constructor = child; }
14
- // @ts-ignore
15
- C.prototype = parent.prototype;
16
- // @ts-ignore
17
- child.prototype = new C();
1
+ class SignatureParser {
2
+ input;
3
+ position;
4
+ constructor(input) {
5
+ this.input = input;
6
+ this.position = 0;
18
7
  }
19
- // @ts-ignore
20
- function peg$SyntaxError(message, expected, found, location) {
21
- // @ts-ignore
22
- var self = Error.call(this, message);
23
- // istanbul ignore next Check is a necessary evil to support older environments
24
- // @ts-ignore
25
- if (Object.setPrototypeOf) {
26
- // @ts-ignore
27
- Object.setPrototypeOf(self, peg$SyntaxError.prototype);
28
- }
29
- // @ts-ignore
30
- self.expected = expected;
31
- // @ts-ignore
32
- self.found = found;
33
- // @ts-ignore
34
- self.location = location;
35
- // @ts-ignore
36
- self.name = "SyntaxError";
37
- // @ts-ignore
38
- return self;
8
+ parse() {
9
+ this.skipWhitespace();
10
+ const optionalDesc = this.parseParsedString();
11
+ this.skipWhitespace();
12
+ const inputs = this.parseInputParsedFieldList();
13
+ this.skipWhitespace();
14
+ this.expect('->');
15
+ this.skipWhitespace();
16
+ const outputs = this.parseOutputParsedFieldList();
17
+ return {
18
+ desc: optionalDesc?.trim(),
19
+ inputs,
20
+ outputs,
21
+ };
39
22
  }
40
- // @ts-ignore
41
- peg$subclass(peg$SyntaxError, Error);
42
- // @ts-ignore
43
- function peg$padEnd(str, targetLength, padString) {
44
- // @ts-ignore
45
- padString = padString || " ";
46
- // @ts-ignore
47
- if (str.length > targetLength) {
48
- return str;
49
- }
50
- // @ts-ignore
51
- targetLength -= str.length;
52
- // @ts-ignore
53
- padString += padString.repeat(targetLength);
54
- // @ts-ignore
55
- return str + padString.slice(0, targetLength);
23
+ parseInputParsedFieldList() {
24
+ const fields = [];
25
+ fields.push(this.parseInputParsedField());
26
+ while (this.match(',')) {
27
+ this.skipWhitespace();
28
+ fields.push(this.parseInputParsedField());
29
+ }
30
+ return fields;
56
31
  }
57
- // @ts-ignore
58
- peg$SyntaxError.prototype.format = function (sources) {
59
- // @ts-ignore
60
- var str = "Error: " + this.message;
61
- // @ts-ignore
62
- if (this.location) {
63
- // @ts-ignore
64
- var src = null;
65
- // @ts-ignore
66
- var k;
67
- // @ts-ignore
68
- for (k = 0; k < sources.length; k++) {
69
- // @ts-ignore
70
- if (sources[k].source === this.location.source) {
71
- // @ts-ignore
72
- src = sources[k].text.split(/\r\n|\n|\r/g);
73
- // @ts-ignore
74
- break;
75
- }
76
- }
77
- // @ts-ignore
78
- var s = this.location.start;
79
- // @ts-ignore
80
- var offset_s = (this.location.source && (typeof this.location.source.offset === "function"))
81
- // @ts-ignore
82
- ? this.location.source.offset(s)
83
- // @ts-ignore
84
- : s;
85
- // @ts-ignore
86
- var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
87
- // @ts-ignore
88
- if (src) {
89
- // @ts-ignore
90
- var e = this.location.end;
91
- // @ts-ignore
92
- var filler = peg$padEnd("", offset_s.line.toString().length, ' ');
93
- // @ts-ignore
94
- var line = src[s.line - 1];
95
- // @ts-ignore
96
- var last = s.line === e.line ? e.column : line.length + 1;
97
- // @ts-ignore
98
- var hatLen = (last - s.column) || 1;
99
- // @ts-ignore
100
- str += "\n --> " + loc + "\n"
101
- // @ts-ignore
102
- + filler + " |\n"
103
- // @ts-ignore
104
- + offset_s.line + " | " + line + "\n"
105
- // @ts-ignore
106
- + filler + " | " + peg$padEnd("", s.column - 1, ' ')
107
- // @ts-ignore
108
- + peg$padEnd("", hatLen, "^");
109
- // @ts-ignore
110
- }
111
- else {
112
- // @ts-ignore
113
- str += "\n at " + loc;
114
- }
115
- }
116
- // @ts-ignore
117
- return str;
118
- };
119
- // @ts-ignore
120
- peg$SyntaxError.buildMessage = function (expected, found) {
121
- // @ts-ignore
122
- var DESCRIBE_EXPECTATION_FNS = {
123
- // @ts-ignore
124
- literal: function (expectation) {
125
- // @ts-ignore
126
- return "\"" + literalEscape(expectation.text) + "\"";
127
- },
128
- // @ts-ignore
129
- class: function (expectation) {
130
- // @ts-ignore
131
- var escapedParts = expectation.parts.map(function (part) {
132
- // @ts-ignore
133
- return Array.isArray(part)
134
- // @ts-ignore
135
- ? classEscape(part[0]) + "-" + classEscape(part[1])
136
- // @ts-ignore
137
- : classEscape(part);
138
- });
139
- // @ts-ignore
140
- return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
141
- },
142
- // @ts-ignore
143
- any: function () {
144
- // @ts-ignore
145
- return "any character";
146
- },
147
- // @ts-ignore
148
- end: function () {
149
- // @ts-ignore
150
- return "end of input";
151
- },
152
- // @ts-ignore
153
- other: function (expectation) {
154
- // @ts-ignore
155
- return expectation.description;
156
- }
157
- };
158
- // @ts-ignore
159
- function hex(ch) {
160
- // @ts-ignore
161
- return ch.charCodeAt(0).toString(16).toUpperCase();
162
- }
163
- // @ts-ignore
164
- function literalEscape(s) {
165
- // @ts-ignore
166
- return s
167
- // @ts-ignore
168
- .replace(/\\/g, "\\\\")
169
- // @ts-ignore
170
- .replace(/"/g, "\\\"")
171
- // @ts-ignore
172
- .replace(/\0/g, "\\0")
173
- // @ts-ignore
174
- .replace(/\t/g, "\\t")
175
- // @ts-ignore
176
- .replace(/\n/g, "\\n")
177
- // @ts-ignore
178
- .replace(/\r/g, "\\r")
179
- // @ts-ignore
180
- .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
181
- // @ts-ignore
182
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
183
- }
184
- // @ts-ignore
185
- function classEscape(s) {
186
- // @ts-ignore
187
- return s
188
- // @ts-ignore
189
- .replace(/\\/g, "\\\\")
190
- // @ts-ignore
191
- .replace(/\]/g, "\\]")
192
- // @ts-ignore
193
- .replace(/\^/g, "\\^")
194
- // @ts-ignore
195
- .replace(/-/g, "\\-")
196
- // @ts-ignore
197
- .replace(/\0/g, "\\0")
198
- // @ts-ignore
199
- .replace(/\t/g, "\\t")
200
- // @ts-ignore
201
- .replace(/\n/g, "\\n")
202
- // @ts-ignore
203
- .replace(/\r/g, "\\r")
204
- // @ts-ignore
205
- .replace(/[\x00-\x0F]/g, function (ch) { return "\\x0" + hex(ch); })
206
- // @ts-ignore
207
- .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { return "\\x" + hex(ch); });
208
- }
209
- // @ts-ignore
210
- function describeExpectation(expectation) {
211
- // @ts-ignore
212
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
213
- }
214
- // @ts-ignore
215
- function describeExpected(expected) {
216
- // @ts-ignore
217
- var descriptions = expected.map(describeExpectation);
218
- // @ts-ignore
219
- var i, j;
220
- // @ts-ignore
221
- descriptions.sort();
222
- // @ts-ignore
223
- if (descriptions.length > 0) {
224
- // @ts-ignore
225
- for (i = 1, j = 1; i < descriptions.length; i++) {
226
- // @ts-ignore
227
- if (descriptions[i - 1] !== descriptions[i]) {
228
- // @ts-ignore
229
- descriptions[j] = descriptions[i];
230
- // @ts-ignore
231
- j++;
232
- }
233
- }
234
- // @ts-ignore
235
- descriptions.length = j;
236
- }
237
- // @ts-ignore
238
- switch (descriptions.length) {
239
- // @ts-ignore
240
- case 1:
241
- // @ts-ignore
242
- return descriptions[0];
243
- // @ts-ignore
244
- case 2:
245
- // @ts-ignore
246
- return descriptions[0] + " or " + descriptions[1];
247
- // @ts-ignore
248
- default:
249
- // @ts-ignore
250
- return descriptions.slice(0, -1).join(", ")
251
- // @ts-ignore
252
- + ", or "
253
- // @ts-ignore
254
- + descriptions[descriptions.length - 1];
255
- }
256
- }
257
- // @ts-ignore
258
- function describeFound(found) {
259
- // @ts-ignore
260
- return found ? "\"" + literalEscape(found) + "\"" : "end of input";
261
- }
262
- // @ts-ignore
263
- return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
264
- };
265
- // @ts-ignore
266
- function peg$parse(input, options) {
267
- // @ts-ignore
268
- options = options !== undefined ? options : {};
269
- // @ts-ignore
270
- var peg$FAILED = {};
271
- // @ts-ignore
272
- var peg$source = options.grammarSource;
273
- // @ts-ignore
274
- var peg$startRuleFunctions = { ParsedSignature: peg$parseParsedSignature };
275
- // @ts-ignore
276
- var peg$startRuleFunction = peg$parseParsedSignature;
277
- // @ts-ignore
278
- var peg$c0 = "->";
279
- var peg$c1 = ",";
280
- var peg$c2 = "?";
281
- var peg$c3 = ":";
282
- var peg$c4 = "[]";
283
- var peg$c5 = "string";
284
- var peg$c6 = "number";
285
- var peg$c7 = "boolean";
286
- var peg$c8 = "json";
287
- var peg$c9 = "image";
288
- var peg$c10 = "datetime";
289
- var peg$c11 = "date";
290
- var peg$c12 = "'";
291
- var peg$c13 = "\"";
292
- var peg$r0 = /^[a-zA-Z_0-9]/;
293
- var peg$r1 = /^[^']/;
294
- var peg$r2 = /^[^"]/;
295
- var peg$r3 = /^[ \t\r\n]/;
296
- var peg$e0 = peg$literalExpectation("->", false);
297
- var peg$e1 = peg$literalExpectation(",", false);
298
- var peg$e2 = peg$literalExpectation("?", false);
299
- var peg$e3 = peg$literalExpectation(":", false);
300
- var peg$e4 = peg$literalExpectation("[]", false);
301
- var peg$e5 = peg$literalExpectation("string", false);
302
- var peg$e6 = peg$literalExpectation("number", false);
303
- var peg$e7 = peg$literalExpectation("boolean", false);
304
- var peg$e8 = peg$literalExpectation("json", false);
305
- var peg$e9 = peg$literalExpectation("image", false);
306
- var peg$e10 = peg$literalExpectation("datetime", false);
307
- var peg$e11 = peg$literalExpectation("date", false);
308
- var peg$e12 = peg$classExpectation([["a", "z"], ["A", "Z"], "_", ["0", "9"]], false, false);
309
- var peg$e13 = peg$literalExpectation("'", false);
310
- var peg$e14 = peg$classExpectation(["'"], true, false);
311
- var peg$e15 = peg$literalExpectation("\"", false);
312
- var peg$e16 = peg$classExpectation(["\""], true, false);
313
- var peg$e17 = peg$classExpectation([" ", "\t", "\r", "\n"], false, false);
314
- // @ts-ignore
315
- var peg$f0 = function (optionalDesc, inputs, outputs) {
316
- // @ts-ignore
317
- return {
318
- // @ts-ignore
319
- desc: optionalDesc ? optionalDesc.join("").trim() : undefined,
320
- // @ts-ignore
321
- inputs,
322
- // @ts-ignore
323
- outputs
324
- };
325
- }; // @ts-ignore
326
- var peg$f1 = function (name, isOptional, optionalType, optionalDesc) {
327
- // @ts-ignore
328
- return {
329
- // @ts-ignore
330
- name,
331
- // @ts-ignore
332
- desc: optionalDesc ? optionalDesc.join("").trim() : undefined,
333
- // @ts-ignore
334
- type: optionalType ? optionalType.at(-1) : undefined,
335
- // @ts-ignore
336
- isOptional: isOptional ? true : undefined
337
- };
338
- }; // @ts-ignore
339
- var peg$f2 = function (type, isArray) {
340
- // @ts-ignore
341
- return { name: type, isArray: isArray ? true : false };
342
- }; // @ts-ignore
343
- var peg$f3 = function (chars) {
344
- // @ts-ignore
345
- return chars.join("");
346
- }; // @ts-ignore
347
- var peg$f4 = function (content) {
348
- return content.join("");
349
- }; // @ts-ignore
350
- var peg$f5 = function (content) {
351
- return content.join("");
352
- }; // @ts-ignore
353
- var peg$f6 = function () {
354
- // @ts-ignore
355
- return "";
356
- }; // @ts-ignore
357
- var peg$f7 = function () {
358
- // @ts-ignore
359
- return "";
32
+ parseOutputParsedFieldList() {
33
+ const fields = [];
34
+ fields.push(this.parseOutputParsedField());
35
+ while (this.match(',')) {
36
+ this.skipWhitespace();
37
+ fields.push(this.parseOutputParsedField());
38
+ }
39
+ return fields;
40
+ }
41
+ parseInputParsedField() {
42
+ this.skipWhitespace();
43
+ const name = this.parseParsedIdentifier();
44
+ const isOptional = this.match('?');
45
+ let type;
46
+ let desc;
47
+ if (this.match(':')) {
48
+ this.skipWhitespace();
49
+ const typeName = this.parseTypeNotClass();
50
+ const isArray = this.match('[]');
51
+ type = { name: typeName, isArray };
52
+ }
53
+ this.skipWhitespace();
54
+ desc = this.parseParsedString();
55
+ return {
56
+ name,
57
+ desc: desc?.trim(),
58
+ type,
59
+ isOptional,
360
60
  };
361
- // @ts-ignore
362
- var peg$currPos = 0;
363
- // @ts-ignore
364
- var peg$savedPos = 0;
365
- // @ts-ignore
366
- var peg$posDetailsCache = [{ line: 1, column: 1 }];
367
- // @ts-ignore
368
- var peg$maxFailPos = 0;
369
- // @ts-ignore
370
- var peg$maxFailExpected = [];
371
- // @ts-ignore
372
- var peg$silentFails = 0;
373
- // @ts-ignore
374
- var peg$resultsCache = {};
375
- // @ts-ignore
376
- var peg$result;
377
- // @ts-ignore
378
- if ("startRule" in options) {
379
- // @ts-ignore
380
- if (!(options.startRule in peg$startRuleFunctions)) {
381
- // @ts-ignore
382
- throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
383
- }
384
- // @ts-ignore
385
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
386
- }
387
- // @ts-ignore
388
- function text() {
389
- // @ts-ignore
390
- return input.substring(peg$savedPos, peg$currPos);
391
- }
392
- // @ts-ignore
393
- function offset() {
394
- // @ts-ignore
395
- return peg$savedPos;
396
- }
397
- // @ts-ignore
398
- function range() {
399
- // @ts-ignore
400
- return {
401
- // @ts-ignore
402
- source: peg$source,
403
- // @ts-ignore
404
- start: peg$savedPos,
405
- // @ts-ignore
406
- end: peg$currPos
407
- };
408
- }
409
- // @ts-ignore
410
- function location() {
411
- // @ts-ignore
412
- return peg$computeLocation(peg$savedPos, peg$currPos);
413
- }
414
- // @ts-ignore
415
- function expected(description, location) {
416
- // @ts-ignore
417
- location = location !== undefined
418
- // @ts-ignore
419
- ? location
420
- // @ts-ignore
421
- : peg$computeLocation(peg$savedPos, peg$currPos);
422
- // @ts-ignore
423
- throw peg$buildStructuredError(
424
- // @ts-ignore
425
- [peg$otherExpectation(description)],
426
- // @ts-ignore
427
- input.substring(peg$savedPos, peg$currPos),
428
- // @ts-ignore
429
- location);
430
- }
431
- // @ts-ignore
432
- function error(message, location) {
433
- // @ts-ignore
434
- location = location !== undefined
435
- // @ts-ignore
436
- ? location
437
- // @ts-ignore
438
- : peg$computeLocation(peg$savedPos, peg$currPos);
439
- // @ts-ignore
440
- throw peg$buildSimpleError(message, location);
441
- }
442
- // @ts-ignore
443
- function peg$literalExpectation(text, ignoreCase) {
444
- // @ts-ignore
445
- return { type: "literal", text: text, ignoreCase: ignoreCase };
446
- }
447
- // @ts-ignore
448
- function peg$classExpectation(parts, inverted, ignoreCase) {
449
- // @ts-ignore
450
- return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
451
- }
452
- // @ts-ignore
453
- function peg$anyExpectation() {
454
- // @ts-ignore
455
- return { type: "any" };
456
- }
457
- // @ts-ignore
458
- function peg$endExpectation() {
459
- // @ts-ignore
460
- return { type: "end" };
461
- }
462
- // @ts-ignore
463
- function peg$otherExpectation(description) {
464
- // @ts-ignore
465
- return { type: "other", description: description };
466
- }
467
- // @ts-ignore
468
- function peg$computePosDetails(pos) {
469
- // @ts-ignore
470
- var details = peg$posDetailsCache[pos];
471
- // @ts-ignore
472
- var p;
473
- // @ts-ignore
474
- if (details) {
475
- // @ts-ignore
476
- return details;
477
- // @ts-ignore
61
+ }
62
+ parseOutputParsedField() {
63
+ this.skipWhitespace();
64
+ const name = this.parseParsedIdentifier();
65
+ const isOptional = this.match('?');
66
+ this.skipWhitespace();
67
+ if (this.match(':')) {
68
+ this.skipWhitespace();
69
+ if (this.match('class')) {
70
+ const isArray = this.match('[]');
71
+ this.skipWhitespace();
72
+ const desc = this.parseParsedString();
73
+ if (!desc) {
74
+ throw new Error("Expected description containing class names after type 'class'");
75
+ }
76
+ const classNames = desc.split(',').map(s => s.trim());
77
+ return {
78
+ name,
79
+ type: { name: 'class', isArray, classes: classNames },
80
+ isOptional,
81
+ };
478
82
  }
479
83
  else {
480
- // @ts-ignore
481
- p = pos - 1;
482
- // @ts-ignore
483
- while (!peg$posDetailsCache[p]) {
484
- // @ts-ignore
485
- p--;
486
- }
487
- // @ts-ignore
488
- details = peg$posDetailsCache[p];
489
- // @ts-ignore
490
- details = {
491
- // @ts-ignore
492
- line: details.line,
493
- // @ts-ignore
494
- column: details.column
84
+ const typeName = this.parseTypeNotClass();
85
+ const isArray = this.match('[]');
86
+ this.skipWhitespace();
87
+ const desc = this.parseParsedString();
88
+ return {
89
+ name,
90
+ desc: desc?.trim(),
91
+ type: { name: typeName, isArray },
92
+ isOptional,
495
93
  };
496
- // @ts-ignore
497
- while (p < pos) {
498
- // @ts-ignore
499
- if (input.charCodeAt(p) === 10) {
500
- // @ts-ignore
501
- details.line++;
502
- // @ts-ignore
503
- details.column = 1;
504
- // @ts-ignore
505
- }
506
- else {
507
- // @ts-ignore
508
- details.column++;
509
- }
510
- // @ts-ignore
511
- p++;
512
- }
513
- // @ts-ignore
514
- peg$posDetailsCache[pos] = details;
515
- // @ts-ignore
516
- return details;
517
94
  }
518
95
  }
519
- // @ts-ignore
520
- function peg$computeLocation(startPos, endPos, offset) {
521
- // @ts-ignore
522
- var startPosDetails = peg$computePosDetails(startPos);
523
- // @ts-ignore
524
- var endPosDetails = peg$computePosDetails(endPos);
525
- // @ts-ignore
526
- var res = {
527
- // @ts-ignore
528
- source: peg$source,
529
- // @ts-ignore
530
- start: {
531
- // @ts-ignore
532
- offset: startPos,
533
- // @ts-ignore
534
- line: startPosDetails.line,
535
- // @ts-ignore
536
- column: startPosDetails.column
537
- },
538
- // @ts-ignore
539
- end: {
540
- // @ts-ignore
541
- offset: endPos,
542
- // @ts-ignore
543
- line: endPosDetails.line,
544
- // @ts-ignore
545
- column: endPosDetails.column
546
- }
96
+ else {
97
+ this.skipWhitespace();
98
+ const desc = this.parseParsedString();
99
+ return {
100
+ name,
101
+ desc: desc?.trim(),
102
+ type: undefined,
103
+ isOptional,
547
104
  };
548
- // @ts-ignore
549
- if (offset && peg$source && (typeof peg$source.offset === "function")) {
550
- // @ts-ignore
551
- res.start = peg$source.offset(res.start);
552
- // @ts-ignore
553
- res.end = peg$source.offset(res.end);
554
- }
555
- // @ts-ignore
556
- return res;
557
- }
558
- // @ts-ignore
559
- function peg$fail(expected) {
560
- // @ts-ignore
561
- if (peg$currPos < peg$maxFailPos) {
562
- return;
563
- }
564
- // @ts-ignore
565
- if (peg$currPos > peg$maxFailPos) {
566
- // @ts-ignore
567
- peg$maxFailPos = peg$currPos;
568
- // @ts-ignore
569
- peg$maxFailExpected = [];
570
- }
571
- // @ts-ignore
572
- peg$maxFailExpected.push(expected);
573
- }
574
- // @ts-ignore
575
- function peg$buildSimpleError(message, location) {
576
- // @ts-ignore
577
- return new peg$SyntaxError(message, null, null, location);
578
- }
579
- // @ts-ignore
580
- function peg$buildStructuredError(expected, found, location) {
581
- // @ts-ignore
582
- return new peg$SyntaxError(
583
- // @ts-ignore
584
- peg$SyntaxError.buildMessage(expected, found),
585
- // @ts-ignore
586
- expected,
587
- // @ts-ignore
588
- found,
589
- // @ts-ignore
590
- location);
591
- }
592
- // @ts-ignore
593
- function peg$parseParsedSignature() {
594
- // @ts-ignore
595
- var s0, s1, s2, s3, s4, s5, s6, s7;
596
- // @ts-ignore
597
- var key = peg$currPos * 9 + 0;
598
- // @ts-ignore
599
- var cached = peg$resultsCache[key];
600
- // @ts-ignore
601
- if (cached) {
602
- // @ts-ignore
603
- peg$currPos = cached.nextPos;
604
- // @ts-ignore
605
- return cached.result;
606
- }
607
- // @ts-ignore
608
- s0 = peg$currPos;
609
- // @ts-ignore
610
- s1 = peg$currPos;
611
- // @ts-ignore
612
- s2 = peg$parse_();
613
- // @ts-ignore
614
- s3 = peg$parseParsedString();
615
- // @ts-ignore
616
- if (s3 !== peg$FAILED) {
617
- // @ts-ignore
618
- s4 = peg$parse_();
619
- // @ts-ignore
620
- s2 = [s2, s3, s4];
621
- // @ts-ignore
622
- s1 = s2;
623
- // @ts-ignore
624
- }
625
- else {
626
- // @ts-ignore
627
- peg$currPos = s1;
628
- // @ts-ignore
629
- s1 = peg$FAILED;
630
- }
631
- // @ts-ignore
632
- if (s1 === peg$FAILED) {
633
- // @ts-ignore
634
- s1 = null;
635
- }
636
- // @ts-ignore
637
- s2 = peg$parseParsedFieldList();
638
- // @ts-ignore
639
- s3 = peg$parse__();
640
- // @ts-ignore
641
- if (s3 !== peg$FAILED) {
642
- // @ts-ignore
643
- if (input.substr(peg$currPos, 2) === peg$c0) {
644
- // @ts-ignore
645
- s4 = peg$c0;
646
- // @ts-ignore
647
- peg$currPos += 2;
648
- // @ts-ignore
649
- }
650
- else {
651
- // @ts-ignore
652
- s4 = peg$FAILED;
653
- // @ts-ignore
654
- if (peg$silentFails === 0) {
655
- peg$fail(peg$e0);
656
- }
657
- }
658
- // @ts-ignore
659
- if (s4 !== peg$FAILED) {
660
- // @ts-ignore
661
- s5 = peg$parse__();
662
- // @ts-ignore
663
- if (s5 !== peg$FAILED) {
664
- // @ts-ignore
665
- s6 = peg$parseParsedFieldList();
666
- // @ts-ignore
667
- s7 = peg$parse_();
668
- // @ts-ignore
669
- peg$savedPos = s0;
670
- // @ts-ignore
671
- s0 = peg$f0(s1, s2, s6);
672
- // @ts-ignore
673
- }
674
- else {
675
- // @ts-ignore
676
- peg$currPos = s0;
677
- // @ts-ignore
678
- s0 = peg$FAILED;
679
- }
680
- // @ts-ignore
681
- }
682
- else {
683
- // @ts-ignore
684
- peg$currPos = s0;
685
- // @ts-ignore
686
- s0 = peg$FAILED;
687
- }
688
- // @ts-ignore
689
- }
690
- else {
691
- // @ts-ignore
692
- peg$currPos = s0;
693
- // @ts-ignore
694
- s0 = peg$FAILED;
695
- }
696
- // @ts-ignore
697
- peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
698
- // @ts-ignore
699
- return s0;
700
- }
701
- // @ts-ignore
702
- function peg$parseParsedFieldList() {
703
- // @ts-ignore
704
- var s0, s1, s2, s3, s4, s5;
705
- // @ts-ignore
706
- var key = peg$currPos * 9 + 1;
707
- // @ts-ignore
708
- var cached = peg$resultsCache[key];
709
- // @ts-ignore
710
- if (cached) {
711
- // @ts-ignore
712
- peg$currPos = cached.nextPos;
713
- // @ts-ignore
714
- return cached.result;
715
- }
716
- // @ts-ignore
717
- s0 = [];
718
- // @ts-ignore
719
- s1 = peg$parseParsedField();
720
- // @ts-ignore
721
- while (s1 !== peg$FAILED) {
722
- // @ts-ignore
723
- s0.push(s1);
724
- // @ts-ignore
725
- s1 = peg$currPos;
726
- // @ts-ignore
727
- s2 = peg$currPos;
728
- // @ts-ignore
729
- s3 = peg$parse_();
730
- // @ts-ignore
731
- if (input.charCodeAt(peg$currPos) === 44) {
732
- // @ts-ignore
733
- s4 = peg$c1;
734
- // @ts-ignore
735
- peg$currPos++;
736
- // @ts-ignore
737
- }
738
- else {
739
- // @ts-ignore
740
- s4 = peg$FAILED;
741
- // @ts-ignore
742
- if (peg$silentFails === 0) {
743
- peg$fail(peg$e1);
744
- }
745
- }
746
- // @ts-ignore
747
- if (s4 !== peg$FAILED) {
748
- // @ts-ignore
749
- s5 = peg$parse_();
750
- // @ts-ignore
751
- s3 = [s3, s4, s5];
752
- // @ts-ignore
753
- s2 = s3;
754
- // @ts-ignore
755
- }
756
- else {
757
- // @ts-ignore
758
- peg$currPos = s2;
759
- // @ts-ignore
760
- s2 = peg$FAILED;
761
- }
762
- // @ts-ignore
763
- if (s2 !== peg$FAILED) {
764
- // @ts-ignore
765
- s2 = peg$parseParsedField();
766
- // @ts-ignore
767
- s1 = s2;
768
- // @ts-ignore
769
- }
770
- else {
771
- // @ts-ignore
772
- s1 = s2;
773
- }
774
- }
775
- // @ts-ignore
776
- peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
777
- // @ts-ignore
778
- return s0;
779
- }
780
- // @ts-ignore
781
- function peg$parseParsedField() {
782
- // @ts-ignore
783
- var s0, s1, s2, s3, s4, s5, s6, s7, s8;
784
- // @ts-ignore
785
- var key = peg$currPos * 9 + 2;
786
- // @ts-ignore
787
- var cached = peg$resultsCache[key];
788
- // @ts-ignore
789
- if (cached) {
790
- // @ts-ignore
791
- peg$currPos = cached.nextPos;
792
- // @ts-ignore
793
- return cached.result;
794
- }
795
- // @ts-ignore
796
- s0 = peg$currPos;
797
- // @ts-ignore
798
- s1 = peg$parse_();
799
- // @ts-ignore
800
- s2 = peg$parseParsedIdentifier();
801
- // @ts-ignore
802
- if (input.charCodeAt(peg$currPos) === 63) {
803
- // @ts-ignore
804
- s3 = peg$c2;
805
- // @ts-ignore
806
- peg$currPos++;
807
- // @ts-ignore
808
- }
809
- else {
810
- // @ts-ignore
811
- s3 = peg$FAILED;
812
- // @ts-ignore
813
- if (peg$silentFails === 0) {
814
- peg$fail(peg$e2);
815
- }
816
- }
817
- // @ts-ignore
818
- if (s3 === peg$FAILED) {
819
- // @ts-ignore
820
- s3 = null;
821
- }
822
- // @ts-ignore
823
- s4 = peg$currPos;
824
- // @ts-ignore
825
- s5 = peg$parse_();
826
- // @ts-ignore
827
- if (input.charCodeAt(peg$currPos) === 58) {
828
- // @ts-ignore
829
- s6 = peg$c3;
830
- // @ts-ignore
831
- peg$currPos++;
832
- // @ts-ignore
833
- }
834
- else {
835
- // @ts-ignore
836
- s6 = peg$FAILED;
837
- // @ts-ignore
838
- if (peg$silentFails === 0) {
839
- peg$fail(peg$e3);
840
- }
841
- }
842
- // @ts-ignore
843
- if (s6 !== peg$FAILED) {
844
- // @ts-ignore
845
- s7 = peg$parse_();
846
- // @ts-ignore
847
- s8 = peg$parseParsedType();
848
- // @ts-ignore
849
- if (s8 !== peg$FAILED) {
850
- // @ts-ignore
851
- s5 = [s5, s6, s7, s8];
852
- // @ts-ignore
853
- s4 = s5;
854
- // @ts-ignore
855
- }
856
- else {
857
- // @ts-ignore
858
- peg$currPos = s4;
859
- // @ts-ignore
860
- s4 = peg$FAILED;
861
- }
862
- // @ts-ignore
863
- }
864
- else {
865
- // @ts-ignore
866
- peg$currPos = s4;
867
- // @ts-ignore
868
- s4 = peg$FAILED;
869
- }
870
- // @ts-ignore
871
- if (s4 === peg$FAILED) {
872
- // @ts-ignore
873
- s4 = null;
874
- }
875
- // @ts-ignore
876
- s5 = peg$currPos;
877
- // @ts-ignore
878
- s6 = peg$parse_();
879
- // @ts-ignore
880
- s7 = peg$parseParsedString();
881
- // @ts-ignore
882
- if (s7 !== peg$FAILED) {
883
- // @ts-ignore
884
- s6 = [s6, s7];
885
- // @ts-ignore
886
- s5 = s6;
887
- // @ts-ignore
888
- }
889
- else {
890
- // @ts-ignore
891
- peg$currPos = s5;
892
- // @ts-ignore
893
- s5 = peg$FAILED;
894
- }
895
- // @ts-ignore
896
- if (s5 === peg$FAILED) {
897
- // @ts-ignore
898
- s5 = null;
899
- }
900
- // @ts-ignore
901
- peg$savedPos = s0;
902
- // @ts-ignore
903
- s0 = peg$f1(s2, s3, s4, s5);
904
- // @ts-ignore
905
- peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
906
- // @ts-ignore
907
- return s0;
908
105
  }
909
- // @ts-ignore
910
- function peg$parseParsedType() {
911
- // @ts-ignore
912
- var s0, s1, s2;
913
- // @ts-ignore
914
- var key = peg$currPos * 9 + 3;
915
- // @ts-ignore
916
- var cached = peg$resultsCache[key];
917
- // @ts-ignore
918
- if (cached) {
919
- // @ts-ignore
920
- peg$currPos = cached.nextPos;
921
- // @ts-ignore
922
- return cached.result;
923
- }
924
- // @ts-ignore
925
- s0 = peg$currPos;
926
- // @ts-ignore
927
- s1 = peg$parseType();
928
- // @ts-ignore
929
- if (s1 !== peg$FAILED) {
930
- // @ts-ignore
931
- if (input.substr(peg$currPos, 2) === peg$c4) {
932
- // @ts-ignore
933
- s2 = peg$c4;
934
- // @ts-ignore
935
- peg$currPos += 2;
936
- // @ts-ignore
937
- }
938
- else {
939
- // @ts-ignore
940
- s2 = peg$FAILED;
941
- // @ts-ignore
942
- if (peg$silentFails === 0) {
943
- peg$fail(peg$e4);
944
- }
945
- }
946
- // @ts-ignore
947
- if (s2 === peg$FAILED) {
948
- // @ts-ignore
949
- s2 = null;
950
- }
951
- // @ts-ignore
952
- peg$savedPos = s0;
953
- // @ts-ignore
954
- s0 = peg$f2(s1, s2);
955
- // @ts-ignore
956
- }
957
- else {
958
- // @ts-ignore
959
- peg$currPos = s0;
960
- // @ts-ignore
961
- s0 = peg$FAILED;
962
- }
963
- // @ts-ignore
964
- peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
965
- // @ts-ignore
966
- return s0;
967
- }
968
- // @ts-ignore
969
- function peg$parseType() {
970
- // @ts-ignore
971
- var s0;
972
- // @ts-ignore
973
- var key = peg$currPos * 9 + 4;
974
- // @ts-ignore
975
- var cached = peg$resultsCache[key];
976
- // @ts-ignore
977
- if (cached) {
978
- // @ts-ignore
979
- peg$currPos = cached.nextPos;
980
- // @ts-ignore
981
- return cached.result;
982
- }
983
- // @ts-ignore
984
- if (input.substr(peg$currPos, 6) === peg$c5) {
985
- // @ts-ignore
986
- s0 = peg$c5;
987
- // @ts-ignore
988
- peg$currPos += 6;
989
- // @ts-ignore
990
- }
991
- else {
992
- // @ts-ignore
993
- s0 = peg$FAILED;
994
- // @ts-ignore
995
- if (peg$silentFails === 0) {
996
- peg$fail(peg$e5);
997
- }
998
- }
999
- // @ts-ignore
1000
- if (s0 === peg$FAILED) {
1001
- // @ts-ignore
1002
- if (input.substr(peg$currPos, 6) === peg$c6) {
1003
- // @ts-ignore
1004
- s0 = peg$c6;
1005
- // @ts-ignore
1006
- peg$currPos += 6;
1007
- // @ts-ignore
1008
- }
1009
- else {
1010
- // @ts-ignore
1011
- s0 = peg$FAILED;
1012
- // @ts-ignore
1013
- if (peg$silentFails === 0) {
1014
- peg$fail(peg$e6);
1015
- }
1016
- }
1017
- // @ts-ignore
1018
- if (s0 === peg$FAILED) {
1019
- // @ts-ignore
1020
- if (input.substr(peg$currPos, 7) === peg$c7) {
1021
- // @ts-ignore
1022
- s0 = peg$c7;
1023
- // @ts-ignore
1024
- peg$currPos += 7;
1025
- // @ts-ignore
1026
- }
1027
- else {
1028
- // @ts-ignore
1029
- s0 = peg$FAILED;
1030
- // @ts-ignore
1031
- if (peg$silentFails === 0) {
1032
- peg$fail(peg$e7);
1033
- }
1034
- }
1035
- // @ts-ignore
1036
- if (s0 === peg$FAILED) {
1037
- // @ts-ignore
1038
- if (input.substr(peg$currPos, 4) === peg$c8) {
1039
- // @ts-ignore
1040
- s0 = peg$c8;
1041
- // @ts-ignore
1042
- peg$currPos += 4;
1043
- // @ts-ignore
1044
- }
1045
- else {
1046
- // @ts-ignore
1047
- s0 = peg$FAILED;
1048
- // @ts-ignore
1049
- if (peg$silentFails === 0) {
1050
- peg$fail(peg$e8);
1051
- }
1052
- }
1053
- // @ts-ignore
1054
- if (s0 === peg$FAILED) {
1055
- // @ts-ignore
1056
- if (input.substr(peg$currPos, 5) === peg$c9) {
1057
- // @ts-ignore
1058
- s0 = peg$c9;
1059
- // @ts-ignore
1060
- peg$currPos += 5;
1061
- // @ts-ignore
1062
- }
1063
- else {
1064
- // @ts-ignore
1065
- s0 = peg$FAILED;
1066
- // @ts-ignore
1067
- if (peg$silentFails === 0) {
1068
- peg$fail(peg$e9);
1069
- }
1070
- }
1071
- // @ts-ignore
1072
- if (s0 === peg$FAILED) {
1073
- // @ts-ignore
1074
- if (input.substr(peg$currPos, 8) === peg$c10) {
1075
- // @ts-ignore
1076
- s0 = peg$c10;
1077
- // @ts-ignore
1078
- peg$currPos += 8;
1079
- // @ts-ignore
1080
- }
1081
- else {
1082
- // @ts-ignore
1083
- s0 = peg$FAILED;
1084
- // @ts-ignore
1085
- if (peg$silentFails === 0) {
1086
- peg$fail(peg$e10);
1087
- }
1088
- }
1089
- // @ts-ignore
1090
- if (s0 === peg$FAILED) {
1091
- // @ts-ignore
1092
- if (input.substr(peg$currPos, 4) === peg$c11) {
1093
- // @ts-ignore
1094
- s0 = peg$c11;
1095
- // @ts-ignore
1096
- peg$currPos += 4;
1097
- // @ts-ignore
1098
- }
1099
- else {
1100
- // @ts-ignore
1101
- s0 = peg$FAILED;
1102
- // @ts-ignore
1103
- if (peg$silentFails === 0) {
1104
- peg$fail(peg$e11);
1105
- }
1106
- }
1107
- }
1108
- }
1109
- }
1110
- }
1111
- }
1112
- }
1113
- // @ts-ignore
1114
- peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1115
- // @ts-ignore
1116
- return s0;
1117
- }
1118
- // @ts-ignore
1119
- function peg$parseParsedIdentifier() {
1120
- // @ts-ignore
1121
- var s0, s1, s2;
1122
- // @ts-ignore
1123
- var key = peg$currPos * 9 + 5;
1124
- // @ts-ignore
1125
- var cached = peg$resultsCache[key];
1126
- // @ts-ignore
1127
- if (cached) {
1128
- // @ts-ignore
1129
- peg$currPos = cached.nextPos;
1130
- // @ts-ignore
1131
- return cached.result;
1132
- }
1133
- // @ts-ignore
1134
- s0 = peg$currPos;
1135
- // @ts-ignore
1136
- s1 = [];
1137
- // @ts-ignore
1138
- if (peg$r0.test(input.charAt(peg$currPos))) {
1139
- // @ts-ignore
1140
- s2 = input.charAt(peg$currPos);
1141
- // @ts-ignore
1142
- peg$currPos++;
1143
- // @ts-ignore
1144
- }
1145
- else {
1146
- // @ts-ignore
1147
- s2 = peg$FAILED;
1148
- // @ts-ignore
1149
- if (peg$silentFails === 0) {
1150
- peg$fail(peg$e12);
1151
- }
1152
- }
1153
- // @ts-ignore
1154
- while (s2 !== peg$FAILED) {
1155
- // @ts-ignore
1156
- s1.push(s2);
1157
- // @ts-ignore
1158
- if (peg$r0.test(input.charAt(peg$currPos))) {
1159
- // @ts-ignore
1160
- s2 = input.charAt(peg$currPos);
1161
- // @ts-ignore
1162
- peg$currPos++;
1163
- // @ts-ignore
1164
- }
1165
- else {
1166
- // @ts-ignore
1167
- s2 = peg$FAILED;
1168
- // @ts-ignore
1169
- if (peg$silentFails === 0) {
1170
- peg$fail(peg$e12);
1171
- }
1172
- }
1173
- }
1174
- // @ts-ignore
1175
- peg$savedPos = s0;
1176
- // @ts-ignore
1177
- s1 = peg$f3(s1);
1178
- // @ts-ignore
1179
- s0 = s1;
1180
- // @ts-ignore
1181
- peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1182
- // @ts-ignore
1183
- return s0;
1184
- }
1185
- // @ts-ignore
1186
- function peg$parseParsedString() {
1187
- // @ts-ignore
1188
- var s0, s1, s2, s3;
1189
- // @ts-ignore
1190
- var key = peg$currPos * 9 + 6;
1191
- // @ts-ignore
1192
- var cached = peg$resultsCache[key];
1193
- // @ts-ignore
1194
- if (cached) {
1195
- // @ts-ignore
1196
- peg$currPos = cached.nextPos;
1197
- // @ts-ignore
1198
- return cached.result;
1199
- }
1200
- // @ts-ignore
1201
- s0 = peg$currPos;
1202
- // @ts-ignore
1203
- if (input.charCodeAt(peg$currPos) === 39) {
1204
- // @ts-ignore
1205
- s1 = peg$c12;
1206
- // @ts-ignore
1207
- peg$currPos++;
1208
- // @ts-ignore
1209
- }
1210
- else {
1211
- // @ts-ignore
1212
- s1 = peg$FAILED;
1213
- // @ts-ignore
1214
- if (peg$silentFails === 0) {
1215
- peg$fail(peg$e13);
1216
- }
1217
- }
1218
- // @ts-ignore
1219
- if (s1 !== peg$FAILED) {
1220
- // @ts-ignore
1221
- s2 = [];
1222
- // @ts-ignore
1223
- if (peg$r1.test(input.charAt(peg$currPos))) {
1224
- // @ts-ignore
1225
- s3 = input.charAt(peg$currPos);
1226
- // @ts-ignore
1227
- peg$currPos++;
1228
- // @ts-ignore
1229
- }
1230
- else {
1231
- // @ts-ignore
1232
- s3 = peg$FAILED;
1233
- // @ts-ignore
1234
- if (peg$silentFails === 0) {
1235
- peg$fail(peg$e14);
1236
- }
1237
- }
1238
- // @ts-ignore
1239
- while (s3 !== peg$FAILED) {
1240
- // @ts-ignore
1241
- s2.push(s3);
1242
- // @ts-ignore
1243
- if (peg$r1.test(input.charAt(peg$currPos))) {
1244
- // @ts-ignore
1245
- s3 = input.charAt(peg$currPos);
1246
- // @ts-ignore
1247
- peg$currPos++;
1248
- // @ts-ignore
1249
- }
1250
- else {
1251
- // @ts-ignore
1252
- s3 = peg$FAILED;
1253
- // @ts-ignore
1254
- if (peg$silentFails === 0) {
1255
- peg$fail(peg$e14);
1256
- }
1257
- }
1258
- }
1259
- // @ts-ignore
1260
- if (input.charCodeAt(peg$currPos) === 39) {
1261
- // @ts-ignore
1262
- s3 = peg$c12;
1263
- // @ts-ignore
1264
- peg$currPos++;
1265
- // @ts-ignore
1266
- }
1267
- else {
1268
- // @ts-ignore
1269
- s3 = peg$FAILED;
1270
- // @ts-ignore
1271
- if (peg$silentFails === 0) {
1272
- peg$fail(peg$e13);
1273
- }
1274
- }
1275
- // @ts-ignore
1276
- if (s3 !== peg$FAILED) {
1277
- // @ts-ignore
1278
- peg$savedPos = s0;
1279
- // @ts-ignore
1280
- s0 = peg$f4(s2);
1281
- // @ts-ignore
1282
- }
1283
- else {
1284
- // @ts-ignore
1285
- peg$currPos = s0;
1286
- // @ts-ignore
1287
- s0 = peg$FAILED;
1288
- }
1289
- // @ts-ignore
1290
- }
1291
- else {
1292
- // @ts-ignore
1293
- peg$currPos = s0;
1294
- // @ts-ignore
1295
- s0 = peg$FAILED;
1296
- }
1297
- // @ts-ignore
1298
- if (s0 === peg$FAILED) {
1299
- // @ts-ignore
1300
- s0 = peg$currPos;
1301
- // @ts-ignore
1302
- if (input.charCodeAt(peg$currPos) === 34) {
1303
- // @ts-ignore
1304
- s1 = peg$c13;
1305
- // @ts-ignore
1306
- peg$currPos++;
1307
- // @ts-ignore
1308
- }
1309
- else {
1310
- // @ts-ignore
1311
- s1 = peg$FAILED;
1312
- // @ts-ignore
1313
- if (peg$silentFails === 0) {
1314
- peg$fail(peg$e15);
1315
- }
1316
- }
1317
- // @ts-ignore
1318
- if (s1 !== peg$FAILED) {
1319
- // @ts-ignore
1320
- s2 = [];
1321
- // @ts-ignore
1322
- if (peg$r2.test(input.charAt(peg$currPos))) {
1323
- // @ts-ignore
1324
- s3 = input.charAt(peg$currPos);
1325
- // @ts-ignore
1326
- peg$currPos++;
1327
- // @ts-ignore
1328
- }
1329
- else {
1330
- // @ts-ignore
1331
- s3 = peg$FAILED;
1332
- // @ts-ignore
1333
- if (peg$silentFails === 0) {
1334
- peg$fail(peg$e16);
1335
- }
1336
- }
1337
- // @ts-ignore
1338
- while (s3 !== peg$FAILED) {
1339
- // @ts-ignore
1340
- s2.push(s3);
1341
- // @ts-ignore
1342
- if (peg$r2.test(input.charAt(peg$currPos))) {
1343
- // @ts-ignore
1344
- s3 = input.charAt(peg$currPos);
1345
- // @ts-ignore
1346
- peg$currPos++;
1347
- // @ts-ignore
1348
- }
1349
- else {
1350
- // @ts-ignore
1351
- s3 = peg$FAILED;
1352
- // @ts-ignore
1353
- if (peg$silentFails === 0) {
1354
- peg$fail(peg$e16);
1355
- }
1356
- }
1357
- }
1358
- // @ts-ignore
1359
- if (input.charCodeAt(peg$currPos) === 34) {
1360
- // @ts-ignore
1361
- s3 = peg$c13;
1362
- // @ts-ignore
1363
- peg$currPos++;
1364
- // @ts-ignore
1365
- }
1366
- else {
1367
- // @ts-ignore
1368
- s3 = peg$FAILED;
1369
- // @ts-ignore
1370
- if (peg$silentFails === 0) {
1371
- peg$fail(peg$e15);
1372
- }
1373
- }
1374
- // @ts-ignore
1375
- if (s3 !== peg$FAILED) {
1376
- // @ts-ignore
1377
- peg$savedPos = s0;
1378
- // @ts-ignore
1379
- s0 = peg$f5(s2);
1380
- // @ts-ignore
1381
- }
1382
- else {
1383
- // @ts-ignore
1384
- peg$currPos = s0;
1385
- // @ts-ignore
1386
- s0 = peg$FAILED;
1387
- }
1388
- // @ts-ignore
1389
- }
1390
- else {
1391
- // @ts-ignore
1392
- peg$currPos = s0;
1393
- // @ts-ignore
1394
- s0 = peg$FAILED;
1395
- }
106
+ }
107
+ parseTypeNotClass() {
108
+ const types = ["string", "number", "boolean", "json", "image", "datetime", "date"];
109
+ for (const type of types) {
110
+ if (this.match(type)) {
111
+ return type;
1396
112
  }
1397
- // @ts-ignore
1398
- peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1399
- // @ts-ignore
1400
- return s0;
1401
113
  }
1402
- // @ts-ignore
1403
- function peg$parse_() {
1404
- // @ts-ignore
1405
- var s0, s1, s2;
1406
- // @ts-ignore
1407
- var key = peg$currPos * 9 + 7;
1408
- // @ts-ignore
1409
- var cached = peg$resultsCache[key];
1410
- // @ts-ignore
1411
- if (cached) {
1412
- // @ts-ignore
1413
- peg$currPos = cached.nextPos;
1414
- // @ts-ignore
1415
- return cached.result;
1416
- }
1417
- // @ts-ignore
1418
- s0 = peg$currPos;
1419
- // @ts-ignore
1420
- s1 = [];
1421
- // @ts-ignore
1422
- if (peg$r3.test(input.charAt(peg$currPos))) {
1423
- // @ts-ignore
1424
- s2 = input.charAt(peg$currPos);
1425
- // @ts-ignore
1426
- peg$currPos++;
1427
- // @ts-ignore
1428
- }
1429
- else {
1430
- // @ts-ignore
1431
- s2 = peg$FAILED;
1432
- // @ts-ignore
1433
- if (peg$silentFails === 0) {
1434
- peg$fail(peg$e17);
1435
- }
1436
- }
1437
- // @ts-ignore
1438
- while (s2 !== peg$FAILED) {
1439
- // @ts-ignore
1440
- s1.push(s2);
1441
- // @ts-ignore
1442
- if (peg$r3.test(input.charAt(peg$currPos))) {
1443
- // @ts-ignore
1444
- s2 = input.charAt(peg$currPos);
1445
- // @ts-ignore
1446
- peg$currPos++;
1447
- // @ts-ignore
1448
- }
1449
- else {
1450
- // @ts-ignore
1451
- s2 = peg$FAILED;
1452
- // @ts-ignore
1453
- if (peg$silentFails === 0) {
1454
- peg$fail(peg$e17);
1455
- }
1456
- }
1457
- }
1458
- // @ts-ignore
1459
- peg$savedPos = s0;
1460
- // @ts-ignore
1461
- s1 = peg$f6();
1462
- // @ts-ignore
1463
- s0 = s1;
1464
- // @ts-ignore
1465
- peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1466
- // @ts-ignore
1467
- return s0;
114
+ throw new Error(`Expected one of ${types.join(', ')}`);
115
+ }
116
+ parseParsedIdentifier() {
117
+ const match = /^[a-zA-Z_][a-zA-Z_0-9]*/.exec(this.input.slice(this.position));
118
+ if (match) {
119
+ this.position += match[0].length;
120
+ return match[0];
1468
121
  }
1469
- // @ts-ignore
1470
- function peg$parse__() {
1471
- // @ts-ignore
1472
- var s0, s1, s2;
1473
- // @ts-ignore
1474
- var key = peg$currPos * 9 + 8;
1475
- // @ts-ignore
1476
- var cached = peg$resultsCache[key];
1477
- // @ts-ignore
1478
- if (cached) {
1479
- // @ts-ignore
1480
- peg$currPos = cached.nextPos;
1481
- // @ts-ignore
1482
- return cached.result;
1483
- }
1484
- // @ts-ignore
1485
- s0 = peg$currPos;
1486
- // @ts-ignore
1487
- s1 = [];
1488
- // @ts-ignore
1489
- if (peg$r3.test(input.charAt(peg$currPos))) {
1490
- // @ts-ignore
1491
- s2 = input.charAt(peg$currPos);
1492
- // @ts-ignore
1493
- peg$currPos++;
1494
- // @ts-ignore
1495
- }
1496
- else {
1497
- // @ts-ignore
1498
- s2 = peg$FAILED;
1499
- // @ts-ignore
1500
- if (peg$silentFails === 0) {
1501
- peg$fail(peg$e17);
1502
- }
1503
- }
1504
- // @ts-ignore
1505
- if (s2 !== peg$FAILED) {
1506
- // @ts-ignore
1507
- while (s2 !== peg$FAILED) {
1508
- // @ts-ignore
1509
- s1.push(s2);
1510
- // @ts-ignore
1511
- if (peg$r3.test(input.charAt(peg$currPos))) {
1512
- // @ts-ignore
1513
- s2 = input.charAt(peg$currPos);
1514
- // @ts-ignore
1515
- peg$currPos++;
1516
- // @ts-ignore
1517
- }
1518
- else {
1519
- // @ts-ignore
1520
- s2 = peg$FAILED;
1521
- // @ts-ignore
1522
- if (peg$silentFails === 0) {
1523
- peg$fail(peg$e17);
1524
- }
1525
- }
1526
- }
1527
- // @ts-ignore
1528
- }
1529
- else {
1530
- // @ts-ignore
1531
- s1 = peg$FAILED;
1532
- }
1533
- // @ts-ignore
1534
- if (s1 !== peg$FAILED) {
1535
- // @ts-ignore
1536
- peg$savedPos = s0;
1537
- // @ts-ignore
1538
- s1 = peg$f7();
1539
- }
1540
- // @ts-ignore
1541
- s0 = s1;
1542
- // @ts-ignore
1543
- peg$resultsCache[key] = { nextPos: peg$currPos, result: s0 };
1544
- // @ts-ignore
1545
- return s0;
122
+ throw new Error('Expected identifier');
123
+ }
124
+ parseParsedString() {
125
+ if (this.match("'")) {
126
+ const endQuote = this.input.indexOf("'", this.position);
127
+ if (endQuote === -1)
128
+ throw new Error("Unterminated string");
129
+ const content = this.input.slice(this.position, endQuote);
130
+ this.position = endQuote + 1;
131
+ return content;
132
+ }
133
+ else if (this.match('"')) {
134
+ const endQuote = this.input.indexOf('"', this.position);
135
+ if (endQuote === -1)
136
+ throw new Error("Unterminated string");
137
+ const content = this.input.slice(this.position, endQuote);
138
+ this.position = endQuote + 1;
139
+ return content;
140
+ }
141
+ return undefined;
142
+ }
143
+ skipWhitespace() {
144
+ const match = /^[ \t\r\n]+/.exec(this.input.slice(this.position));
145
+ if (match) {
146
+ this.position += match[0].length;
1546
147
  }
1547
- // @ts-ignore
1548
- peg$result = peg$startRuleFunction();
1549
- // @ts-ignore
1550
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
1551
- // @ts-ignore
1552
- return peg$result;
1553
- // @ts-ignore
148
+ }
149
+ match(str) {
150
+ if (this.input.startsWith(str, this.position)) {
151
+ this.position += str.length;
152
+ return true;
1554
153
  }
1555
- else {
1556
- // @ts-ignore
1557
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1558
- // @ts-ignore
1559
- peg$fail(peg$endExpectation());
1560
- }
1561
- // @ts-ignore
1562
- throw peg$buildStructuredError(
1563
- // @ts-ignore
1564
- peg$maxFailExpected,
1565
- // @ts-ignore
1566
- peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
1567
- // @ts-ignore
1568
- peg$maxFailPos < input.length
1569
- // @ts-ignore
1570
- ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
1571
- // @ts-ignore
1572
- : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
154
+ return false;
155
+ }
156
+ expect(str) {
157
+ if (!this.match(str)) {
158
+ throw new Error(`Expected "${str}"`);
1573
159
  }
1574
160
  }
1575
- // @ts-ignore
1576
- return {
1577
- SyntaxError: peg$SyntaxError,
1578
- parse: peg$parse
1579
- };
1580
- })();
1581
- peggyParser.SyntaxError.prototype.name = "PeggySyntaxError";
1582
- export const parse = peggyParser.parse;
1583
- export const PeggySyntaxError = peggyParser.SyntaxError;
161
+ }
162
+ export function parseSignature(input) {
163
+ const parser = new SignatureParser(input);
164
+ return parser.parse();
165
+ }
1584
166
  //# sourceMappingURL=parser.js.map