@temperlang/std 0.3.0 → 0.5.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.
package/json.js ADDED
@@ -0,0 +1,2101 @@
1
+ const {
2
+ trunc: trunc__727
3
+ } = globalThis.Math;
4
+ import {
5
+ type as type__392, requireInstanceOf as requireInstanceOf__585, requireStringIndex as requireStringIndex__852, cmpFloat as cmpFloat__966, mappedGetOr as mappedGetOr_422, listedGet as listedGet_424, mappedForEach as mappedForEach_436, float64ToString as float64ToString_473, float64ToInt as float64ToInt_475, stringToInt as stringToInt_487, stringToFloat64 as stringToFloat64_488, listBuilderAdd as listBuilderAdd_500, listedGetOr as listedGetOr_504, listBuilderSet as listBuilderSet_512, listBuilderRemoveLast as listBuilderRemoveLast_517, mapBuilderConstructor as mapBuilderConstructor_579, panic as panic_586, mappedGet as mappedGet_591, mapBuilderSet as mapBuilderSet_592, listBuilderToList as listBuilderToList_598, mappedToMap as mappedToMap_599, stringGet as stringGet_645, stringNext as stringNext_746, stringHasAtLeast as stringHasAtLeast_817, stringBuilderAppendCodePoint as stringBuilderAppendCodePoint_822
6
+ } from "@temperlang/core";
7
+ export class InterchangeContext extends type__392() {
8
+ /**
9
+ * @param {string} headerName_391
10
+ * @returns {string | null}
11
+ */
12
+ getHeader(headerName_391) {
13
+ null;
14
+ }
15
+ };
16
+ export class NullInterchangeContext extends type__392(InterchangeContext) {
17
+ /**
18
+ * @param {string} headerName_394
19
+ * @returns {string | null}
20
+ */
21
+ getHeader(headerName_394) {
22
+ return null;
23
+ }
24
+ /** @type {NullInterchangeContext} */
25
+ static #instance_395 = new NullInterchangeContext();
26
+ /** @returns {NullInterchangeContext} */
27
+ static get instance() {
28
+ return this.#instance_395;
29
+ }
30
+ constructor() {
31
+ super ();
32
+ return;
33
+ }
34
+ };
35
+ export class JsonProducer extends type__392() {
36
+ startObject() {
37
+ null;
38
+ }
39
+ endObject() {
40
+ null;
41
+ }
42
+ /** @param {string} key_400 */
43
+ objectKey(key_400) {
44
+ null;
45
+ }
46
+ startArray() {
47
+ null;
48
+ }
49
+ endArray() {
50
+ null;
51
+ }
52
+ nullValue() {
53
+ null;
54
+ }
55
+ /** @param {boolean} x_405 */
56
+ booleanValue(x_405) {
57
+ null;
58
+ }
59
+ /** @param {number} x_407 */
60
+ intValue(x_407) {
61
+ null;
62
+ }
63
+ /** @param {number} x_409 */
64
+ float64Value(x_409) {
65
+ null;
66
+ }
67
+ /** @param {string} x_411 */
68
+ numericTokenValue(x_411) {
69
+ null;
70
+ }
71
+ /** @param {string} x_413 */
72
+ stringValue(x_413) {
73
+ null;
74
+ }
75
+ /** @returns {JsonParseErrorReceiver | null} */
76
+ get parseErrorReceiver() {
77
+ return null;
78
+ }
79
+ };
80
+ export class JsonSyntaxTree extends type__392() {
81
+ /** @param {JsonProducer} p_416 */
82
+ produce(p_416) {
83
+ null;
84
+ }
85
+ };
86
+ export class JsonObject extends type__392(JsonSyntaxTree) {
87
+ /** @type {Map<string, Array<JsonSyntaxTree>>} */
88
+ #properties_417;
89
+ /**
90
+ * @param {string} propertyKey_419
91
+ * @returns {JsonSyntaxTree | null}
92
+ */
93
+ propertyValueOrNull(propertyKey_419) {
94
+ let return_420;
95
+ const treeList_421 = mappedGetOr_422(this.#properties_417, propertyKey_419, Object.freeze([]));
96
+ const lastIndex_423 = treeList_421.length - 1;
97
+ if (lastIndex_423 >= 0) {
98
+ return_420 = listedGet_424(treeList_421, lastIndex_423);
99
+ } else {
100
+ return_420 = null;
101
+ }
102
+ return return_420;
103
+ }
104
+ /**
105
+ * @param {string} propertyKey_426
106
+ * @returns {JsonSyntaxTree}
107
+ */
108
+ propertyValueOrBubble(propertyKey_426) {
109
+ let return_427;
110
+ let t_428 = this.propertyValueOrNull(propertyKey_426);
111
+ if (t_428 == null) {
112
+ throw Error();
113
+ } else {
114
+ return_427 = t_428;
115
+ }
116
+ return return_427;
117
+ }
118
+ /** @param {JsonProducer} p_430 */
119
+ produce(p_430) {
120
+ p_430.startObject();
121
+ function fn_431(k_432, vs_433) {
122
+ function fn_434(v_435) {
123
+ p_430.objectKey(k_432);
124
+ v_435.produce(p_430);
125
+ return;
126
+ }
127
+ vs_433.forEach(fn_434);
128
+ return;
129
+ }
130
+ mappedForEach_436(this.#properties_417, fn_431);
131
+ p_430.endObject();
132
+ return;
133
+ }
134
+ /** @param {Map<string, Array<JsonSyntaxTree>>} properties_437 */
135
+ constructor(properties_437) {
136
+ super ();
137
+ this.#properties_417 = properties_437;
138
+ return;
139
+ }
140
+ /** @returns {Map<string, Array<JsonSyntaxTree>>} */
141
+ get properties() {
142
+ return this.#properties_417;
143
+ }
144
+ };
145
+ export class JsonArray extends type__392(JsonSyntaxTree) {
146
+ /** @type {Array<JsonSyntaxTree>} */
147
+ #elements_439;
148
+ /** @param {JsonProducer} p_441 */
149
+ produce(p_441) {
150
+ p_441.startArray();
151
+ function fn_442(v_443) {
152
+ v_443.produce(p_441);
153
+ return;
154
+ }
155
+ this.#elements_439.forEach(fn_442);
156
+ p_441.endArray();
157
+ return;
158
+ }
159
+ /** @param {Array<JsonSyntaxTree>} elements_444 */
160
+ constructor(elements_444) {
161
+ super ();
162
+ this.#elements_439 = elements_444;
163
+ return;
164
+ }
165
+ /** @returns {Array<JsonSyntaxTree>} */
166
+ get elements() {
167
+ return this.#elements_439;
168
+ }
169
+ };
170
+ export class JsonBoolean extends type__392(JsonSyntaxTree) {
171
+ /** @type {boolean} */
172
+ #content_446;
173
+ /** @param {JsonProducer} p_448 */
174
+ produce(p_448) {
175
+ p_448.booleanValue(this.#content_446);
176
+ return;
177
+ }
178
+ /** @param {boolean} content_449 */
179
+ constructor(content_449) {
180
+ super ();
181
+ this.#content_446 = content_449;
182
+ return;
183
+ }
184
+ /** @returns {boolean} */
185
+ get content() {
186
+ return this.#content_446;
187
+ }
188
+ };
189
+ export class JsonNull extends type__392(JsonSyntaxTree) {
190
+ /** @param {JsonProducer} p_452 */
191
+ produce(p_452) {
192
+ p_452.nullValue();
193
+ return;
194
+ }
195
+ constructor() {
196
+ super ();
197
+ return;
198
+ }
199
+ };
200
+ export class JsonString extends type__392(JsonSyntaxTree) {
201
+ /** @type {string} */
202
+ #content_453;
203
+ /** @param {JsonProducer} p_455 */
204
+ produce(p_455) {
205
+ p_455.stringValue(this.#content_453);
206
+ return;
207
+ }
208
+ /** @param {string} content_456 */
209
+ constructor(content_456) {
210
+ super ();
211
+ this.#content_453 = content_456;
212
+ return;
213
+ }
214
+ /** @returns {string} */
215
+ get content() {
216
+ return this.#content_453;
217
+ }
218
+ };
219
+ export class JsonNumeric extends type__392(JsonSyntaxTree) {
220
+ /** @returns {string} */
221
+ asJsonNumericToken() {
222
+ null;
223
+ }
224
+ /** @returns {number} */
225
+ asInt() {
226
+ null;
227
+ }
228
+ /** @returns {number} */
229
+ asFloat64() {
230
+ null;
231
+ }
232
+ };
233
+ export class JsonInt extends type__392(JsonNumeric) {
234
+ /** @type {number} */
235
+ #content_461;
236
+ /** @param {JsonProducer} p_463 */
237
+ produce(p_463) {
238
+ p_463.intValue(this.#content_461);
239
+ return;
240
+ }
241
+ /** @returns {string} */
242
+ asJsonNumericToken() {
243
+ return this.#content_461.toString();
244
+ }
245
+ /** @returns {number} */
246
+ asInt() {
247
+ return this.#content_461;
248
+ }
249
+ /** @returns {number} */
250
+ asFloat64() {
251
+ return this.#content_461;
252
+ }
253
+ /** @param {number} content_467 */
254
+ constructor(content_467) {
255
+ super ();
256
+ this.#content_461 = content_467;
257
+ return;
258
+ }
259
+ /** @returns {number} */
260
+ get content() {
261
+ return this.#content_461;
262
+ }
263
+ };
264
+ export class JsonFloat64 extends type__392(JsonNumeric) {
265
+ /** @type {number} */
266
+ #content_469;
267
+ /** @param {JsonProducer} p_471 */
268
+ produce(p_471) {
269
+ p_471.float64Value(this.#content_469);
270
+ return;
271
+ }
272
+ /** @returns {string} */
273
+ asJsonNumericToken() {
274
+ return float64ToString_473(this.#content_469);
275
+ }
276
+ /** @returns {number} */
277
+ asInt() {
278
+ return float64ToInt_475(this.#content_469);
279
+ }
280
+ /** @returns {number} */
281
+ asFloat64() {
282
+ return this.#content_469;
283
+ }
284
+ /** @param {number} content_477 */
285
+ constructor(content_477) {
286
+ super ();
287
+ this.#content_469 = content_477;
288
+ return;
289
+ }
290
+ /** @returns {number} */
291
+ get content() {
292
+ return this.#content_469;
293
+ }
294
+ };
295
+ export class JsonNumericToken extends type__392(JsonNumeric) {
296
+ /** @type {string} */
297
+ #content_479;
298
+ /** @param {JsonProducer} p_481 */
299
+ produce(p_481) {
300
+ p_481.numericTokenValue(this.#content_479);
301
+ return;
302
+ }
303
+ /** @returns {string} */
304
+ asJsonNumericToken() {
305
+ return this.#content_479;
306
+ }
307
+ /** @returns {number} */
308
+ asInt() {
309
+ let return_484;
310
+ let t_485;
311
+ let t_486;
312
+ try {
313
+ t_485 = stringToInt_487(this.#content_479);
314
+ return_484 = t_485;
315
+ } catch {
316
+ t_486 = stringToFloat64_488(this.#content_479);
317
+ return_484 = float64ToInt_475(t_486);
318
+ }
319
+ return return_484;
320
+ }
321
+ /** @returns {number} */
322
+ asFloat64() {
323
+ return stringToFloat64_488(this.#content_479);
324
+ }
325
+ /** @param {string} content_490 */
326
+ constructor(content_490) {
327
+ super ();
328
+ this.#content_479 = content_490;
329
+ return;
330
+ }
331
+ /** @returns {string} */
332
+ get content() {
333
+ return this.#content_479;
334
+ }
335
+ };
336
+ export class JsonTextProducer extends type__392(JsonProducer) {
337
+ /** @type {InterchangeContext} */
338
+ #interchangeContext_492;
339
+ /** @type {globalThis.Array<string>} */
340
+ #buffer_493;
341
+ /** @type {Array<number>} */
342
+ #stack_494;
343
+ /** @type {boolean} */
344
+ #wellFormed_495;
345
+ /** @param {InterchangeContext | null} [interchangeContext_496] */
346
+ constructor(interchangeContext_496) {
347
+ super ();
348
+ let interchangeContext_497;
349
+ if (interchangeContext_496 == null) {
350
+ interchangeContext_497 = NullInterchangeContext.instance;
351
+ } else {
352
+ interchangeContext_497 = interchangeContext_496;
353
+ }
354
+ this.#interchangeContext_492 = interchangeContext_497;
355
+ let t_498 = [""];
356
+ this.#buffer_493 = t_498;
357
+ let t_499 = [];
358
+ this.#stack_494 = t_499;
359
+ listBuilderAdd_500(this.#stack_494, 5);
360
+ this.#wellFormed_495 = true;
361
+ return;
362
+ }
363
+ /** @returns {number} */
364
+ #state_502() {
365
+ let t_503 = this.#stack_494.length;
366
+ return listedGetOr_504(this.#stack_494, t_503 - 1, -1);
367
+ }
368
+ #beforeValue_506() {
369
+ let t_507;
370
+ let t_508;
371
+ let t_509;
372
+ let t_510;
373
+ const currentState_511 = this.#state_502();
374
+ if (currentState_511 === 3) {
375
+ t_507 = this.#stack_494.length;
376
+ listBuilderSet_512(this.#stack_494, t_507 - 1, 4);
377
+ } else if (currentState_511 === 4) {
378
+ this.#buffer_493[0] += ",";
379
+ } else if (currentState_511 === 1) {
380
+ t_508 = this.#stack_494.length;
381
+ listBuilderSet_512(this.#stack_494, t_508 - 1, 2);
382
+ } else if (currentState_511 === 5) {
383
+ t_509 = this.#stack_494.length;
384
+ listBuilderSet_512(this.#stack_494, t_509 - 1, 6);
385
+ } else {
386
+ if (currentState_511 === 6) {
387
+ t_510 = true;
388
+ } else {
389
+ t_510 = currentState_511 === 2;
390
+ }
391
+ if (t_510) {
392
+ this.#wellFormed_495 = false;
393
+ }
394
+ }
395
+ return;
396
+ }
397
+ startObject() {
398
+ this.#beforeValue_506();
399
+ this.#buffer_493[0] += "{";
400
+ listBuilderAdd_500(this.#stack_494, 0);
401
+ return;
402
+ }
403
+ endObject() {
404
+ let t_515;
405
+ this.#buffer_493[0] += "}";
406
+ const currentState_516 = this.#state_502();
407
+ if (0 === currentState_516) {
408
+ t_515 = true;
409
+ } else {
410
+ t_515 = 2 === currentState_516;
411
+ }
412
+ if (t_515) {
413
+ listBuilderRemoveLast_517(this.#stack_494);
414
+ } else {
415
+ this.#wellFormed_495 = false;
416
+ }
417
+ return;
418
+ }
419
+ /** @param {string} key_519 */
420
+ objectKey(key_519) {
421
+ let t_520;
422
+ const currentState_521 = this.#state_502();
423
+ if (!(currentState_521 === 0)) {
424
+ if (currentState_521 === 2) {
425
+ this.#buffer_493[0] += ",";
426
+ } else {
427
+ this.#wellFormed_495 = false;
428
+ }
429
+ }
430
+ encodeJsonString_522(key_519, this.#buffer_493);
431
+ this.#buffer_493[0] += ":";
432
+ if (currentState_521 >= 0) {
433
+ t_520 = this.#stack_494.length;
434
+ listBuilderSet_512(this.#stack_494, t_520 - 1, 1);
435
+ }
436
+ return;
437
+ }
438
+ startArray() {
439
+ this.#beforeValue_506();
440
+ this.#buffer_493[0] += "[";
441
+ listBuilderAdd_500(this.#stack_494, 3);
442
+ return;
443
+ }
444
+ endArray() {
445
+ let t_525;
446
+ this.#buffer_493[0] += "]";
447
+ const currentState_526 = this.#state_502();
448
+ if (3 === currentState_526) {
449
+ t_525 = true;
450
+ } else {
451
+ t_525 = 4 === currentState_526;
452
+ }
453
+ if (t_525) {
454
+ listBuilderRemoveLast_517(this.#stack_494);
455
+ } else {
456
+ this.#wellFormed_495 = false;
457
+ }
458
+ return;
459
+ }
460
+ nullValue() {
461
+ this.#beforeValue_506();
462
+ this.#buffer_493[0] += "null";
463
+ return;
464
+ }
465
+ /** @param {boolean} x_529 */
466
+ booleanValue(x_529) {
467
+ let t_530;
468
+ this.#beforeValue_506();
469
+ if (x_529) {
470
+ t_530 = "true";
471
+ } else {
472
+ t_530 = "false";
473
+ }
474
+ this.#buffer_493[0] += t_530;
475
+ return;
476
+ }
477
+ /** @param {number} x_532 */
478
+ intValue(x_532) {
479
+ this.#beforeValue_506();
480
+ let t_533 = x_532.toString();
481
+ this.#buffer_493[0] += t_533;
482
+ return;
483
+ }
484
+ /** @param {number} x_535 */
485
+ float64Value(x_535) {
486
+ this.#beforeValue_506();
487
+ let t_536 = float64ToString_473(x_535);
488
+ this.#buffer_493[0] += t_536;
489
+ return;
490
+ }
491
+ /** @param {string} x_538 */
492
+ numericTokenValue(x_538) {
493
+ this.#beforeValue_506();
494
+ this.#buffer_493[0] += x_538;
495
+ return;
496
+ }
497
+ /** @param {string} x_540 */
498
+ stringValue(x_540) {
499
+ this.#beforeValue_506();
500
+ encodeJsonString_522(x_540, this.#buffer_493);
501
+ return;
502
+ }
503
+ /** @returns {string} */
504
+ toJsonString() {
505
+ let return_542;
506
+ let t_543;
507
+ let t_544;
508
+ let t_545;
509
+ if (this.#wellFormed_495) {
510
+ if (this.#stack_494.length === 1) {
511
+ t_543 = this.#state_502();
512
+ t_544 = t_543 === 6;
513
+ } else {
514
+ t_544 = false;
515
+ }
516
+ t_545 = t_544;
517
+ } else {
518
+ t_545 = false;
519
+ }
520
+ if (t_545) {
521
+ return_542 = this.#buffer_493[0];
522
+ } else {
523
+ throw Error();
524
+ }
525
+ return return_542;
526
+ }
527
+ /** @returns {InterchangeContext} */
528
+ get interchangeContext() {
529
+ return this.#interchangeContext_492;
530
+ }
531
+ };
532
+ export class JsonParseErrorReceiver extends type__392() {
533
+ /** @param {string} explanation_548 */
534
+ explainJsonError(explanation_548) {
535
+ null;
536
+ }
537
+ };
538
+ export class JsonSyntaxTreeProducer extends type__392(JsonProducer, JsonParseErrorReceiver) {
539
+ /** @type {Array<Array<JsonSyntaxTree>>} */
540
+ #stack_549;
541
+ /** @type {string | null} */
542
+ #error_550;
543
+ /** @returns {InterchangeContext} */
544
+ get interchangeContext() {
545
+ return NullInterchangeContext.instance;
546
+ }
547
+ constructor() {
548
+ super ();
549
+ let t_552 = [];
550
+ this.#stack_549 = t_552;
551
+ let t_553 = [];
552
+ listBuilderAdd_500(this.#stack_549, t_553);
553
+ this.#error_550 = null;
554
+ return;
555
+ }
556
+ /** @param {JsonSyntaxTree} v_556 */
557
+ #storeValue_555(v_556) {
558
+ let t_557;
559
+ if (! ! this.#stack_549.length) {
560
+ t_557 = this.#stack_549.length;
561
+ listBuilderAdd_500(listedGet_424(this.#stack_549, t_557 - 1), v_556);
562
+ }
563
+ return;
564
+ }
565
+ startObject() {
566
+ let t_559 = [];
567
+ listBuilderAdd_500(this.#stack_549, t_559);
568
+ return;
569
+ }
570
+ endObject() {
571
+ let return_561;
572
+ let t_562;
573
+ let t_563;
574
+ let t_564;
575
+ let t_565;
576
+ let t_566;
577
+ let t_567;
578
+ let t_568;
579
+ let t_569;
580
+ let t_570;
581
+ let t_571;
582
+ let t_572;
583
+ let t_573;
584
+ let t_574;
585
+ let t_575;
586
+ fn_576: {
587
+ if (! this.#stack_549.length) {
588
+ return_561 = void 0;
589
+ break fn_576;
590
+ }
591
+ const ls_577 = listBuilderRemoveLast_517(this.#stack_549);
592
+ const m_578 = mapBuilderConstructor_579();
593
+ let multis_580 = null;
594
+ let i_581 = 0;
595
+ let n_582 = ls_577.length & -2;
596
+ while (i_581 < n_582) {
597
+ const postfixReturn_583 = i_581;
598
+ i_581 = i_581 + 1;
599
+ const keyTree_584 = listedGet_424(ls_577, postfixReturn_583);
600
+ if (!(keyTree_584 instanceof JsonString)) {
601
+ break;
602
+ }
603
+ try {
604
+ t_568 = requireInstanceOf__585(keyTree_584, JsonString);
605
+ t_569 = t_568;
606
+ } catch {
607
+ t_562 = panic_586();
608
+ t_569 = t_562;
609
+ }
610
+ const key_587 = t_569.content;
611
+ const postfixReturn_588 = i_581;
612
+ i_581 = i_581 + 1;
613
+ const value_589 = listedGet_424(ls_577, postfixReturn_588);
614
+ if (m_578.has(key_587)) {
615
+ if (multis_580 == null) {
616
+ t_563 = mapBuilderConstructor_579();
617
+ multis_580 = t_563;
618
+ }
619
+ try {
620
+ if (multis_580 == null) {
621
+ throw Error();
622
+ } else {
623
+ t_570 = multis_580;
624
+ }
625
+ t_571 = t_570;
626
+ } catch {
627
+ t_564 = panic_586();
628
+ t_571 = t_564;
629
+ }
630
+ const mb_590 = t_571;
631
+ if (! mb_590.has(key_587)) {
632
+ try {
633
+ t_572 = mappedGet_591(m_578, key_587);
634
+ t_573 = t_572;
635
+ } catch {
636
+ t_565 = panic_586();
637
+ t_573 = t_565;
638
+ }
639
+ mapBuilderSet_592(mb_590, key_587, t_573.slice());
640
+ }
641
+ try {
642
+ t_574 = mappedGet_591(mb_590, key_587);
643
+ t_575 = t_574;
644
+ } catch {
645
+ t_566 = panic_586();
646
+ t_575 = t_566;
647
+ }
648
+ listBuilderAdd_500(t_575, value_589);
649
+ } else {
650
+ mapBuilderSet_592(m_578, key_587, Object.freeze([value_589]));
651
+ }
652
+ }
653
+ const multis_593 = multis_580;
654
+ if (!(multis_593 == null)) {
655
+ function fn_594(k_595, vs_596) {
656
+ let t_597 = listBuilderToList_598(vs_596);
657
+ mapBuilderSet_592(m_578, k_595, t_597);
658
+ return;
659
+ }
660
+ mappedForEach_436(multis_593, fn_594);
661
+ }
662
+ t_567 = new JsonObject(mappedToMap_599(m_578));
663
+ this.#storeValue_555(t_567);
664
+ return_561 = void 0;
665
+ }
666
+ return return_561;
667
+ }
668
+ /** @param {string} key_601 */
669
+ objectKey(key_601) {
670
+ let t_602 = new JsonString(key_601);
671
+ this.#storeValue_555(t_602);
672
+ return;
673
+ }
674
+ startArray() {
675
+ let t_604 = [];
676
+ listBuilderAdd_500(this.#stack_549, t_604);
677
+ return;
678
+ }
679
+ endArray() {
680
+ let return_606;
681
+ let t_607;
682
+ fn_608: {
683
+ if (! this.#stack_549.length) {
684
+ return_606 = void 0;
685
+ break fn_608;
686
+ }
687
+ const ls_609 = listBuilderRemoveLast_517(this.#stack_549);
688
+ t_607 = new JsonArray(listBuilderToList_598(ls_609));
689
+ this.#storeValue_555(t_607);
690
+ return_606 = void 0;
691
+ }
692
+ return return_606;
693
+ }
694
+ nullValue() {
695
+ let t_611 = new JsonNull();
696
+ this.#storeValue_555(t_611);
697
+ return;
698
+ }
699
+ /** @param {boolean} x_613 */
700
+ booleanValue(x_613) {
701
+ let t_614 = new JsonBoolean(x_613);
702
+ this.#storeValue_555(t_614);
703
+ return;
704
+ }
705
+ /** @param {number} x_616 */
706
+ intValue(x_616) {
707
+ let t_617 = new JsonInt(x_616);
708
+ this.#storeValue_555(t_617);
709
+ return;
710
+ }
711
+ /** @param {number} x_619 */
712
+ float64Value(x_619) {
713
+ let t_620 = new JsonFloat64(x_619);
714
+ this.#storeValue_555(t_620);
715
+ return;
716
+ }
717
+ /** @param {string} x_622 */
718
+ numericTokenValue(x_622) {
719
+ let t_623 = new JsonNumericToken(x_622);
720
+ this.#storeValue_555(t_623);
721
+ return;
722
+ }
723
+ /** @param {string} x_625 */
724
+ stringValue(x_625) {
725
+ let t_626 = new JsonString(x_625);
726
+ this.#storeValue_555(t_626);
727
+ return;
728
+ }
729
+ /** @returns {JsonSyntaxTree} */
730
+ toJsonSyntaxTree() {
731
+ let t_628;
732
+ if (this.#stack_549.length !== 1) {
733
+ t_628 = true;
734
+ } else {
735
+ t_628 = !(this.#error_550 == null);
736
+ }
737
+ if (t_628) {
738
+ throw Error();
739
+ }
740
+ const ls_629 = listedGet_424(this.#stack_549, 0);
741
+ if (ls_629.length !== 1) {
742
+ throw Error();
743
+ }
744
+ return listedGet_424(ls_629, 0);
745
+ }
746
+ /** @returns {string | null} */
747
+ get jsonError() {
748
+ return this.#error_550;
749
+ }
750
+ /** @returns {JsonParseErrorReceiver} */
751
+ get parseErrorReceiver() {
752
+ return this;
753
+ }
754
+ /** @param {string} error_633 */
755
+ explainJsonError(error_633) {
756
+ this.#error_550 = error_633;
757
+ return;
758
+ }
759
+ };
760
+ /**
761
+ * @param {string} sourceText_635
762
+ * @param {globalThis.number} i_636
763
+ * @param {JsonProducer} out_637
764
+ * @returns {globalThis.number}
765
+ */
766
+ function parseJsonValue_634(sourceText_635, i_636, out_637) {
767
+ let return_638;
768
+ let t_639;
769
+ let t_640;
770
+ let t_641;
771
+ fn_642: {
772
+ t_639 = skipJsonSpaces_643(sourceText_635, i_636);
773
+ i_636 = t_639;
774
+ if (!(sourceText_635.length > i_636)) {
775
+ expectedTokenError_644(sourceText_635, i_636, out_637, "JSON value");
776
+ return_638 = -1;
777
+ break fn_642;
778
+ }
779
+ t_640 = stringGet_645(sourceText_635, i_636);
780
+ if (t_640 === 123) {
781
+ return_638 = parseJsonObject_646(sourceText_635, i_636, out_637);
782
+ } else if (t_640 === 91) {
783
+ return_638 = parseJsonArray_647(sourceText_635, i_636, out_637);
784
+ } else if (t_640 === 34) {
785
+ return_638 = parseJsonString_648(sourceText_635, i_636, out_637);
786
+ } else {
787
+ if (t_640 === 116) {
788
+ t_641 = true;
789
+ } else {
790
+ t_641 = t_640 === 102;
791
+ }
792
+ if (t_641) {
793
+ return_638 = parseJsonBoolean_649(sourceText_635, i_636, out_637);
794
+ } else if (t_640 === 110) {
795
+ return_638 = parseJsonNull_650(sourceText_635, i_636, out_637);
796
+ } else {
797
+ return_638 = parseJsonNumber_651(sourceText_635, i_636, out_637);
798
+ }
799
+ }
800
+ }
801
+ return return_638;
802
+ }
803
+ /** @template T_652 */
804
+ export class JsonAdapter extends type__392() {
805
+ /**
806
+ * @param {T_652} x_654
807
+ * @param {JsonProducer} p_655
808
+ */
809
+ encodeToJson(x_654, p_655) {
810
+ null;
811
+ }
812
+ /**
813
+ * @param {JsonSyntaxTree} t_657
814
+ * @param {InterchangeContext} ic_658
815
+ * @returns {T_652}
816
+ */
817
+ decodeFromJson(t_657, ic_658) {
818
+ null;
819
+ }
820
+ };
821
+ class BooleanJsonAdapter_659 extends type__392(JsonAdapter) {
822
+ /**
823
+ * @param {boolean} x_661
824
+ * @param {JsonProducer} p_662
825
+ */
826
+ encodeToJson(x_661, p_662) {
827
+ p_662.booleanValue(x_661);
828
+ return;
829
+ }
830
+ /**
831
+ * @param {JsonSyntaxTree} t_664
832
+ * @param {InterchangeContext} ic_665
833
+ * @returns {boolean}
834
+ */
835
+ decodeFromJson(t_664, ic_665) {
836
+ let t_666;
837
+ t_666 = requireInstanceOf__585(t_664, JsonBoolean);
838
+ return t_666.content;
839
+ }
840
+ constructor() {
841
+ super ();
842
+ return;
843
+ }
844
+ }
845
+ class Float64JsonAdapter_667 extends type__392(JsonAdapter) {
846
+ /**
847
+ * @param {number} x_669
848
+ * @param {JsonProducer} p_670
849
+ */
850
+ encodeToJson(x_669, p_670) {
851
+ p_670.float64Value(x_669);
852
+ return;
853
+ }
854
+ /**
855
+ * @param {JsonSyntaxTree} t_672
856
+ * @param {InterchangeContext} ic_673
857
+ * @returns {number}
858
+ */
859
+ decodeFromJson(t_672, ic_673) {
860
+ let t_674;
861
+ t_674 = requireInstanceOf__585(t_672, JsonNumeric);
862
+ return t_674.asFloat64();
863
+ }
864
+ constructor() {
865
+ super ();
866
+ return;
867
+ }
868
+ }
869
+ class IntJsonAdapter_675 extends type__392(JsonAdapter) {
870
+ /**
871
+ * @param {number} x_677
872
+ * @param {JsonProducer} p_678
873
+ */
874
+ encodeToJson(x_677, p_678) {
875
+ p_678.intValue(x_677);
876
+ return;
877
+ }
878
+ /**
879
+ * @param {JsonSyntaxTree} t_680
880
+ * @param {InterchangeContext} ic_681
881
+ * @returns {number}
882
+ */
883
+ decodeFromJson(t_680, ic_681) {
884
+ let t_682;
885
+ t_682 = requireInstanceOf__585(t_680, JsonNumeric);
886
+ return t_682.asInt();
887
+ }
888
+ constructor() {
889
+ super ();
890
+ return;
891
+ }
892
+ }
893
+ class StringJsonAdapter_683 extends type__392(JsonAdapter) {
894
+ /**
895
+ * @param {string} x_685
896
+ * @param {JsonProducer} p_686
897
+ */
898
+ encodeToJson(x_685, p_686) {
899
+ p_686.stringValue(x_685);
900
+ return;
901
+ }
902
+ /**
903
+ * @param {JsonSyntaxTree} t_688
904
+ * @param {InterchangeContext} ic_689
905
+ * @returns {string}
906
+ */
907
+ decodeFromJson(t_688, ic_689) {
908
+ let t_690;
909
+ t_690 = requireInstanceOf__585(t_688, JsonString);
910
+ return t_690.content;
911
+ }
912
+ constructor() {
913
+ super ();
914
+ return;
915
+ }
916
+ }
917
+ /** @template T_692 */
918
+ class ListJsonAdapter_691 extends type__392(JsonAdapter) {
919
+ /** @type {JsonAdapter<T_692>} */
920
+ #adapterForT_693;
921
+ /**
922
+ * @param {Array<T_692>} x_695
923
+ * @param {JsonProducer} p_696
924
+ */
925
+ encodeToJson(x_695, p_696) {
926
+ const this699 = this;
927
+ p_696.startArray();
928
+ function fn_697(el_698) {
929
+ this699.#adapterForT_693.encodeToJson(el_698, p_696);
930
+ return;
931
+ }
932
+ x_695.forEach(fn_697);
933
+ p_696.endArray();
934
+ return;
935
+ }
936
+ /**
937
+ * @param {JsonSyntaxTree} t_701
938
+ * @param {InterchangeContext} ic_702
939
+ * @returns {Array<T_692>}
940
+ */
941
+ decodeFromJson(t_701, ic_702) {
942
+ let t_703;
943
+ const b_704 = [];
944
+ let t_705;
945
+ t_705 = requireInstanceOf__585(t_701, JsonArray);
946
+ const elements_706 = t_705.elements;
947
+ const n_707 = elements_706.length;
948
+ let i_708 = 0;
949
+ while (i_708 < n_707) {
950
+ const el_709 = listedGet_424(elements_706, i_708);
951
+ i_708 = i_708 + 1;
952
+ t_703 = this.#adapterForT_693.decodeFromJson(el_709, ic_702);
953
+ listBuilderAdd_500(b_704, t_703);
954
+ }
955
+ return listBuilderToList_598(b_704);
956
+ }
957
+ /** @param {JsonAdapter<T_692>} adapterForT_710 */
958
+ constructor(adapterForT_710) {
959
+ super ();
960
+ this.#adapterForT_693 = adapterForT_710;
961
+ return;
962
+ }
963
+ }
964
+ /** @template T_711 */
965
+ export class OrNullJsonAdapter extends type__392(JsonAdapter) {
966
+ /** @type {JsonAdapter<T_711>} */
967
+ #adapterForT_712;
968
+ /**
969
+ * @param {T_711 | null} x_714
970
+ * @param {JsonProducer} p_715
971
+ */
972
+ encodeToJson(x_714, p_715) {
973
+ if (x_714 == null) {
974
+ p_715.nullValue();
975
+ } else {
976
+ const x_716 = x_714;
977
+ this.#adapterForT_712.encodeToJson(x_716, p_715);
978
+ }
979
+ return;
980
+ }
981
+ /**
982
+ * @param {JsonSyntaxTree} t_718
983
+ * @param {InterchangeContext} ic_719
984
+ * @returns {T_711 | null}
985
+ */
986
+ decodeFromJson(t_718, ic_719) {
987
+ let return_720;
988
+ if (t_718 instanceof JsonNull) {
989
+ return_720 = null;
990
+ } else {
991
+ return_720 = this.#adapterForT_712.decodeFromJson(t_718, ic_719);
992
+ }
993
+ return return_720;
994
+ }
995
+ /** @param {JsonAdapter<T_711>} adapterForT_721 */
996
+ constructor(adapterForT_721) {
997
+ super ();
998
+ this.#adapterForT_712 = adapterForT_721;
999
+ return;
1000
+ }
1001
+ };
1002
+ /** @type {Array<string>} */
1003
+ const hexDigits_722 = Object.freeze(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]);
1004
+ /**
1005
+ * @param {number} cp_724
1006
+ * @param {globalThis.Array<string>} buffer_725
1007
+ */
1008
+ function encodeHex4_723(cp_724, buffer_725) {
1009
+ const b0_726 = trunc__727(cp_724 / 4096) & 15;
1010
+ const b1_728 = trunc__727(cp_724 / 256) & 15;
1011
+ const b2_729 = trunc__727(cp_724 / 16) & 15;
1012
+ const b3_730 = cp_724 & 15;
1013
+ let t_731 = listedGet_424(hexDigits_722, b0_726);
1014
+ buffer_725[0] += t_731;
1015
+ let t_732 = listedGet_424(hexDigits_722, b1_728);
1016
+ buffer_725[0] += t_732;
1017
+ let t_733 = listedGet_424(hexDigits_722, b2_729);
1018
+ buffer_725[0] += t_733;
1019
+ let t_734 = listedGet_424(hexDigits_722, b3_730);
1020
+ buffer_725[0] += t_734;
1021
+ return;
1022
+ }
1023
+ /**
1024
+ * @param {string} x_735
1025
+ * @param {globalThis.Array<string>} buffer_736
1026
+ */
1027
+ function encodeJsonString_522(x_735, buffer_736) {
1028
+ let t_737;
1029
+ let t_738;
1030
+ let t_739;
1031
+ let t_740;
1032
+ buffer_736[0] += "\u0022";
1033
+ let i_741 = 0;
1034
+ let emitted_742 = i_741;
1035
+ while (true) {
1036
+ if (!(x_735.length > i_741)) {
1037
+ break;
1038
+ }
1039
+ const cp_743 = stringGet_645(x_735, i_741);
1040
+ if (cp_743 === 8) {
1041
+ t_740 = "\\b";
1042
+ } else if (cp_743 === 9) {
1043
+ t_740 = "\\t";
1044
+ } else if (cp_743 === 10) {
1045
+ t_740 = "\\n";
1046
+ } else if (cp_743 === 12) {
1047
+ t_740 = "\\f";
1048
+ } else if (cp_743 === 13) {
1049
+ t_740 = "\\r";
1050
+ } else if (cp_743 === 34) {
1051
+ t_740 = "\\\u0022";
1052
+ } else if (cp_743 === 92) {
1053
+ t_740 = "\\\\";
1054
+ } else {
1055
+ if (cp_743 < 32) {
1056
+ t_738 = true;
1057
+ } else {
1058
+ if (55296 <= cp_743) {
1059
+ t_737 = cp_743 <= 57343;
1060
+ } else {
1061
+ t_737 = false;
1062
+ }
1063
+ t_738 = t_737;
1064
+ }
1065
+ if (t_738) {
1066
+ t_739 = "\\u";
1067
+ } else {
1068
+ t_739 = "";
1069
+ }
1070
+ t_740 = t_739;
1071
+ }
1072
+ const replacement_744 = t_740;
1073
+ const nextI_745 = stringNext_746(x_735, i_741);
1074
+ if (replacement_744 !== "") {
1075
+ buffer_736[0] += x_735.substring(emitted_742, i_741);
1076
+ buffer_736[0] += replacement_744;
1077
+ if (replacement_744 === "\\u") {
1078
+ encodeHex4_723(cp_743, buffer_736);
1079
+ }
1080
+ emitted_742 = nextI_745;
1081
+ }
1082
+ i_741 = nextI_745;
1083
+ }
1084
+ buffer_736[0] += x_735.substring(emitted_742, i_741);
1085
+ buffer_736[0] += "\u0022";
1086
+ return;
1087
+ }
1088
+ /**
1089
+ * @param {JsonProducer} out_748
1090
+ * @param {string} explanation_749
1091
+ */
1092
+ function storeJsonError_747(out_748, explanation_749) {
1093
+ let t_750 = out_748.parseErrorReceiver;
1094
+ if (!(t_750 == null)) {
1095
+ t_750.explainJsonError(explanation_749);
1096
+ }
1097
+ return;
1098
+ }
1099
+ /**
1100
+ * @param {string} sourceText_751
1101
+ * @param {globalThis.number} i_752
1102
+ * @param {JsonProducer} out_753
1103
+ * @param {string} shortExplanation_754
1104
+ */
1105
+ function expectedTokenError_644(sourceText_751, i_752, out_753, shortExplanation_754) {
1106
+ let t_755;
1107
+ let t_756;
1108
+ let gotten_757;
1109
+ if (sourceText_751.length > i_752) {
1110
+ t_755 = sourceText_751.length;
1111
+ t_756 = sourceText_751.substring(i_752, t_755);
1112
+ gotten_757 = "`" + t_756 + "`";
1113
+ } else {
1114
+ gotten_757 = "end-of-file";
1115
+ }
1116
+ storeJsonError_747(out_753, "Expected " + shortExplanation_754 + ", but got " + gotten_757);
1117
+ return;
1118
+ }
1119
+ /**
1120
+ * @param {string} sourceText_758
1121
+ * @param {globalThis.number} i_759
1122
+ * @returns {globalThis.number}
1123
+ */
1124
+ function skipJsonSpaces_643(sourceText_758, i_759) {
1125
+ let t_760;
1126
+ let t_761;
1127
+ let t_762;
1128
+ let t_763;
1129
+ let t_764;
1130
+ while (true) {
1131
+ if (!(sourceText_758.length > i_759)) {
1132
+ break;
1133
+ }
1134
+ t_760 = stringGet_645(sourceText_758, i_759);
1135
+ if (t_760 === 9) {
1136
+ t_764 = true;
1137
+ } else {
1138
+ if (t_760 === 10) {
1139
+ t_763 = true;
1140
+ } else {
1141
+ if (t_760 === 13) {
1142
+ t_762 = true;
1143
+ } else {
1144
+ t_762 = t_760 === 32;
1145
+ }
1146
+ t_763 = t_762;
1147
+ }
1148
+ t_764 = t_763;
1149
+ }
1150
+ if (! t_764) {
1151
+ break;
1152
+ }
1153
+ t_761 = stringNext_746(sourceText_758, i_759);
1154
+ i_759 = t_761;
1155
+ }
1156
+ return i_759;
1157
+ }
1158
+ /**
1159
+ * @param {string} sourceText_766
1160
+ * @param {globalThis.number} start_767
1161
+ * @param {globalThis.number} limit_768
1162
+ * @returns {number}
1163
+ */
1164
+ function decodeHexUnsigned_765(sourceText_766, start_767, limit_768) {
1165
+ let return_769;
1166
+ let t_770;
1167
+ let t_771;
1168
+ let t_772;
1169
+ let t_773;
1170
+ let t_774;
1171
+ fn_775: {
1172
+ let n_776 = 0;
1173
+ let i_777 = start_767;
1174
+ while (true) {
1175
+ if (!(i_777 - limit_768 < 0)) {
1176
+ break;
1177
+ }
1178
+ const cp_778 = stringGet_645(sourceText_766, i_777);
1179
+ if (48 <= cp_778) {
1180
+ t_771 = cp_778 <= 48;
1181
+ } else {
1182
+ t_771 = false;
1183
+ }
1184
+ if (t_771) {
1185
+ t_774 = cp_778 - 48;
1186
+ } else {
1187
+ if (65 <= cp_778) {
1188
+ t_772 = cp_778 <= 70;
1189
+ } else {
1190
+ t_772 = false;
1191
+ }
1192
+ if (t_772) {
1193
+ t_774 = cp_778 - 65 + 10;
1194
+ } else {
1195
+ if (97 <= cp_778) {
1196
+ t_773 = cp_778 <= 102;
1197
+ } else {
1198
+ t_773 = false;
1199
+ }
1200
+ if (t_773) {
1201
+ t_774 = cp_778 - 97 + 10;
1202
+ } else {
1203
+ return_769 = -1;
1204
+ break fn_775;
1205
+ }
1206
+ }
1207
+ }
1208
+ const digit_779 = t_774;
1209
+ n_776 = n_776 * 16 + digit_779;
1210
+ t_770 = stringNext_746(sourceText_766, i_777);
1211
+ i_777 = t_770;
1212
+ }
1213
+ return_769 = n_776;
1214
+ }
1215
+ return return_769;
1216
+ }
1217
+ /**
1218
+ * @param {string} sourceText_781
1219
+ * @param {globalThis.number} i_782
1220
+ * @param {globalThis.Array<string>} sb_783
1221
+ * @param {JsonProducer} errOut_784
1222
+ * @returns {globalThis.number}
1223
+ */
1224
+ function parseJsonStringTo_780(sourceText_781, i_782, sb_783, errOut_784) {
1225
+ let return_785;
1226
+ let t_786;
1227
+ let t_787;
1228
+ let t_788;
1229
+ let t_789;
1230
+ let t_790;
1231
+ let t_791;
1232
+ let t_792;
1233
+ let t_793;
1234
+ let t_794;
1235
+ let t_795;
1236
+ let t_796;
1237
+ let t_797;
1238
+ let t_798;
1239
+ let t_799;
1240
+ let t_800;
1241
+ let t_801;
1242
+ let t_802;
1243
+ let t_803;
1244
+ let t_804;
1245
+ let t_805;
1246
+ let t_806;
1247
+ let t_807;
1248
+ let t_808;
1249
+ fn_809: {
1250
+ if (!(sourceText_781.length > i_782)) {
1251
+ t_797 = true;
1252
+ } else {
1253
+ t_786 = stringGet_645(sourceText_781, i_782);
1254
+ t_797 = t_786 !== 34;
1255
+ }
1256
+ if (t_797) {
1257
+ expectedTokenError_644(sourceText_781, i_782, errOut_784, "\u0022");
1258
+ return_785 = -1;
1259
+ break fn_809;
1260
+ }
1261
+ t_787 = stringNext_746(sourceText_781, i_782);
1262
+ i_782 = t_787;
1263
+ let leadSurrogate_810 = -1;
1264
+ let consumed_811 = i_782;
1265
+ while (true) {
1266
+ if (!(sourceText_781.length > i_782)) {
1267
+ break;
1268
+ }
1269
+ const cp_812 = stringGet_645(sourceText_781, i_782);
1270
+ if (cp_812 === 34) {
1271
+ break;
1272
+ }
1273
+ t_788 = stringNext_746(sourceText_781, i_782);
1274
+ let iNext_813 = t_788;
1275
+ const end_814 = sourceText_781.length;
1276
+ let needToFlush_815 = false;
1277
+ if (cp_812 !== 92) {
1278
+ t_803 = cp_812;
1279
+ } else {
1280
+ needToFlush_815 = true;
1281
+ if (!(sourceText_781.length > iNext_813)) {
1282
+ expectedTokenError_644(sourceText_781, iNext_813, errOut_784, "escape sequence");
1283
+ return_785 = -1;
1284
+ break fn_809;
1285
+ }
1286
+ const esc0_816 = stringGet_645(sourceText_781, iNext_813);
1287
+ t_789 = stringNext_746(sourceText_781, iNext_813);
1288
+ iNext_813 = t_789;
1289
+ if (esc0_816 === 34) {
1290
+ t_799 = true;
1291
+ } else {
1292
+ if (esc0_816 === 92) {
1293
+ t_798 = true;
1294
+ } else {
1295
+ t_798 = esc0_816 === 47;
1296
+ }
1297
+ t_799 = t_798;
1298
+ }
1299
+ if (t_799) {
1300
+ t_802 = esc0_816;
1301
+ } else if (esc0_816 === 98) {
1302
+ t_802 = 8;
1303
+ } else if (esc0_816 === 102) {
1304
+ t_802 = 12;
1305
+ } else if (esc0_816 === 110) {
1306
+ t_802 = 10;
1307
+ } else if (esc0_816 === 114) {
1308
+ t_802 = 13;
1309
+ } else if (esc0_816 === 116) {
1310
+ t_802 = 9;
1311
+ } else if (esc0_816 === 117) {
1312
+ if (stringHasAtLeast_817(sourceText_781, iNext_813, end_814, 4)) {
1313
+ const startHex_818 = iNext_813;
1314
+ t_790 = stringNext_746(sourceText_781, iNext_813);
1315
+ iNext_813 = t_790;
1316
+ t_791 = stringNext_746(sourceText_781, iNext_813);
1317
+ iNext_813 = t_791;
1318
+ t_792 = stringNext_746(sourceText_781, iNext_813);
1319
+ iNext_813 = t_792;
1320
+ t_793 = stringNext_746(sourceText_781, iNext_813);
1321
+ iNext_813 = t_793;
1322
+ t_794 = decodeHexUnsigned_765(sourceText_781, startHex_818, iNext_813);
1323
+ t_800 = t_794;
1324
+ } else {
1325
+ t_800 = -1;
1326
+ }
1327
+ const hex_819 = t_800;
1328
+ if (hex_819 < 0) {
1329
+ expectedTokenError_644(sourceText_781, iNext_813, errOut_784, "four hex digits");
1330
+ return_785 = -1;
1331
+ break fn_809;
1332
+ }
1333
+ t_801 = hex_819;
1334
+ t_802 = t_801;
1335
+ } else {
1336
+ expectedTokenError_644(sourceText_781, iNext_813, errOut_784, "escape sequence");
1337
+ return_785 = -1;
1338
+ break fn_809;
1339
+ }
1340
+ t_803 = t_802;
1341
+ }
1342
+ let decodedCp_820 = t_803;
1343
+ if (leadSurrogate_810 >= 0) {
1344
+ needToFlush_815 = true;
1345
+ const lead_821 = leadSurrogate_810;
1346
+ if (56320 <= decodedCp_820) {
1347
+ t_804 = decodedCp_820 <= 57343;
1348
+ } else {
1349
+ t_804 = false;
1350
+ }
1351
+ if (t_804) {
1352
+ leadSurrogate_810 = -1;
1353
+ t_805 = (lead_821 - 55296) * 1024 | decodedCp_820 - 56320;
1354
+ decodedCp_820 = 65536 + t_805;
1355
+ }
1356
+ } else {
1357
+ if (55296 <= decodedCp_820) {
1358
+ t_806 = decodedCp_820 <= 56319;
1359
+ } else {
1360
+ t_806 = false;
1361
+ }
1362
+ if (t_806) {
1363
+ needToFlush_815 = true;
1364
+ }
1365
+ }
1366
+ if (needToFlush_815) {
1367
+ sb_783[0] += sourceText_781.substring(consumed_811, i_782);
1368
+ if (leadSurrogate_810 >= 0) {
1369
+ try {
1370
+ stringBuilderAppendCodePoint_822(sb_783, leadSurrogate_810);
1371
+ } catch {
1372
+ throw Error();
1373
+ }
1374
+ }
1375
+ if (55296 <= decodedCp_820) {
1376
+ t_807 = decodedCp_820 <= 56319;
1377
+ } else {
1378
+ t_807 = false;
1379
+ }
1380
+ if (t_807) {
1381
+ leadSurrogate_810 = decodedCp_820;
1382
+ } else {
1383
+ leadSurrogate_810 = -1;
1384
+ try {
1385
+ stringBuilderAppendCodePoint_822(sb_783, decodedCp_820);
1386
+ } catch {
1387
+ throw Error();
1388
+ }
1389
+ }
1390
+ consumed_811 = iNext_813;
1391
+ }
1392
+ i_782 = iNext_813;
1393
+ }
1394
+ if (!(sourceText_781.length > i_782)) {
1395
+ t_808 = true;
1396
+ } else {
1397
+ t_795 = stringGet_645(sourceText_781, i_782);
1398
+ t_808 = t_795 !== 34;
1399
+ }
1400
+ if (t_808) {
1401
+ expectedTokenError_644(sourceText_781, i_782, errOut_784, "\u0022");
1402
+ return_785 = -1;
1403
+ } else {
1404
+ if (leadSurrogate_810 >= 0) {
1405
+ try {
1406
+ stringBuilderAppendCodePoint_822(sb_783, leadSurrogate_810);
1407
+ } catch {
1408
+ throw Error();
1409
+ }
1410
+ } else {
1411
+ sb_783[0] += sourceText_781.substring(consumed_811, i_782);
1412
+ }
1413
+ t_796 = stringNext_746(sourceText_781, i_782);
1414
+ i_782 = t_796;
1415
+ return_785 = i_782;
1416
+ }
1417
+ }
1418
+ return return_785;
1419
+ }
1420
+ /**
1421
+ * @param {string} sourceText_823
1422
+ * @param {globalThis.number} i_824
1423
+ * @param {JsonProducer} out_825
1424
+ * @returns {globalThis.number}
1425
+ */
1426
+ function parseJsonObject_646(sourceText_823, i_824, out_825) {
1427
+ let return_826;
1428
+ let t_827;
1429
+ let t_828;
1430
+ let t_829;
1431
+ let t_830;
1432
+ let t_831;
1433
+ let t_832;
1434
+ let t_833;
1435
+ let t_834;
1436
+ let t_835;
1437
+ let t_836;
1438
+ let t_837;
1439
+ let t_838;
1440
+ let t_839;
1441
+ let t_840;
1442
+ let t_841;
1443
+ let t_842;
1444
+ let t_843;
1445
+ let t_844;
1446
+ let t_845;
1447
+ let t_846;
1448
+ let t_847;
1449
+ let t_848;
1450
+ fn_849: {
1451
+ try {
1452
+ if (!(sourceText_823.length > i_824)) {
1453
+ t_841 = true;
1454
+ } else {
1455
+ t_827 = stringGet_645(sourceText_823, i_824);
1456
+ t_841 = t_827 !== 123;
1457
+ }
1458
+ if (t_841) {
1459
+ expectedTokenError_644(sourceText_823, i_824, out_825, "'{'");
1460
+ return_826 = -1;
1461
+ break fn_849;
1462
+ }
1463
+ out_825.startObject();
1464
+ t_828 = stringNext_746(sourceText_823, i_824);
1465
+ t_829 = skipJsonSpaces_643(sourceText_823, t_828);
1466
+ i_824 = t_829;
1467
+ if (sourceText_823.length > i_824) {
1468
+ t_830 = stringGet_645(sourceText_823, i_824);
1469
+ t_842 = t_830 !== 125;
1470
+ } else {
1471
+ t_842 = false;
1472
+ }
1473
+ if (t_842) {
1474
+ while (true) {
1475
+ const keyBuffer_850 = [""];
1476
+ const afterKey_851 = parseJsonStringTo_780(sourceText_823, i_824, keyBuffer_850, out_825);
1477
+ if (!(afterKey_851 >= 0)) {
1478
+ return_826 = -1;
1479
+ break fn_849;
1480
+ }
1481
+ t_831 = keyBuffer_850[0];
1482
+ out_825.objectKey(t_831);
1483
+ try {
1484
+ t_843 = requireStringIndex__852(afterKey_851);
1485
+ t_844 = t_843;
1486
+ } catch {
1487
+ t_832 = panic_586();
1488
+ t_844 = t_832;
1489
+ }
1490
+ t_833 = skipJsonSpaces_643(sourceText_823, t_844);
1491
+ i_824 = t_833;
1492
+ if (sourceText_823.length > i_824) {
1493
+ t_834 = stringGet_645(sourceText_823, i_824);
1494
+ t_845 = t_834 === 58;
1495
+ } else {
1496
+ t_845 = false;
1497
+ }
1498
+ if (t_845) {
1499
+ t_835 = stringNext_746(sourceText_823, i_824);
1500
+ i_824 = t_835;
1501
+ const afterPropertyValue_853 = parseJsonValue_634(sourceText_823, i_824, out_825);
1502
+ if (!(afterPropertyValue_853 >= 0)) {
1503
+ return_826 = -1;
1504
+ break fn_849;
1505
+ }
1506
+ t_846 = requireStringIndex__852(afterPropertyValue_853);
1507
+ i_824 = t_846;
1508
+ } else {
1509
+ expectedTokenError_644(sourceText_823, i_824, out_825, "':'");
1510
+ return_826 = -1;
1511
+ break fn_849;
1512
+ }
1513
+ t_836 = skipJsonSpaces_643(sourceText_823, i_824);
1514
+ i_824 = t_836;
1515
+ if (sourceText_823.length > i_824) {
1516
+ t_837 = stringGet_645(sourceText_823, i_824);
1517
+ t_847 = t_837 === 44;
1518
+ } else {
1519
+ t_847 = false;
1520
+ }
1521
+ if (t_847) {
1522
+ t_838 = stringNext_746(sourceText_823, i_824);
1523
+ t_839 = skipJsonSpaces_643(sourceText_823, t_838);
1524
+ i_824 = t_839;
1525
+ } else {
1526
+ break;
1527
+ }
1528
+ }
1529
+ }
1530
+ if (sourceText_823.length > i_824) {
1531
+ t_840 = stringGet_645(sourceText_823, i_824);
1532
+ t_848 = t_840 === 125;
1533
+ } else {
1534
+ t_848 = false;
1535
+ }
1536
+ if (t_848) {
1537
+ out_825.endObject();
1538
+ return_826 = stringNext_746(sourceText_823, i_824);
1539
+ } else {
1540
+ expectedTokenError_644(sourceText_823, i_824, out_825, "'}'");
1541
+ return_826 = -1;
1542
+ }
1543
+ } catch {
1544
+ return_826 = panic_586();
1545
+ }
1546
+ }
1547
+ return return_826;
1548
+ }
1549
+ /**
1550
+ * @param {string} sourceText_854
1551
+ * @param {globalThis.number} i_855
1552
+ * @param {JsonProducer} out_856
1553
+ * @returns {globalThis.number}
1554
+ */
1555
+ function parseJsonArray_647(sourceText_854, i_855, out_856) {
1556
+ let return_857;
1557
+ let t_858;
1558
+ let t_859;
1559
+ let t_860;
1560
+ let t_861;
1561
+ let t_862;
1562
+ let t_863;
1563
+ let t_864;
1564
+ let t_865;
1565
+ let t_866;
1566
+ let t_867;
1567
+ let t_868;
1568
+ let t_869;
1569
+ let t_870;
1570
+ let t_871;
1571
+ fn_872: {
1572
+ try {
1573
+ if (!(sourceText_854.length > i_855)) {
1574
+ t_867 = true;
1575
+ } else {
1576
+ t_858 = stringGet_645(sourceText_854, i_855);
1577
+ t_867 = t_858 !== 91;
1578
+ }
1579
+ if (t_867) {
1580
+ expectedTokenError_644(sourceText_854, i_855, out_856, "'['");
1581
+ return_857 = -1;
1582
+ break fn_872;
1583
+ }
1584
+ out_856.startArray();
1585
+ t_859 = stringNext_746(sourceText_854, i_855);
1586
+ t_860 = skipJsonSpaces_643(sourceText_854, t_859);
1587
+ i_855 = t_860;
1588
+ if (sourceText_854.length > i_855) {
1589
+ t_861 = stringGet_645(sourceText_854, i_855);
1590
+ t_868 = t_861 !== 93;
1591
+ } else {
1592
+ t_868 = false;
1593
+ }
1594
+ if (t_868) {
1595
+ while (true) {
1596
+ const afterElementValue_873 = parseJsonValue_634(sourceText_854, i_855, out_856);
1597
+ if (!(afterElementValue_873 >= 0)) {
1598
+ return_857 = -1;
1599
+ break fn_872;
1600
+ }
1601
+ t_869 = requireStringIndex__852(afterElementValue_873);
1602
+ i_855 = t_869;
1603
+ t_862 = skipJsonSpaces_643(sourceText_854, i_855);
1604
+ i_855 = t_862;
1605
+ if (sourceText_854.length > i_855) {
1606
+ t_863 = stringGet_645(sourceText_854, i_855);
1607
+ t_870 = t_863 === 44;
1608
+ } else {
1609
+ t_870 = false;
1610
+ }
1611
+ if (t_870) {
1612
+ t_864 = stringNext_746(sourceText_854, i_855);
1613
+ t_865 = skipJsonSpaces_643(sourceText_854, t_864);
1614
+ i_855 = t_865;
1615
+ } else {
1616
+ break;
1617
+ }
1618
+ }
1619
+ }
1620
+ if (sourceText_854.length > i_855) {
1621
+ t_866 = stringGet_645(sourceText_854, i_855);
1622
+ t_871 = t_866 === 93;
1623
+ } else {
1624
+ t_871 = false;
1625
+ }
1626
+ if (t_871) {
1627
+ out_856.endArray();
1628
+ return_857 = stringNext_746(sourceText_854, i_855);
1629
+ } else {
1630
+ expectedTokenError_644(sourceText_854, i_855, out_856, "']'");
1631
+ return_857 = -1;
1632
+ }
1633
+ } catch {
1634
+ return_857 = panic_586();
1635
+ }
1636
+ }
1637
+ return return_857;
1638
+ }
1639
+ /**
1640
+ * @param {string} sourceText_874
1641
+ * @param {globalThis.number} i_875
1642
+ * @param {JsonProducer} out_876
1643
+ * @returns {globalThis.number}
1644
+ */
1645
+ function parseJsonString_648(sourceText_874, i_875, out_876) {
1646
+ let t_877;
1647
+ const sb_878 = [""];
1648
+ const after_879 = parseJsonStringTo_780(sourceText_874, i_875, sb_878, out_876);
1649
+ if (after_879 >= 0) {
1650
+ t_877 = sb_878[0];
1651
+ out_876.stringValue(t_877);
1652
+ }
1653
+ return after_879;
1654
+ }
1655
+ /**
1656
+ * @param {string} string_881
1657
+ * @param {globalThis.number} inString_882
1658
+ * @param {string} substring_883
1659
+ * @returns {globalThis.number}
1660
+ */
1661
+ function afterSubstring_880(string_881, inString_882, substring_883) {
1662
+ let return_884;
1663
+ let t_885;
1664
+ let t_886;
1665
+ fn_887: {
1666
+ let i_888 = inString_882;
1667
+ let j_889 = 0;
1668
+ while (true) {
1669
+ if (!(substring_883.length > j_889)) {
1670
+ break;
1671
+ }
1672
+ if (!(string_881.length > i_888)) {
1673
+ return_884 = -1;
1674
+ break fn_887;
1675
+ }
1676
+ if (stringGet_645(string_881, i_888) !== stringGet_645(substring_883, j_889)) {
1677
+ return_884 = -1;
1678
+ break fn_887;
1679
+ }
1680
+ t_885 = stringNext_746(string_881, i_888);
1681
+ i_888 = t_885;
1682
+ t_886 = stringNext_746(substring_883, j_889);
1683
+ j_889 = t_886;
1684
+ }
1685
+ return_884 = i_888;
1686
+ }
1687
+ return return_884;
1688
+ }
1689
+ /**
1690
+ * @param {string} sourceText_890
1691
+ * @param {globalThis.number} i_891
1692
+ * @param {JsonProducer} out_892
1693
+ * @returns {globalThis.number}
1694
+ */
1695
+ function parseJsonBoolean_649(sourceText_890, i_891, out_892) {
1696
+ let return_893;
1697
+ let t_894;
1698
+ fn_895: {
1699
+ let ch0_896;
1700
+ if (sourceText_890.length > i_891) {
1701
+ t_894 = stringGet_645(sourceText_890, i_891);
1702
+ ch0_896 = t_894;
1703
+ } else {
1704
+ ch0_896 = 0;
1705
+ }
1706
+ const end_897 = sourceText_890.length;
1707
+ let keyword_898;
1708
+ let n_899;
1709
+ if (ch0_896 === 102) {
1710
+ keyword_898 = "false";
1711
+ n_899 = 5;
1712
+ } else if (ch0_896 === 116) {
1713
+ keyword_898 = "true";
1714
+ n_899 = 4;
1715
+ } else {
1716
+ keyword_898 = null;
1717
+ n_899 = 0;
1718
+ }
1719
+ if (!(keyword_898 == null)) {
1720
+ const keyword_900 = keyword_898;
1721
+ if (stringHasAtLeast_817(sourceText_890, i_891, end_897, n_899)) {
1722
+ const after_901 = afterSubstring_880(sourceText_890, i_891, keyword_900);
1723
+ if (after_901 >= 0) {
1724
+ return_893 = requireStringIndex__852(after_901);
1725
+ out_892.booleanValue(n_899 === 4);
1726
+ break fn_895;
1727
+ }
1728
+ }
1729
+ }
1730
+ expectedTokenError_644(sourceText_890, i_891, out_892, "`false` or `true`");
1731
+ return_893 = -1;
1732
+ }
1733
+ return return_893;
1734
+ }
1735
+ /**
1736
+ * @param {string} sourceText_902
1737
+ * @param {globalThis.number} i_903
1738
+ * @param {JsonProducer} out_904
1739
+ * @returns {globalThis.number}
1740
+ */
1741
+ function parseJsonNull_650(sourceText_902, i_903, out_904) {
1742
+ let return_905;
1743
+ fn_906: {
1744
+ const after_907 = afterSubstring_880(sourceText_902, i_903, "null");
1745
+ if (after_907 >= 0) {
1746
+ return_905 = requireStringIndex__852(after_907);
1747
+ out_904.nullValue();
1748
+ break fn_906;
1749
+ }
1750
+ expectedTokenError_644(sourceText_902, i_903, out_904, "`null`");
1751
+ return_905 = -1;
1752
+ }
1753
+ return return_905;
1754
+ }
1755
+ /**
1756
+ * @param {string} sourceText_908
1757
+ * @param {globalThis.number} i_909
1758
+ * @param {JsonProducer} out_910
1759
+ * @returns {globalThis.number}
1760
+ */
1761
+ function parseJsonNumber_651(sourceText_908, i_909, out_910) {
1762
+ let return_911;
1763
+ let t_912;
1764
+ let t_913;
1765
+ let t_914;
1766
+ let t_915;
1767
+ let t_916;
1768
+ let t_917;
1769
+ let t_918;
1770
+ let t_919;
1771
+ let t_920;
1772
+ let t_921;
1773
+ let t_922;
1774
+ let t_923;
1775
+ let t_924;
1776
+ let t_925;
1777
+ let t_926;
1778
+ let t_927;
1779
+ let t_928;
1780
+ let t_929;
1781
+ let t_930;
1782
+ let t_931;
1783
+ let t_932;
1784
+ let t_933;
1785
+ let t_934;
1786
+ let t_935;
1787
+ let t_936;
1788
+ let t_937;
1789
+ let t_938;
1790
+ let t_939;
1791
+ let t_940;
1792
+ let t_941;
1793
+ let t_942;
1794
+ let t_943;
1795
+ let t_944;
1796
+ let t_945;
1797
+ let t_946;
1798
+ let t_947;
1799
+ let t_948;
1800
+ let t_949;
1801
+ fn_950: {
1802
+ try {
1803
+ let isNegative_951 = false;
1804
+ const startOfNumber_952 = i_909;
1805
+ if (sourceText_908.length > i_909) {
1806
+ t_912 = stringGet_645(sourceText_908, i_909);
1807
+ t_925 = t_912 === 45;
1808
+ } else {
1809
+ t_925 = false;
1810
+ }
1811
+ if (t_925) {
1812
+ isNegative_951 = true;
1813
+ t_913 = stringNext_746(sourceText_908, i_909);
1814
+ i_909 = t_913;
1815
+ }
1816
+ let digit0_953;
1817
+ if (sourceText_908.length > i_909) {
1818
+ t_914 = stringGet_645(sourceText_908, i_909);
1819
+ digit0_953 = t_914;
1820
+ } else {
1821
+ digit0_953 = -1;
1822
+ }
1823
+ if (digit0_953 < 48) {
1824
+ t_926 = true;
1825
+ } else {
1826
+ t_926 = 57 < digit0_953;
1827
+ }
1828
+ if (t_926) {
1829
+ let error_954;
1830
+ if (! isNegative_951) {
1831
+ t_927 = digit0_953 !== 46;
1832
+ } else {
1833
+ t_927 = false;
1834
+ }
1835
+ if (t_927) {
1836
+ error_954 = "JSON value";
1837
+ } else {
1838
+ error_954 = "digit";
1839
+ }
1840
+ expectedTokenError_644(sourceText_908, i_909, out_910, error_954);
1841
+ return_911 = -1;
1842
+ break fn_950;
1843
+ }
1844
+ t_915 = stringNext_746(sourceText_908, i_909);
1845
+ i_909 = t_915;
1846
+ let nDigits_955 = 1;
1847
+ try {
1848
+ t_928 = digit0_953 - 48;
1849
+ t_929 = t_928;
1850
+ } catch {
1851
+ t_916 = panic_586();
1852
+ t_929 = t_916;
1853
+ }
1854
+ let tentativeValue_956 = t_929;
1855
+ if (48 !== digit0_953) {
1856
+ while (true) {
1857
+ if (!(sourceText_908.length > i_909)) {
1858
+ break;
1859
+ }
1860
+ const possibleDigit_957 = stringGet_645(sourceText_908, i_909);
1861
+ if (48 <= possibleDigit_957) {
1862
+ t_930 = possibleDigit_957 <= 57;
1863
+ } else {
1864
+ t_930 = false;
1865
+ }
1866
+ if (t_930) {
1867
+ t_917 = stringNext_746(sourceText_908, i_909);
1868
+ i_909 = t_917;
1869
+ nDigits_955 = nDigits_955 + 1;
1870
+ t_932 = tentativeValue_956 * 10.0;
1871
+ t_931 = possibleDigit_957 - 48;
1872
+ tentativeValue_956 = t_932 + t_931;
1873
+ } else {
1874
+ break;
1875
+ }
1876
+ }
1877
+ }
1878
+ let nDigitsAfterPoint_958 = 0;
1879
+ if (sourceText_908.length > i_909) {
1880
+ t_918 = stringGet_645(sourceText_908, i_909);
1881
+ t_933 = 46 === t_918;
1882
+ } else {
1883
+ t_933 = false;
1884
+ }
1885
+ if (t_933) {
1886
+ t_919 = stringNext_746(sourceText_908, i_909);
1887
+ i_909 = t_919;
1888
+ const afterPoint_959 = i_909;
1889
+ while (true) {
1890
+ if (!(sourceText_908.length > i_909)) {
1891
+ break;
1892
+ }
1893
+ const possibleDigit_960 = stringGet_645(sourceText_908, i_909);
1894
+ if (48 <= possibleDigit_960) {
1895
+ t_934 = possibleDigit_960 <= 57;
1896
+ } else {
1897
+ t_934 = false;
1898
+ }
1899
+ if (t_934) {
1900
+ t_920 = stringNext_746(sourceText_908, i_909);
1901
+ i_909 = t_920;
1902
+ nDigits_955 = nDigits_955 + 1;
1903
+ nDigitsAfterPoint_958 = nDigitsAfterPoint_958 + 1;
1904
+ t_936 = tentativeValue_956 * 10.0;
1905
+ t_935 = possibleDigit_960 - 48;
1906
+ tentativeValue_956 = t_936 + t_935;
1907
+ } else {
1908
+ break;
1909
+ }
1910
+ }
1911
+ if (i_909 === afterPoint_959) {
1912
+ expectedTokenError_644(sourceText_908, i_909, out_910, "digit");
1913
+ return_911 = -1;
1914
+ break fn_950;
1915
+ }
1916
+ }
1917
+ let nExponentDigits_961 = 0;
1918
+ if (sourceText_908.length > i_909) {
1919
+ t_937 = stringGet_645(sourceText_908, i_909) | 32;
1920
+ t_938 = 101 === t_937;
1921
+ } else {
1922
+ t_938 = false;
1923
+ }
1924
+ if (t_938) {
1925
+ t_921 = stringNext_746(sourceText_908, i_909);
1926
+ i_909 = t_921;
1927
+ if (!(sourceText_908.length > i_909)) {
1928
+ expectedTokenError_644(sourceText_908, i_909, out_910, "sign or digit");
1929
+ return_911 = -1;
1930
+ break fn_950;
1931
+ }
1932
+ const afterE_962 = stringGet_645(sourceText_908, i_909);
1933
+ if (afterE_962 === 43) {
1934
+ t_939 = true;
1935
+ } else {
1936
+ t_939 = afterE_962 === 45;
1937
+ }
1938
+ if (t_939) {
1939
+ t_922 = stringNext_746(sourceText_908, i_909);
1940
+ i_909 = t_922;
1941
+ }
1942
+ while (true) {
1943
+ if (!(sourceText_908.length > i_909)) {
1944
+ break;
1945
+ }
1946
+ const possibleDigit_963 = stringGet_645(sourceText_908, i_909);
1947
+ if (48 <= possibleDigit_963) {
1948
+ t_940 = possibleDigit_963 <= 57;
1949
+ } else {
1950
+ t_940 = false;
1951
+ }
1952
+ if (t_940) {
1953
+ t_923 = stringNext_746(sourceText_908, i_909);
1954
+ i_909 = t_923;
1955
+ nExponentDigits_961 = nExponentDigits_961 + 1;
1956
+ } else {
1957
+ break;
1958
+ }
1959
+ }
1960
+ if (nExponentDigits_961 === 0) {
1961
+ expectedTokenError_644(sourceText_908, i_909, out_910, "exponent digit");
1962
+ return_911 = -1;
1963
+ break fn_950;
1964
+ }
1965
+ }
1966
+ const afterExponent_964 = i_909;
1967
+ if (nExponentDigits_961 === 0) {
1968
+ t_941 = nDigitsAfterPoint_958 === 0;
1969
+ } else {
1970
+ t_941 = false;
1971
+ }
1972
+ if (t_941) {
1973
+ let value_965;
1974
+ if (isNegative_951) {
1975
+ value_965 = - tentativeValue_956;
1976
+ } else {
1977
+ value_965 = tentativeValue_956;
1978
+ }
1979
+ if (nDigits_955 <= 10) {
1980
+ if (cmpFloat__966(-2.147483648E9, value_965) <= 0) {
1981
+ t_942 = cmpFloat__966(value_965, 2.147483647E9) <= 0;
1982
+ } else {
1983
+ t_942 = false;
1984
+ }
1985
+ t_943 = t_942;
1986
+ } else {
1987
+ t_943 = false;
1988
+ }
1989
+ if (t_943) {
1990
+ try {
1991
+ t_944 = float64ToInt_475(value_965);
1992
+ t_945 = t_944;
1993
+ } catch {
1994
+ t_924 = panic_586();
1995
+ t_945 = t_924;
1996
+ }
1997
+ out_910.intValue(t_945);
1998
+ return_911 = i_909;
1999
+ break fn_950;
2000
+ }
2001
+ }
2002
+ const numericTokenString_967 = sourceText_908.substring(startOfNumber_952, i_909);
2003
+ let doubleValue_968 = NaN;
2004
+ if (nExponentDigits_961 !== 0) {
2005
+ t_946 = true;
2006
+ } else {
2007
+ t_946 = nDigitsAfterPoint_958 !== 0;
2008
+ }
2009
+ if (t_946) {
2010
+ try {
2011
+ t_947 = stringToFloat64_488(numericTokenString_967);
2012
+ doubleValue_968 = t_947;
2013
+ } catch {
2014
+ }
2015
+ }
2016
+ if (cmpFloat__966(doubleValue_968, -Infinity) !== 0) {
2017
+ if (cmpFloat__966(doubleValue_968, Infinity) !== 0) {
2018
+ t_948 = cmpFloat__966(doubleValue_968, NaN) !== 0;
2019
+ } else {
2020
+ t_948 = false;
2021
+ }
2022
+ t_949 = t_948;
2023
+ } else {
2024
+ t_949 = false;
2025
+ }
2026
+ if (t_949) {
2027
+ out_910.float64Value(doubleValue_968);
2028
+ } else {
2029
+ out_910.numericTokenValue(numericTokenString_967);
2030
+ }
2031
+ return_911 = i_909;
2032
+ } catch {
2033
+ return_911 = panic_586();
2034
+ }
2035
+ }
2036
+ return return_911;
2037
+ }
2038
+ /**
2039
+ * @param {string} sourceText_969
2040
+ * @param {JsonProducer} out_970
2041
+ */
2042
+ export function parseJsonToProducer(sourceText_969, out_970) {
2043
+ let t_971;
2044
+ let t_972;
2045
+ let t_973;
2046
+ let t_974;
2047
+ let t_975;
2048
+ let t_976;
2049
+ let i_977 = 0;
2050
+ const afterValue_978 = parseJsonValue_634(sourceText_969, i_977, out_970);
2051
+ if (afterValue_978 >= 0) {
2052
+ t_976 = requireStringIndex__852(afterValue_978);
2053
+ t_971 = skipJsonSpaces_643(sourceText_969, t_976);
2054
+ i_977 = t_971;
2055
+ if (sourceText_969.length > i_977) {
2056
+ t_972 = out_970.parseErrorReceiver;
2057
+ t_975 = !(t_972 == null);
2058
+ } else {
2059
+ t_975 = false;
2060
+ }
2061
+ if (t_975) {
2062
+ t_973 = sourceText_969.length;
2063
+ t_974 = sourceText_969.substring(i_977, t_973);
2064
+ storeJsonError_747(out_970, "Extraneous JSON `" + t_974 + "`");
2065
+ }
2066
+ }
2067
+ return;
2068
+ };
2069
+ /**
2070
+ * @param {string} sourceText_979
2071
+ * @returns {JsonSyntaxTree}
2072
+ */
2073
+ export function parseJson(sourceText_979) {
2074
+ const p_980 = new JsonSyntaxTreeProducer();
2075
+ parseJsonToProducer(sourceText_979, p_980);
2076
+ return p_980.toJsonSyntaxTree();
2077
+ };
2078
+ /** @returns {JsonAdapter<boolean>} */
2079
+ export function booleanJsonAdapter() {
2080
+ return new BooleanJsonAdapter_659();
2081
+ };
2082
+ /** @returns {JsonAdapter<number>} */
2083
+ export function float64JsonAdapter() {
2084
+ return new Float64JsonAdapter_667();
2085
+ };
2086
+ /** @returns {JsonAdapter<number>} */
2087
+ export function intJsonAdapter() {
2088
+ return new IntJsonAdapter_675();
2089
+ };
2090
+ /** @returns {JsonAdapter<string>} */
2091
+ export function stringJsonAdapter() {
2092
+ return new StringJsonAdapter_683();
2093
+ };
2094
+ /**
2095
+ * @template {unknown} T_982
2096
+ * @param {JsonAdapter<T_982>} adapterForT_981
2097
+ * @returns {JsonAdapter<Array<T_982>>}
2098
+ */
2099
+ export function listJsonAdapter(adapterForT_981) {
2100
+ return new ListJsonAdapter_691(adapterForT_981);
2101
+ };