@temperlang/std 0.0.3

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/regex.js ADDED
@@ -0,0 +1,1205 @@
1
+ import {
2
+ InterfaceType as InterfaceType_51, listify as listify_52, compiledRegexCompileFormatted as compiledRegexCompileFormatted_53, compiledRegexCompiledFoundIn as compiledRegexCompiledFoundIn_54, compiledRegexCompiledFind as compiledRegexCompiledFind_55, listJoin as listJoin_56, genericEq as genericEq_57, listBuilderAdd as listBuilderAdd_58, regexFormatterPushCodeTo as regexFormatterPushCodeTo_59, regexFormatterAdjustCodeSet as regexFormatterAdjustCodeSet_60, genericLt as genericLt_61, listGet as listGet_62, genericNe as genericNe_63, genericGt as genericGt_64, strCat as strCat_10, stringCodePoints as stringCodePoints_8, intToString as intToString_9, requireInstanceOf as requireInstanceOf__254, noResultException as noResultException__256, requireIsSafeInteger as requireIsSafeInteger__352
3
+ } from "@temperlang/core";
4
+ export function Regex(x_65) {
5
+ return x_65 instanceof Regex_66;
6
+ };
7
+ export function CodePart(x_67) {
8
+ return x_67 instanceof CodePart_68;
9
+ };
10
+ export function Special(x_69) {
11
+ return x_69 instanceof Special_70;
12
+ };
13
+ export function SpecialSet(x_71) {
14
+ return x_71 instanceof SpecialSet_72;
15
+ };
16
+ function methodCompiled73() {
17
+ let return_74;
18
+ let t_75 = CompiledRegex(this);
19
+ return_74 = t_75;
20
+ return return_74;
21
+ }
22
+ function methodFoundIn76(text_77) {
23
+ let return_78;
24
+ let t_79 = this.compiled();
25
+ let t_80 = t_79.foundIn(text_77);
26
+ return_78 = t_80;
27
+ return return_78;
28
+ }
29
+ function methodFind81(text_82) {
30
+ let return_83;
31
+ let t_84;
32
+ let t_85 = this.compiled();
33
+ {
34
+ t_84 = t_85.find(text_82);
35
+ return_83 = t_84;
36
+ }
37
+ return return_83;
38
+ }
39
+ const Regex_66 = new InterfaceType_51("Regex", [["m", "compiled", methodCompiled73], ["m", "foundIn", methodFoundIn76], ["m", "find", methodFind81]], [], 1);
40
+ export function Capture(...args_86) {
41
+ return new Capture_87(...args_86);
42
+ };
43
+ class Capture_87 {
44
+ #name_88;
45
+ #item_89;
46
+ constructor(name_90, item_91) {
47
+ let return_92;
48
+ return_92 = void 0;
49
+ this.#name_88 = name_90;
50
+ this.#item_89 = item_91;
51
+ return;
52
+ }
53
+ get name() {
54
+ let return_94;
55
+ return_94 = this.#name_88;
56
+ return return_94;
57
+ }
58
+ get item() {
59
+ let return_96;
60
+ return_96 = this.#item_89;
61
+ return return_96;
62
+ }
63
+ }
64
+ Regex_66.implementedBy(Capture_87);
65
+ const CodePart_68 = new InterfaceType_51("CodePart", [], [Regex_66], 2);
66
+ export function CodePoints(...args_97) {
67
+ return new CodePoints_98(...args_97);
68
+ };
69
+ class CodePoints_98 {
70
+ #value_99;
71
+ constructor(value_100) {
72
+ let return_101;
73
+ return_101 = void 0;
74
+ this.#value_99 = value_100;
75
+ return;
76
+ }
77
+ get value() {
78
+ let return_103;
79
+ return_103 = this.#value_99;
80
+ return return_103;
81
+ }
82
+ }
83
+ CodePart_68.implementedBy(CodePoints_98);
84
+ const Special_70 = new InterfaceType_51("Special", [], [Regex_66], 2);
85
+ const SpecialSet_72 = new InterfaceType_51("SpecialSet", [], [CodePart_68, Special_70], 3);
86
+ export function CodeRange(...args_104) {
87
+ return new CodeRange_105(...args_104);
88
+ };
89
+ class CodeRange_105 {
90
+ #min_106;
91
+ #max_107;
92
+ constructor(min_108, max_109) {
93
+ let return_110;
94
+ return_110 = void 0;
95
+ this.#min_106 = min_108;
96
+ this.#max_107 = max_109;
97
+ return;
98
+ }
99
+ get min() {
100
+ let return_112;
101
+ return_112 = this.#min_106;
102
+ return return_112;
103
+ }
104
+ get max() {
105
+ let return_114;
106
+ return_114 = this.#max_107;
107
+ return return_114;
108
+ }
109
+ }
110
+ CodePart_68.implementedBy(CodeRange_105);
111
+ export function CodeSet(...args_115) {
112
+ return new CodeSet_116(...args_115);
113
+ };
114
+ class CodeSet_116 {
115
+ #items_117;
116
+ #negated_118;
117
+ constructor(items_119, negated_120) {
118
+ let return_121;
119
+ return_121 = void 0;
120
+ if (!(negated_120 !== void 0)) {
121
+ negated_120 = false;
122
+ }
123
+ this.#items_117 = items_119;
124
+ this.#negated_118 = negated_120;
125
+ return;
126
+ }
127
+ get items() {
128
+ let return_123;
129
+ return_123 = this.#items_117;
130
+ return return_123;
131
+ }
132
+ get negated() {
133
+ let return_125;
134
+ return_125 = this.#negated_118;
135
+ return return_125;
136
+ }
137
+ }
138
+ Regex_66.implementedBy(CodeSet_116);
139
+ export function Or(...args_126) {
140
+ return new Or_127(...args_126);
141
+ };
142
+ class Or_127 {
143
+ #items_128;
144
+ constructor(items_129) {
145
+ let return_130;
146
+ return_130 = void 0;
147
+ this.#items_128 = items_129;
148
+ return;
149
+ }
150
+ get items() {
151
+ let return_132;
152
+ return_132 = this.#items_128;
153
+ return return_132;
154
+ }
155
+ }
156
+ Regex_66.implementedBy(Or_127);
157
+ export function Repeat(...args_133) {
158
+ return new Repeat_134(...args_133);
159
+ };
160
+ class Repeat_134 {
161
+ #item_135;
162
+ #min_136;
163
+ #max_137;
164
+ #reluctant_138;
165
+ constructor(item_139, min_140, max_141, reluctant_142) {
166
+ let return_143;
167
+ return_143 = void 0;
168
+ if (!(reluctant_142 !== void 0)) {
169
+ reluctant_142 = false;
170
+ }
171
+ this.#item_135 = item_139;
172
+ this.#min_136 = min_140;
173
+ this.#max_137 = max_141;
174
+ this.#reluctant_138 = reluctant_142;
175
+ return;
176
+ }
177
+ get item() {
178
+ let return_145;
179
+ return_145 = this.#item_135;
180
+ return return_145;
181
+ }
182
+ get min() {
183
+ let return_147;
184
+ return_147 = this.#min_136;
185
+ return return_147;
186
+ }
187
+ get max() {
188
+ let return_149;
189
+ return_149 = this.#max_137;
190
+ return return_149;
191
+ }
192
+ get reluctant() {
193
+ let return_151;
194
+ return_151 = this.#reluctant_138;
195
+ return return_151;
196
+ }
197
+ }
198
+ Regex_66.implementedBy(Repeat_134);
199
+ export function Sequence(...args_152) {
200
+ return new Sequence_153(...args_152);
201
+ };
202
+ class Sequence_153 {
203
+ #items_154;
204
+ constructor(items_155) {
205
+ let return_156;
206
+ return_156 = void 0;
207
+ this.#items_154 = items_155;
208
+ return;
209
+ }
210
+ get items() {
211
+ let return_158;
212
+ return_158 = this.#items_154;
213
+ return return_158;
214
+ }
215
+ }
216
+ Regex_66.implementedBy(Sequence_153);
217
+ export function Match(...args_159) {
218
+ return new Match_160(...args_159);
219
+ };
220
+ class Match_160 {
221
+ #groups_161;
222
+ constructor(groups_162) {
223
+ let return_163;
224
+ return_163 = void 0;
225
+ this.#groups_161 = groups_162;
226
+ return;
227
+ }
228
+ get groups() {
229
+ let return_165;
230
+ return_165 = this.#groups_161;
231
+ return return_165;
232
+ }
233
+ }
234
+ export function Group(...args_166) {
235
+ return new Group_167(...args_166);
236
+ };
237
+ class Group_167 {
238
+ #name_168;
239
+ #value_169;
240
+ #codePointsBegin_170;
241
+ constructor(name_171, value_172, codePointsBegin_173) {
242
+ let return_174;
243
+ return_174 = void 0;
244
+ this.#name_168 = name_171;
245
+ this.#value_169 = value_172;
246
+ this.#codePointsBegin_170 = codePointsBegin_173;
247
+ return;
248
+ }
249
+ get name() {
250
+ let return_176;
251
+ return_176 = this.#name_168;
252
+ return return_176;
253
+ }
254
+ get value() {
255
+ let return_178;
256
+ return_178 = this.#value_169;
257
+ return return_178;
258
+ }
259
+ get codePointsBegin() {
260
+ let return_180;
261
+ return_180 = this.#codePointsBegin_170;
262
+ return return_180;
263
+ }
264
+ }
265
+ function RegexRefs_181(...args_182) {
266
+ return new RegexRefs_183(...args_182);
267
+ }
268
+ class RegexRefs_183 {
269
+ #codePoints_184;
270
+ #match_185;
271
+ #orObject_186;
272
+ constructor(codePoints_187, match_188, orObject_189) {
273
+ let return_190;
274
+ let t_191;
275
+ let t_192;
276
+ let t_193;
277
+ let t_194;
278
+ return_190 = void 0;
279
+ if (!(codePoints_187 !== void 0)) {
280
+ t_191 = CodePoints("");
281
+ codePoints_187 = t_191;
282
+ }
283
+ if (!(match_188 !== void 0)) {
284
+ t_192 = Group("", "", 0);
285
+ t_193 = Match(listify_52(t_192));
286
+ match_188 = t_193;
287
+ }
288
+ if (!(orObject_189 !== void 0)) {
289
+ t_194 = Or(listify_52());
290
+ orObject_189 = t_194;
291
+ }
292
+ this.#codePoints_184 = codePoints_187;
293
+ this.#match_185 = match_188;
294
+ this.#orObject_186 = orObject_189;
295
+ return;
296
+ }
297
+ get codePoints() {
298
+ let return_196;
299
+ return_196 = this.#codePoints_184;
300
+ return return_196;
301
+ }
302
+ get match() {
303
+ let return_198;
304
+ return_198 = this.#match_185;
305
+ return return_198;
306
+ }
307
+ get orObject() {
308
+ let return_200;
309
+ return_200 = this.#orObject_186;
310
+ return return_200;
311
+ }
312
+ }
313
+ export function CompiledRegex(...args_201) {
314
+ return new CompiledRegex_202(...args_201);
315
+ };
316
+ class CompiledRegex_202 {
317
+ #data_203;
318
+ constructor(data_204) {
319
+ let return_205;
320
+ return_205 = void 0;
321
+ this.#data_203 = data_204;
322
+ let t_206 = this.format();
323
+ let t_207 = compiledRegexCompileFormatted_53(this, t_206);
324
+ this.#compiled_208 = t_207;
325
+ return;
326
+ }
327
+ foundIn(text_210) {
328
+ let return_211;
329
+ let t_212 = compiledRegexCompiledFoundIn_54(this, this.#compiled_208, text_210);
330
+ return_211 = t_212;
331
+ return return_211;
332
+ }
333
+ find(text_214) {
334
+ let return_215;
335
+ let t_216;
336
+ {
337
+ t_216 = compiledRegexCompiledFind_55(this, this.#compiled_208, text_214, regexRefs_217);
338
+ return_215 = t_216;
339
+ }
340
+ return return_215;
341
+ }
342
+ #compiled_208;
343
+ format() {
344
+ let return_219;
345
+ let t_220 = RegexFormatter_221();
346
+ let t_222 = t_220.format(this.#data_203);
347
+ return_219 = t_222;
348
+ return return_219;
349
+ }
350
+ get data() {
351
+ let return_224;
352
+ return_224 = this.#data_203;
353
+ return return_224;
354
+ }
355
+ }
356
+ function RegexFormatter_221(...args_225) {
357
+ return new RegexFormatter_226(...args_225);
358
+ }
359
+ class RegexFormatter_226 {
360
+ #out_227;
361
+ format(regex_229) {
362
+ let return_230;
363
+ this.pushRegex(regex_229);
364
+ let t_231 = this.#out_227;
365
+ function fn_232(x_233) {
366
+ let return_234;
367
+ return_234 = x_233;
368
+ return return_234;
369
+ }
370
+ let t_235 = fn_232;
371
+ let t_236 = listJoin_56(t_231, "", t_235);
372
+ return_230 = t_236;
373
+ return return_230;
374
+ }
375
+ pushRegex(regex_238) {
376
+ let return_239;
377
+ return_239 = void 0;
378
+ let t_240;
379
+ let t_241;
380
+ let t_242;
381
+ let t_243;
382
+ let t_244;
383
+ let t_245;
384
+ let t_246;
385
+ let t_247;
386
+ let t_248;
387
+ let t_249;
388
+ let t_250;
389
+ let t_251;
390
+ let t_252;
391
+ let t_253;
392
+ try {
393
+ requireInstanceOf__254(regex_238, Capture_87);
394
+ t_240 = true;
395
+ } catch {
396
+ t_240 = false;
397
+ }
398
+ s_255: {
399
+ if (t_240) {
400
+ try {
401
+ t_241 = requireInstanceOf__254(regex_238, Capture_87);
402
+ } catch {
403
+ break s_255;
404
+ }
405
+ this.pushCapture(t_241);
406
+ } else {
407
+ try {
408
+ requireInstanceOf__254(regex_238, CodePoints_98);
409
+ t_242 = true;
410
+ } catch {
411
+ t_242 = false;
412
+ }
413
+ if (t_242) {
414
+ try {
415
+ t_243 = requireInstanceOf__254(regex_238, CodePoints_98);
416
+ } catch {
417
+ break s_255;
418
+ }
419
+ this.pushCodePoints(t_243, false);
420
+ } else {
421
+ try {
422
+ requireInstanceOf__254(regex_238, CodeRange_105);
423
+ t_244 = true;
424
+ } catch {
425
+ t_244 = false;
426
+ }
427
+ if (t_244) {
428
+ try {
429
+ t_245 = requireInstanceOf__254(regex_238, CodeRange_105);
430
+ } catch {
431
+ break s_255;
432
+ }
433
+ this.pushCodeRange(t_245);
434
+ } else {
435
+ try {
436
+ requireInstanceOf__254(regex_238, CodeSet_116);
437
+ t_246 = true;
438
+ } catch {
439
+ t_246 = false;
440
+ }
441
+ if (t_246) {
442
+ try {
443
+ t_247 = requireInstanceOf__254(regex_238, CodeSet_116);
444
+ } catch {
445
+ break s_255;
446
+ }
447
+ this.pushCodeSet(t_247);
448
+ } else {
449
+ try {
450
+ requireInstanceOf__254(regex_238, Or_127);
451
+ t_248 = true;
452
+ } catch {
453
+ t_248 = false;
454
+ }
455
+ if (t_248) {
456
+ try {
457
+ t_249 = requireInstanceOf__254(regex_238, Or_127);
458
+ } catch {
459
+ break s_255;
460
+ }
461
+ this.pushOr(t_249);
462
+ } else {
463
+ try {
464
+ requireInstanceOf__254(regex_238, Repeat_134);
465
+ t_250 = true;
466
+ } catch {
467
+ t_250 = false;
468
+ }
469
+ if (t_250) {
470
+ try {
471
+ t_251 = requireInstanceOf__254(regex_238, Repeat_134);
472
+ } catch {
473
+ break s_255;
474
+ }
475
+ this.pushRepeat(t_251);
476
+ } else {
477
+ try {
478
+ requireInstanceOf__254(regex_238, Sequence_153);
479
+ t_252 = true;
480
+ } catch {
481
+ t_252 = false;
482
+ }
483
+ if (t_252) {
484
+ try {
485
+ t_253 = requireInstanceOf__254(regex_238, Sequence_153);
486
+ } catch {
487
+ break s_255;
488
+ }
489
+ this.pushSequence(t_253);
490
+ } else if (genericEq_57(regex_238, Begin)) {
491
+ try {
492
+ listBuilderAdd_58(this.#out_227, "^");
493
+ } catch {
494
+ break s_255;
495
+ }
496
+ } else if (genericEq_57(regex_238, Dot)) {
497
+ try {
498
+ listBuilderAdd_58(this.#out_227, ".");
499
+ } catch {
500
+ break s_255;
501
+ }
502
+ } else if (genericEq_57(regex_238, End)) {
503
+ try {
504
+ listBuilderAdd_58(this.#out_227, "\u0024");
505
+ } catch {
506
+ break s_255;
507
+ }
508
+ } else if (genericEq_57(regex_238, WordBoundary)) {
509
+ try {
510
+ listBuilderAdd_58(this.#out_227, "\\b");
511
+ } catch {
512
+ break s_255;
513
+ }
514
+ } else if (genericEq_57(regex_238, Digit)) {
515
+ try {
516
+ listBuilderAdd_58(this.#out_227, "\\d");
517
+ } catch {
518
+ break s_255;
519
+ }
520
+ } else if (genericEq_57(regex_238, Space)) {
521
+ try {
522
+ listBuilderAdd_58(this.#out_227, "\\s");
523
+ } catch {
524
+ break s_255;
525
+ }
526
+ } else if (genericEq_57(regex_238, Word)) {
527
+ try {
528
+ listBuilderAdd_58(this.#out_227, "\\w");
529
+ } catch {
530
+ break s_255;
531
+ }
532
+ }
533
+ }
534
+ }
535
+ }
536
+ }
537
+ }
538
+ }
539
+ return return_239;
540
+ }
541
+ throw noResultException__256;
542
+ }
543
+ pushCapture(capture_258) {
544
+ let return_259;
545
+ let t_260;
546
+ let t_261;
547
+ return_259 = void 0;
548
+ let t_262;
549
+ {
550
+ listBuilderAdd_58(this.#out_227, "(");
551
+ t_262 = this.#out_227;
552
+ t_260 = capture_258.name;
553
+ this.pushCaptureName(t_262, t_260);
554
+ t_261 = capture_258.item;
555
+ this.pushRegex(t_261);
556
+ listBuilderAdd_58(this.#out_227, ")");
557
+ }
558
+ return return_259;
559
+ }
560
+ pushCaptureName(out_264, name_265) {
561
+ let return_266;
562
+ return_266 = void 0;
563
+ listBuilderAdd_58(out_264, strCat_10("?\u003c", name_265, "\u003e"));
564
+ return return_266;
565
+ }
566
+ pushCode(code_268, insideCodeSet_269) {
567
+ let return_270;
568
+ return_270 = void 0;
569
+ regexFormatterPushCodeTo_59(this, this.#out_227, code_268, insideCodeSet_269);
570
+ return return_270;
571
+ }
572
+ pushCodePoints(codePoints_272, insideCodeSet_273) {
573
+ let return_274;
574
+ let t_275;
575
+ let t_276;
576
+ let t_277;
577
+ let t_278;
578
+ return_274 = void 0;
579
+ let t_279 = codePoints_272.value;
580
+ let t_280 = stringCodePoints_8(t_279);
581
+ let slice_281 = t_280;
582
+ while (true) {
583
+ t_275 = slice_281.isEmpty;
584
+ t_278 = ! t_275;
585
+ if (t_278) {
586
+ t_276 = slice_281.read();
587
+ this.pushCode(t_276, insideCodeSet_273);
588
+ t_277 = slice_281.advance(1);
589
+ slice_281 = t_277;
590
+ } else {
591
+ break;
592
+ }
593
+ }
594
+ return return_274;
595
+ }
596
+ pushCodeRange(codeRange_283) {
597
+ let return_284;
598
+ return_284 = void 0;
599
+ {
600
+ listBuilderAdd_58(this.#out_227, "[");
601
+ this.pushCodeRangeUnwrapped(codeRange_283);
602
+ listBuilderAdd_58(this.#out_227, "]");
603
+ }
604
+ return return_284;
605
+ }
606
+ pushCodeRangeUnwrapped(codeRange_286) {
607
+ let return_287;
608
+ let t_288;
609
+ return_287 = void 0;
610
+ let t_289 = codeRange_286.min;
611
+ this.pushCode(t_289, true);
612
+ {
613
+ listBuilderAdd_58(this.#out_227, "-");
614
+ t_288 = codeRange_286.max;
615
+ this.pushCode(t_288, true);
616
+ }
617
+ return return_287;
618
+ }
619
+ pushCodeSet(codeSet_291) {
620
+ let return_292;
621
+ let t_293;
622
+ let t_294;
623
+ let t_295;
624
+ let t_296;
625
+ return_292 = void 0;
626
+ let t_297;
627
+ let t_298;
628
+ let t_299;
629
+ let t_300;
630
+ let t_301;
631
+ let t_302 = regexFormatterAdjustCodeSet_60(this, codeSet_291, regexRefs_217);
632
+ const adjusted_303 = t_302;
633
+ try {
634
+ requireInstanceOf__254(adjusted_303, CodeSet_116);
635
+ t_297 = true;
636
+ } catch {
637
+ t_297 = false;
638
+ }
639
+ s_304: {
640
+ if (t_297) {
641
+ s_305: {
642
+ try {
643
+ t_298 = requireInstanceOf__254(adjusted_303, CodeSet_116);
644
+ listBuilderAdd_58(this.#out_227, "[");
645
+ } catch {
646
+ break s_305;
647
+ }
648
+ t_296 = t_298.negated;
649
+ if (t_296) {
650
+ try {
651
+ listBuilderAdd_58(this.#out_227, "^");
652
+ } catch {
653
+ break s_305;
654
+ }
655
+ }
656
+ let i_306 = 0;
657
+ while (true) {
658
+ t_293 = t_298.items;
659
+ t_295 = t_293.length;
660
+ try {
661
+ t_299 = genericLt_61(i_306, t_295);
662
+ } catch {
663
+ break;
664
+ }
665
+ if (t_299) {
666
+ t_294 = t_298.items;
667
+ try {
668
+ t_301 = listGet_62(t_294, i_306);
669
+ } catch {
670
+ break;
671
+ }
672
+ this.pushCodeSetItem(t_301);
673
+ t_300 = i_306 + 1;
674
+ i_306 = t_300;
675
+ } else {
676
+ try {
677
+ listBuilderAdd_58(this.#out_227, "]");
678
+ } catch {
679
+ break s_305;
680
+ }
681
+ break s_304;
682
+ }
683
+ }
684
+ }
685
+ throw noResultException__256;
686
+ }
687
+ this.pushRegex(adjusted_303);
688
+ }
689
+ return return_292;
690
+ }
691
+ pushCodeSetItem(codePart_308) {
692
+ let return_309;
693
+ return_309 = void 0;
694
+ let t_310;
695
+ let t_311;
696
+ let t_312;
697
+ let t_313;
698
+ let t_314;
699
+ let t_315;
700
+ try {
701
+ requireInstanceOf__254(codePart_308, CodePoints_98);
702
+ t_310 = true;
703
+ } catch {
704
+ t_310 = false;
705
+ }
706
+ s_316: {
707
+ if (t_310) {
708
+ try {
709
+ t_311 = requireInstanceOf__254(codePart_308, CodePoints_98);
710
+ } catch {
711
+ break s_316;
712
+ }
713
+ this.pushCodePoints(t_311, true);
714
+ } else {
715
+ try {
716
+ requireInstanceOf__254(codePart_308, CodeRange_105);
717
+ t_312 = true;
718
+ } catch {
719
+ t_312 = false;
720
+ }
721
+ if (t_312) {
722
+ try {
723
+ t_313 = requireInstanceOf__254(codePart_308, CodeRange_105);
724
+ } catch {
725
+ break s_316;
726
+ }
727
+ this.pushCodeRangeUnwrapped(t_313);
728
+ } else {
729
+ try {
730
+ requireInstanceOf__254(codePart_308, SpecialSet_72);
731
+ t_314 = true;
732
+ } catch {
733
+ t_314 = false;
734
+ }
735
+ if (t_314) {
736
+ try {
737
+ t_315 = requireInstanceOf__254(codePart_308, SpecialSet_72);
738
+ } catch {
739
+ break s_316;
740
+ }
741
+ this.pushRegex(t_315);
742
+ }
743
+ }
744
+ }
745
+ return return_309;
746
+ }
747
+ throw noResultException__256;
748
+ }
749
+ pushOr(or_318) {
750
+ let return_319;
751
+ let t_320;
752
+ let t_321;
753
+ let t_322;
754
+ let t_323;
755
+ return_319 = void 0;
756
+ let t_324;
757
+ let t_325;
758
+ let t_326;
759
+ let t_327;
760
+ let t_328 = or_318.items;
761
+ let t_329 = ! t_328.length;
762
+ let t_330 = ! t_329;
763
+ s_331: if (t_330) {
764
+ s_332: {
765
+ try {
766
+ listBuilderAdd_58(this.#out_227, "(?:");
767
+ t_323 = or_318.items;
768
+ t_324 = listGet_62(t_323, 0);
769
+ } catch {
770
+ break s_332;
771
+ }
772
+ this.pushRegex(t_324);
773
+ let i_333 = 1;
774
+ while (true) {
775
+ t_320 = or_318.items;
776
+ t_322 = t_320.length;
777
+ try {
778
+ t_325 = genericLt_61(i_333, t_322);
779
+ } catch {
780
+ break;
781
+ }
782
+ if (t_325) {
783
+ try {
784
+ listBuilderAdd_58(this.#out_227, "|");
785
+ t_321 = or_318.items;
786
+ t_327 = listGet_62(t_321, i_333);
787
+ } catch {
788
+ break;
789
+ }
790
+ this.pushRegex(t_327);
791
+ t_326 = i_333 + 1;
792
+ i_333 = t_326;
793
+ } else {
794
+ try {
795
+ listBuilderAdd_58(this.#out_227, ")");
796
+ } catch {
797
+ break s_332;
798
+ }
799
+ break s_331;
800
+ }
801
+ }
802
+ }
803
+ throw noResultException__256;
804
+ }
805
+ return return_319;
806
+ }
807
+ pushRepeat(repeat_335) {
808
+ let return_336;
809
+ let t_337;
810
+ let t_338;
811
+ let t_339;
812
+ let t_340;
813
+ let t_341;
814
+ return_336 = void 0;
815
+ let t_342;
816
+ let t_343;
817
+ let t_344;
818
+ let t_345;
819
+ let t_346;
820
+ let t_347;
821
+ let t_348;
822
+ s_349: {
823
+ let min_350;
824
+ try {
825
+ listBuilderAdd_58(this.#out_227, "(?:");
826
+ t_337 = repeat_335.item;
827
+ this.pushRegex(t_337);
828
+ listBuilderAdd_58(this.#out_227, ")");
829
+ t_338 = repeat_335.min;
830
+ min_350 = t_338;
831
+ t_342 = repeat_335.max;
832
+ } catch {
833
+ break s_349;
834
+ }
835
+ const max_351 = t_342;
836
+ if (genericEq_57(min_350, 0)) {
837
+ t_343 = genericEq_57(max_351, 1);
838
+ } else {
839
+ t_343 = false;
840
+ }
841
+ if (t_343) {
842
+ try {
843
+ listBuilderAdd_58(this.#out_227, "?");
844
+ } catch {
845
+ break s_349;
846
+ }
847
+ } else {
848
+ if (genericEq_57(min_350, 0)) {
849
+ t_344 = genericEq_57(max_351, null);
850
+ } else {
851
+ t_344 = false;
852
+ }
853
+ if (t_344) {
854
+ try {
855
+ listBuilderAdd_58(this.#out_227, "*");
856
+ } catch {
857
+ break s_349;
858
+ }
859
+ } else {
860
+ if (genericEq_57(min_350, 1)) {
861
+ t_345 = genericEq_57(max_351, null);
862
+ } else {
863
+ t_345 = false;
864
+ }
865
+ if (t_345) {
866
+ try {
867
+ listBuilderAdd_58(this.#out_227, "+");
868
+ } catch {
869
+ break s_349;
870
+ }
871
+ } else {
872
+ t_346 = this.#out_227;
873
+ t_339 = intToString_9(min_350);
874
+ try {
875
+ listBuilderAdd_58(t_346, strCat_10("{", t_339));
876
+ } catch {
877
+ break s_349;
878
+ }
879
+ if (genericNe_63(min_350, max_351)) {
880
+ try {
881
+ listBuilderAdd_58(this.#out_227, ",");
882
+ } catch {
883
+ break s_349;
884
+ }
885
+ if (genericNe_63(max_351, null)) {
886
+ t_348 = this.#out_227;
887
+ try {
888
+ t_347 = requireIsSafeInteger__352(max_351);
889
+ t_340 = intToString_9(t_347);
890
+ listBuilderAdd_58(t_348, t_340);
891
+ } catch {
892
+ break s_349;
893
+ }
894
+ }
895
+ }
896
+ try {
897
+ listBuilderAdd_58(this.#out_227, "}");
898
+ } catch {
899
+ break s_349;
900
+ }
901
+ }
902
+ }
903
+ }
904
+ t_341 = repeat_335.reluctant;
905
+ if (t_341) {
906
+ try {
907
+ listBuilderAdd_58(this.#out_227, "?");
908
+ } catch {
909
+ break s_349;
910
+ }
911
+ }
912
+ return return_336;
913
+ }
914
+ throw noResultException__256;
915
+ }
916
+ pushSequence(sequence_354) {
917
+ let return_355;
918
+ let t_356;
919
+ let t_357;
920
+ let t_358;
921
+ return_355 = void 0;
922
+ let t_359;
923
+ let t_360;
924
+ let t_361;
925
+ let i_362 = 0;
926
+ s_363: {
927
+ while (true) {
928
+ t_356 = sequence_354.items;
929
+ t_358 = t_356.length;
930
+ try {
931
+ t_359 = genericLt_61(i_362, t_358);
932
+ } catch {
933
+ break;
934
+ }
935
+ if (t_359) {
936
+ t_357 = sequence_354.items;
937
+ try {
938
+ t_361 = listGet_62(t_357, i_362);
939
+ } catch {
940
+ break;
941
+ }
942
+ this.pushRegex(t_361);
943
+ t_360 = i_362 + 1;
944
+ i_362 = t_360;
945
+ } else {
946
+ break s_363;
947
+ }
948
+ }
949
+ throw noResultException__256;
950
+ }
951
+ return return_355;
952
+ }
953
+ maxCode(codePart_365) {
954
+ let return_366;
955
+ let t_367;
956
+ let t_368;
957
+ let t_369;
958
+ let t_370;
959
+ let t_371;
960
+ let t_372;
961
+ let t_373;
962
+ let t_374;
963
+ let t_375;
964
+ let t_376;
965
+ let t_377;
966
+ let t_378;
967
+ let t_379;
968
+ let t_380;
969
+ let t_381;
970
+ let t_382;
971
+ let t_383;
972
+ let t_384;
973
+ let t_385;
974
+ let t_386;
975
+ let t_387;
976
+ let t_388;
977
+ try {
978
+ requireInstanceOf__254(codePart_365, CodePoints_98);
979
+ t_381 = true;
980
+ } catch {
981
+ t_381 = false;
982
+ }
983
+ s_389: {
984
+ if (t_381) {
985
+ try {
986
+ t_382 = requireInstanceOf__254(codePart_365, CodePoints_98);
987
+ } catch {
988
+ break s_389;
989
+ }
990
+ t_370 = t_382.value;
991
+ const value_390 = t_370;
992
+ t_371 = ! value_390;
993
+ if (t_371) {
994
+ t_385 = null;
995
+ } else {
996
+ let max_391 = 0;
997
+ t_372 = stringCodePoints_8(value_390);
998
+ let slice_392 = t_372;
999
+ while (true) {
1000
+ t_373 = slice_392.isEmpty;
1001
+ t_376 = ! t_373;
1002
+ if (t_376) {
1003
+ t_374 = slice_392.read();
1004
+ const next_393 = t_374;
1005
+ try {
1006
+ t_383 = genericGt_64(next_393, max_391);
1007
+ } catch {
1008
+ break s_389;
1009
+ }
1010
+ if (t_383) {
1011
+ max_391 = next_393;
1012
+ }
1013
+ t_375 = slice_392.advance(1);
1014
+ slice_392 = t_375;
1015
+ } else {
1016
+ break;
1017
+ }
1018
+ }
1019
+ t_384 = max_391;
1020
+ t_385 = t_384;
1021
+ }
1022
+ t_388 = t_385;
1023
+ } else {
1024
+ try {
1025
+ requireInstanceOf__254(codePart_365, CodeRange_105);
1026
+ t_386 = true;
1027
+ } catch {
1028
+ t_386 = false;
1029
+ }
1030
+ if (t_386) {
1031
+ try {
1032
+ t_387 = requireInstanceOf__254(codePart_365, CodeRange_105);
1033
+ } catch {
1034
+ break s_389;
1035
+ }
1036
+ t_377 = t_387.max;
1037
+ t_388 = t_377;
1038
+ } else if (genericEq_57(codePart_365, Digit)) {
1039
+ t_367 = stringCodePoints_8("9");
1040
+ t_378 = t_367.read();
1041
+ t_388 = t_378;
1042
+ } else if (genericEq_57(codePart_365, Space)) {
1043
+ t_368 = stringCodePoints_8(" ");
1044
+ t_379 = t_368.read();
1045
+ t_388 = t_379;
1046
+ } else if (genericEq_57(codePart_365, Word)) {
1047
+ t_369 = stringCodePoints_8("z");
1048
+ t_380 = t_369.read();
1049
+ t_388 = t_380;
1050
+ } else {
1051
+ t_388 = null;
1052
+ }
1053
+ }
1054
+ try {
1055
+ return_366 = t_388;
1056
+ return return_366;
1057
+ } catch {
1058
+ }
1059
+ }
1060
+ throw noResultException__256;
1061
+ }
1062
+ constructor(out_394) {
1063
+ let return_395;
1064
+ let t_396;
1065
+ return_395 = void 0;
1066
+ if (!(out_394 !== void 0)) {
1067
+ t_396 = [];
1068
+ out_394 = t_396;
1069
+ }
1070
+ this.#out_227 = out_394;
1071
+ return;
1072
+ }
1073
+ }
1074
+ let typePlaceholder_397;
1075
+ let typePlaceholder_398;
1076
+ function Begin_399(...args_400) {
1077
+ return new Begin_401(...args_400);
1078
+ }
1079
+ class Begin_401 {
1080
+ constructor() {
1081
+ let return_402;
1082
+ return_402 = void 0;
1083
+ return;
1084
+ }
1085
+ }
1086
+ Special_70.implementedBy(Begin_401);
1087
+ let t_403 = Begin_399();
1088
+ export const Begin = t_403;
1089
+ ;
1090
+ function Dot_404(...args_405) {
1091
+ return new Dot_406(...args_405);
1092
+ }
1093
+ class Dot_406 {
1094
+ constructor() {
1095
+ let return_407;
1096
+ return_407 = void 0;
1097
+ return;
1098
+ }
1099
+ }
1100
+ Special_70.implementedBy(Dot_406);
1101
+ let t_408 = Dot_404();
1102
+ export const Dot = t_408;
1103
+ ;
1104
+ function End_409(...args_410) {
1105
+ return new End_411(...args_410);
1106
+ }
1107
+ class End_411 {
1108
+ constructor() {
1109
+ let return_412;
1110
+ return_412 = void 0;
1111
+ return;
1112
+ }
1113
+ }
1114
+ Special_70.implementedBy(End_411);
1115
+ let t_413 = End_409();
1116
+ export const End = t_413;
1117
+ ;
1118
+ function WordBoundary_414(...args_415) {
1119
+ return new WordBoundary_416(...args_415);
1120
+ }
1121
+ class WordBoundary_416 {
1122
+ constructor() {
1123
+ let return_417;
1124
+ return_417 = void 0;
1125
+ return;
1126
+ }
1127
+ }
1128
+ Special_70.implementedBy(WordBoundary_416);
1129
+ let t_418 = WordBoundary_414();
1130
+ export const WordBoundary = t_418;
1131
+ ;
1132
+ let typePlaceholder_419;
1133
+ function Digit_420(...args_421) {
1134
+ return new Digit_422(...args_421);
1135
+ }
1136
+ class Digit_422 {
1137
+ constructor() {
1138
+ let return_423;
1139
+ return_423 = void 0;
1140
+ return;
1141
+ }
1142
+ }
1143
+ SpecialSet_72.implementedBy(Digit_422);
1144
+ let t_424 = Digit_420();
1145
+ export const Digit = t_424;
1146
+ ;
1147
+ function Space_425(...args_426) {
1148
+ return new Space_427(...args_426);
1149
+ }
1150
+ class Space_427 {
1151
+ constructor() {
1152
+ let return_428;
1153
+ return_428 = void 0;
1154
+ return;
1155
+ }
1156
+ }
1157
+ SpecialSet_72.implementedBy(Space_427);
1158
+ let t_429 = Space_425();
1159
+ export const Space = t_429;
1160
+ ;
1161
+ function Word_430(...args_431) {
1162
+ return new Word_432(...args_431);
1163
+ }
1164
+ class Word_432 {
1165
+ constructor() {
1166
+ let return_433;
1167
+ return_433 = void 0;
1168
+ return;
1169
+ }
1170
+ }
1171
+ SpecialSet_72.implementedBy(Word_432);
1172
+ let t_434 = Word_430();
1173
+ export const Word = t_434;
1174
+ ;
1175
+ export function entire(item_435) {
1176
+ let return_436;
1177
+ let t_437 = Sequence(listify_52(Begin, item_435, End));
1178
+ return_436 = t_437;
1179
+ return return_436;
1180
+ };
1181
+ export function oneOrMore(item_438, reluctant_439) {
1182
+ let return_440;
1183
+ if (!(reluctant_439 !== void 0)) {
1184
+ reluctant_439 = false;
1185
+ }
1186
+ let t_441 = Repeat(item_438, 1, null, reluctant_439);
1187
+ return_440 = t_441;
1188
+ return return_440;
1189
+ };
1190
+ export function optional(item_442, reluctant_443) {
1191
+ let return_444;
1192
+ if (!(reluctant_443 !== void 0)) {
1193
+ reluctant_443 = false;
1194
+ }
1195
+ let t_445 = Repeat(item_442, 0, 1, reluctant_443);
1196
+ return_444 = t_445;
1197
+ return return_444;
1198
+ };
1199
+ let t_446 = RegexRefs_181();
1200
+ const regexRefs_217 = t_446;
1201
+ const return_447 = RegexFormatter_221;
1202
+ export default return_447;
1203
+ export {
1204
+ InterfaceType_51
1205
+ };