@temperlang/std 0.3.0 → 0.4.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/regex.js CHANGED
@@ -1,1063 +1,1285 @@
1
1
  import {
2
- InterfaceType as InterfaceType_0, requireInstanceOf as requireInstanceOf__117, requireIsSafeInteger as requireIsSafeInteger__191, listify as listify_69, regexCompileFormatted as regexCompileFormatted_77, regexCompiledFound as regexCompiledFound_81, regexCompiledFind as regexCompiledFind_84, regexCompiledReplace as regexCompiledReplace_89, listedJoin as listedJoin_99, eqGeneric as eqGeneric_119, listBuilderAdd as listBuilderAdd_120, strCat as strCat_129, regexFormatterPushCodeTo as regexFormatterPushCodeTo_133, stringCodePoints as stringCodePoints_140, regexFormatterAdjustCodeSet as regexFormatterAdjustCodeSet_155, listedGet as listedGet_159, intToString as intToString_190
2
+ type as type__10, requireInstanceOf as requireInstanceOf__138, pairConstructor as pairConstructor_90, mapConstructor as mapConstructor_89, regexCompileFormatted as regexCompileFormatted_101, regexCompiledFound as regexCompiledFound_105, regexCompiledFind as regexCompiledFind_110, regexCompiledReplace as regexCompiledReplace_115, regexCompiledSplit as regexCompiledSplit_118, listedJoin as listedJoin_128, listBuilderAdd as listBuilderAdd_146, listedGet as listedGet_174, regexFormatterPushCodeTo as regexFormatterPushCodeTo_176, stringGet as stringGet_184, stringNext as stringNext_185, regexFormatterAdjustCodeSet as regexFormatterAdjustCodeSet_199, listBuilderToList as listBuilderToList_311
3
3
  } from "@temperlang/core";
4
- function methodCompiled1() {
5
- return new Regex(this);
6
- }
7
- function methodFound2(text_3) {
8
- return this.compiled().found(text_3);
9
- }
10
- function methodFind4(text_5) {
11
- return this.compiled().find(text_5);
12
- }
13
- function methodReplace6(text_7, format_8) {
14
- return this.compiled().replace(text_7, format_8);
15
- }
16
- /**
17
- * @typedef {{
18
- * compiled: () => Regex, found: (text_3: string) => boolean, find: (text_5: string) => Map<string, Group>, replace: (text_7: string, format_8: (arg0: Map<string, Group>) => string) => string
19
- * }}
20
- * RegexNode
21
- */
22
- export const RegexNode = new InterfaceType_0("RegexNode", [["m", "compiled", methodCompiled1], ["m", "found", methodFound2], ["m", "find", methodFind4], ["m", "replace", methodReplace6]], [], 1);
23
- export class Capture {
4
+ export class RegexNode extends type__10() {
5
+ /** @returns {Regex} */
6
+ compiled() {
7
+ return new Regex(this);
8
+ }
9
+ /**
10
+ * @param {string} text_2
11
+ * @returns {boolean}
12
+ */
13
+ found(text_2) {
14
+ return this.compiled().found(text_2);
15
+ }
16
+ /**
17
+ * @param {string} text_4
18
+ * @returns {Match}
19
+ */
20
+ find(text_4) {
21
+ return this.compiled().find(text_4);
22
+ }
23
+ /**
24
+ * @param {string} text_6
25
+ * @param {(arg0: Match) => string} format_7
26
+ * @returns {string}
27
+ */
28
+ replace(text_6, format_7) {
29
+ return this.compiled().replace(text_6, format_7);
30
+ }
31
+ /**
32
+ * @param {string} text_9
33
+ * @returns {Array<string>}
34
+ */
35
+ split(text_9) {
36
+ return this.compiled().split(text_9);
37
+ }
38
+ };
39
+ export class Capture extends type__10(RegexNode) {
24
40
  /** @type {string} */
25
- #name_9;
41
+ #name_11;
26
42
  /** @type {RegexNode} */
27
- #item_10;
43
+ #item_12;
28
44
  /**
29
- * @param {string} name_11
30
- * @param {RegexNode} item_12
45
+ * @param {string} name_13
46
+ * @param {RegexNode} item_14
31
47
  */
32
- constructor(name_11, item_12) {
33
- this.#name_9 = name_11;
34
- this.#item_10 = item_12;
48
+ constructor(name_13, item_14) {
49
+ super ();
50
+ this.#name_11 = name_13;
51
+ this.#item_12 = item_14;
35
52
  return;
36
53
  }
37
54
  /** @returns {string} */
38
55
  get name() {
39
- return this.#name_9;
56
+ return this.#name_11;
40
57
  }
41
58
  /** @returns {RegexNode} */
42
59
  get item() {
43
- return this.#item_10;
60
+ return this.#item_12;
44
61
  }
45
62
  };
46
- RegexNode.implementedBy(Capture);
47
- /**
48
- * @typedef {{}}
49
- * CodePart
50
- */
51
- export const CodePart = new InterfaceType_0("CodePart", [], [RegexNode], 2);
52
- export class CodePoints {
63
+ export class CodePart extends type__10(RegexNode) {
64
+ };
65
+ export class CodePoints extends type__10(CodePart) {
53
66
  /** @type {string} */
54
- #value_15;
55
- /** @param {string} value_16 */
56
- constructor(value_16) {
57
- this.#value_15 = value_16;
67
+ #value_17;
68
+ /** @param {string} value_18 */
69
+ constructor(value_18) {
70
+ super ();
71
+ this.#value_17 = value_18;
58
72
  return;
59
73
  }
60
74
  /** @returns {string} */
61
75
  get value() {
62
- return this.#value_15;
76
+ return this.#value_17;
63
77
  }
64
78
  };
65
- CodePart.implementedBy(CodePoints);
66
- /**
67
- * @typedef {{}}
68
- * Special
69
- */
70
- export const Special = new InterfaceType_0("Special", [], [RegexNode], 2);
71
- /**
72
- * @typedef {{}}
73
- * SpecialSet
74
- */
75
- export const SpecialSet = new InterfaceType_0("SpecialSet", [], [CodePart, Special], 3);
76
- export class CodeRange {
79
+ export class Special extends type__10(RegexNode) {
80
+ };
81
+ export class SpecialSet extends type__10(CodePart, Special) {
82
+ };
83
+ export class CodeRange extends type__10(CodePart) {
77
84
  /** @type {number} */
78
- #min_18;
85
+ #min_20;
79
86
  /** @type {number} */
80
- #max_19;
87
+ #max_21;
81
88
  /**
82
- * @param {number} min_20
83
- * @param {number} max_21
89
+ * @param {number} min_22
90
+ * @param {number} max_23
84
91
  */
85
- constructor(min_20, max_21) {
86
- this.#min_18 = min_20;
87
- this.#max_19 = max_21;
92
+ constructor(min_22, max_23) {
93
+ super ();
94
+ this.#min_20 = min_22;
95
+ this.#max_21 = max_23;
88
96
  return;
89
97
  }
90
98
  /** @returns {number} */
91
99
  get min() {
92
- return this.#min_18;
100
+ return this.#min_20;
93
101
  }
94
102
  /** @returns {number} */
95
103
  get max() {
96
- return this.#max_19;
104
+ return this.#max_21;
97
105
  }
98
106
  };
99
- CodePart.implementedBy(CodeRange);
100
- function getterItems24() {
101
- return null;
102
- }
103
- /**
104
- * @template ITEM_25
105
- * @typedef {{
106
- * get items(): Array<ITEM_25>
107
- * }}
108
- * ItemizedRegex
109
- */
110
- export const ItemizedRegex = new InterfaceType_0("ItemizedRegex", [["g", "items", getterItems24]], [RegexNode], 2);
111
- export class CodeSet {
107
+ /** @template ITEM_27 */
108
+ export class ItemizedRegex extends type__10(RegexNode) {
109
+ };
110
+ export class CodeSet extends type__10(ItemizedRegex) {
112
111
  /** @type {Array<CodePart>} */
113
- #items_26;
112
+ #items_28;
114
113
  /** @type {boolean} */
115
- #negated_27;
114
+ #negated_29;
116
115
  /**
117
- * @param {Array<CodePart>} items_28
118
- * @param {boolean} negated_29
116
+ * @param {Array<CodePart>} items_30
117
+ * @param {boolean | null} [negated_31]
119
118
  */
120
- constructor(items_28, negated_29) {
121
- if (!(negated_29 !== void 0)) {
122
- negated_29 = false;
119
+ constructor(items_30, negated_31) {
120
+ super ();
121
+ let negated_32;
122
+ if (negated_31 == null) {
123
+ negated_32 = false;
124
+ } else {
125
+ negated_32 = negated_31;
123
126
  }
124
- this.#items_26 = items_28;
125
- this.#negated_27 = negated_29;
127
+ this.#items_28 = items_30;
128
+ this.#negated_29 = negated_32;
126
129
  return;
127
130
  }
128
131
  /** @returns {Array<CodePart>} */
129
132
  get items() {
130
- return this.#items_26;
133
+ return this.#items_28;
131
134
  }
132
135
  /** @returns {boolean} */
133
136
  get negated() {
134
- return this.#negated_27;
137
+ return this.#negated_29;
135
138
  }
136
139
  };
137
- ItemizedRegex.implementedBy(CodeSet);
138
- export class Or {
140
+ export class Or extends type__10(ItemizedRegex) {
139
141
  /** @type {Array<RegexNode>} */
140
- #items_32;
141
- /** @param {Array<RegexNode>} items_33 */
142
- constructor(items_33) {
143
- this.#items_32 = items_33;
142
+ #items_35;
143
+ /** @param {Array<RegexNode>} items_36 */
144
+ constructor(items_36) {
145
+ super ();
146
+ this.#items_35 = items_36;
144
147
  return;
145
148
  }
146
149
  /** @returns {Array<RegexNode>} */
147
150
  get items() {
148
- return this.#items_32;
151
+ return this.#items_35;
149
152
  }
150
153
  };
151
- ItemizedRegex.implementedBy(Or);
152
- export class Repeat {
154
+ export class Repeat extends type__10(RegexNode) {
153
155
  /** @type {RegexNode} */
154
- #item_35;
156
+ #item_38;
155
157
  /** @type {number} */
156
- #min_36;
158
+ #min_39;
157
159
  /** @type {number | null} */
158
- #max_37;
160
+ #max_40;
159
161
  /** @type {boolean} */
160
- #reluctant_38;
162
+ #reluctant_41;
161
163
  /**
162
- * @param {RegexNode} item_39
163
- * @param {number} min_40
164
- * @param {number | null} max_41
165
- * @param {boolean} reluctant_42
164
+ * @param {RegexNode} item_42
165
+ * @param {number} min_43
166
+ * @param {number | null} max_44
167
+ * @param {boolean | null} [reluctant_45]
166
168
  */
167
- constructor(item_39, min_40, max_41, reluctant_42) {
168
- if (!(reluctant_42 !== void 0)) {
169
- reluctant_42 = false;
169
+ constructor(item_42, min_43, max_44, reluctant_45) {
170
+ super ();
171
+ let reluctant_46;
172
+ if (reluctant_45 == null) {
173
+ reluctant_46 = false;
174
+ } else {
175
+ reluctant_46 = reluctant_45;
170
176
  }
171
- this.#item_35 = item_39;
172
- this.#min_36 = min_40;
173
- this.#max_37 = max_41;
174
- this.#reluctant_38 = reluctant_42;
177
+ this.#item_38 = item_42;
178
+ this.#min_39 = min_43;
179
+ this.#max_40 = max_44;
180
+ this.#reluctant_41 = reluctant_46;
175
181
  return;
176
182
  }
177
183
  /** @returns {RegexNode} */
178
184
  get item() {
179
- return this.#item_35;
185
+ return this.#item_38;
180
186
  }
181
187
  /** @returns {number} */
182
188
  get min() {
183
- return this.#min_36;
189
+ return this.#min_39;
184
190
  }
185
191
  /** @returns {number | null} */
186
192
  get max() {
187
- return this.#max_37;
193
+ return this.#max_40;
188
194
  }
189
195
  /** @returns {boolean} */
190
196
  get reluctant() {
191
- return this.#reluctant_38;
197
+ return this.#reluctant_41;
192
198
  }
193
199
  };
194
- RegexNode.implementedBy(Repeat);
195
- export class Sequence {
200
+ export class Sequence extends type__10(ItemizedRegex) {
196
201
  /** @type {Array<RegexNode>} */
197
- #items_47;
198
- /** @param {Array<RegexNode>} items_48 */
199
- constructor(items_48) {
200
- this.#items_47 = items_48;
202
+ #items_51;
203
+ /** @param {Array<RegexNode>} items_52 */
204
+ constructor(items_52) {
205
+ super ();
206
+ this.#items_51 = items_52;
201
207
  return;
202
208
  }
203
209
  /** @returns {Array<RegexNode>} */
204
210
  get items() {
205
- return this.#items_47;
211
+ return this.#items_51;
206
212
  }
207
213
  };
208
- ItemizedRegex.implementedBy(Sequence);
209
- export class Group {
214
+ export class Match extends type__10() {
215
+ /** @type {Group} */
216
+ #full_54;
217
+ /** @type {Map<string, Group>} */
218
+ #groups_55;
219
+ /**
220
+ * @param {Group} full_56
221
+ * @param {Map<string, Group>} groups_57
222
+ */
223
+ constructor(full_56, groups_57) {
224
+ super ();
225
+ this.#full_54 = full_56;
226
+ this.#groups_55 = groups_57;
227
+ return;
228
+ }
229
+ /** @returns {Group} */
230
+ get full() {
231
+ return this.#full_54;
232
+ }
233
+ /** @returns {Map<string, Group>} */
234
+ get groups() {
235
+ return this.#groups_55;
236
+ }
237
+ };
238
+ export class Group extends type__10() {
210
239
  /** @type {string} */
211
- #name_50;
240
+ #name_60;
212
241
  /** @type {string} */
213
- #value_51;
214
- /** @type {number} */
215
- #codePointsBegin_52;
242
+ #value_61;
243
+ /** @type {globalThis.number} */
244
+ #begin_62;
245
+ /** @type {globalThis.number} */
246
+ #end_63;
216
247
  /**
217
- * @param {string} name_53
218
- * @param {string} value_54
219
- * @param {number} codePointsBegin_55
248
+ * @param {string} name_64
249
+ * @param {string} value_65
250
+ * @param {globalThis.number} begin_66
251
+ * @param {globalThis.number} end_67
220
252
  */
221
- constructor(name_53, value_54, codePointsBegin_55) {
222
- this.#name_50 = name_53;
223
- this.#value_51 = value_54;
224
- this.#codePointsBegin_52 = codePointsBegin_55;
253
+ constructor(name_64, value_65, begin_66, end_67) {
254
+ super ();
255
+ this.#name_60 = name_64;
256
+ this.#value_61 = value_65;
257
+ this.#begin_62 = begin_66;
258
+ this.#end_63 = end_67;
225
259
  return;
226
260
  }
227
261
  /** @returns {string} */
228
262
  get name() {
229
- return this.#name_50;
263
+ return this.#name_60;
230
264
  }
231
265
  /** @returns {string} */
232
266
  get value() {
233
- return this.#value_51;
267
+ return this.#value_61;
234
268
  }
235
- /** @returns {number} */
236
- get codePointsBegin() {
237
- return this.#codePointsBegin_52;
269
+ /** @returns {globalThis.number} */
270
+ get begin() {
271
+ return this.#begin_62;
272
+ }
273
+ /** @returns {globalThis.number} */
274
+ get end() {
275
+ return this.#end_63;
238
276
  }
239
277
  };
240
- class RegexRefs_59 {
278
+ class RegexRefs_72 extends type__10() {
241
279
  /** @type {CodePoints} */
242
- #codePoints_60;
280
+ #codePoints_73;
243
281
  /** @type {Group} */
244
- #group_61;
282
+ #group_74;
283
+ /** @type {Match} */
284
+ #match_75;
245
285
  /** @type {Or} */
246
- #orObject_62;
286
+ #orObject_76;
247
287
  /**
248
- * @param {CodePoints} codePoints_63
249
- * @param {Group} group_64
250
- * @param {Or} orObject_65
288
+ * @param {CodePoints | null} [codePoints_77]
289
+ * @param {Group | null} [group_78]
290
+ * @param {Match | null} [match_79]
291
+ * @param {Or | null} [orObject_80]
251
292
  */
252
- constructor(codePoints_63, group_64, orObject_65) {
253
- let t_66;
254
- let t_67;
255
- let t_68;
256
- if (!(codePoints_63 !== void 0)) {
257
- t_66 = new CodePoints("");
258
- codePoints_63 = t_66;
293
+ constructor(codePoints_77, group_78, match_79, orObject_80) {
294
+ super ();
295
+ let t_81;
296
+ let t_82;
297
+ let t_83;
298
+ let t_84;
299
+ let t_85;
300
+ let codePoints_86;
301
+ if (codePoints_77 == null) {
302
+ t_81 = new CodePoints("");
303
+ codePoints_86 = t_81;
304
+ } else {
305
+ codePoints_86 = codePoints_77;
306
+ }
307
+ let group_87;
308
+ if (group_78 == null) {
309
+ t_82 = new Group("", "", 0, 0);
310
+ group_87 = t_82;
311
+ } else {
312
+ group_87 = group_78;
259
313
  }
260
- if (!(group_64 !== void 0)) {
261
- t_67 = new Group("", "", 0);
262
- group_64 = t_67;
314
+ let match_88;
315
+ if (match_79 == null) {
316
+ t_83 = mapConstructor_89(Object.freeze([pairConstructor_90("", group_87)]));
317
+ t_84 = new Match(group_87, t_83);
318
+ match_88 = t_84;
319
+ } else {
320
+ match_88 = match_79;
263
321
  }
264
- if (!(orObject_65 !== void 0)) {
265
- t_68 = new Or(listify_69());
266
- orObject_65 = t_68;
322
+ let orObject_91;
323
+ if (orObject_80 == null) {
324
+ t_85 = new Or(Object.freeze([]));
325
+ orObject_91 = t_85;
326
+ } else {
327
+ orObject_91 = orObject_80;
267
328
  }
268
- this.#codePoints_60 = codePoints_63;
269
- this.#group_61 = group_64;
270
- this.#orObject_62 = orObject_65;
329
+ this.#codePoints_73 = codePoints_86;
330
+ this.#group_74 = group_87;
331
+ this.#match_75 = match_88;
332
+ this.#orObject_76 = orObject_91;
271
333
  return;
272
334
  }
273
335
  /** @returns {CodePoints} */
274
336
  get codePoints() {
275
- return this.#codePoints_60;
337
+ return this.#codePoints_73;
276
338
  }
277
339
  /** @returns {Group} */
278
340
  get group() {
279
- return this.#group_61;
341
+ return this.#group_74;
342
+ }
343
+ /** @returns {Match} */
344
+ get match() {
345
+ return this.#match_75;
280
346
  }
281
347
  /** @returns {Or} */
282
348
  get orObject() {
283
- return this.#orObject_62;
349
+ return this.#orObject_76;
284
350
  }
285
351
  }
286
- export class Regex {
352
+ export class Regex extends type__10() {
287
353
  /** @type {RegexNode} */
288
- #data_73;
289
- /** @param {RegexNode} data_74 */
290
- constructor(data_74) {
291
- this.#data_73 = data_74;
292
- let t_75 = this.format();
293
- let t_76 = regexCompileFormatted_77(this, t_75);
294
- this.#compiled_78 = t_76;
354
+ #data_96;
355
+ /** @param {RegexNode} data_97 */
356
+ constructor(data_97) {
357
+ super ();
358
+ this.#data_96 = data_97;
359
+ let t_98 = this.#format_99();
360
+ let t_100 = regexCompileFormatted_101(this, t_98);
361
+ this.#compiled_102 = t_100;
295
362
  return;
296
363
  }
297
364
  /**
298
- * @param {string} text_80
365
+ * @param {string} text_104
299
366
  * @returns {boolean}
300
367
  */
301
- found(text_80) {
302
- return regexCompiledFound_81(this, this.#compiled_78, text_80);
368
+ found(text_104) {
369
+ return regexCompiledFound_105(this, this.#compiled_102, text_104);
303
370
  }
304
371
  /**
305
- * @param {string} text_83
306
- * @returns {Map<string, Group>}
372
+ * @param {string} text_107
373
+ * @param {globalThis.number | null} [begin_108]
374
+ * @returns {Match}
307
375
  */
308
- find(text_83) {
309
- return regexCompiledFind_84(this, this.#compiled_78, text_83, regexRefs_85);
376
+ find(text_107, begin_108) {
377
+ let begin_109;
378
+ if (begin_108 == null) {
379
+ begin_109 = 0;
380
+ } else {
381
+ begin_109 = begin_108;
382
+ }
383
+ return regexCompiledFind_110(this, this.#compiled_102, text_107, begin_109, regexRefs_111);
310
384
  }
311
385
  /**
312
- * @param {string} text_87
313
- * @param {(arg0: Map<string, Group>) => string} format_88
386
+ * @param {string} text_113
387
+ * @param {(arg0: Match) => string} format_114
314
388
  * @returns {string}
315
389
  */
316
- replace(text_87, format_88) {
317
- return regexCompiledReplace_89(this, this.#compiled_78, text_87, format_88, regexRefs_85);
390
+ replace(text_113, format_114) {
391
+ return regexCompiledReplace_115(this, this.#compiled_102, text_113, format_114, regexRefs_111);
392
+ }
393
+ /**
394
+ * @param {string} text_117
395
+ * @returns {Array<string>}
396
+ */
397
+ split(text_117) {
398
+ return regexCompiledSplit_118(this, this.#compiled_102, text_117, regexRefs_111);
318
399
  }
319
400
  /** @type {unknown} */
320
- #compiled_78;
401
+ #compiled_102;
321
402
  /** @returns {string} */
322
- format() {
323
- return new RegexFormatter_91().format(this.#data_73);
403
+ #format_99() {
404
+ return new RegexFormatter_120().format(this.#data_96);
324
405
  }
325
406
  /** @returns {RegexNode} */
326
407
  get data() {
327
- return this.#data_73;
408
+ return this.#data_96;
328
409
  }
329
410
  };
330
- class RegexFormatter_91 {
411
+ class RegexFormatter_120 extends type__10() {
331
412
  /** @type {Array<string>} */
332
- #out_93;
413
+ #out_122;
333
414
  /**
334
- * @param {RegexNode} regex_95
415
+ * @param {RegexNode} regex_124
335
416
  * @returns {string}
336
417
  */
337
- format(regex_95) {
338
- this.pushRegex(regex_95);
339
- let t_96 = this.#out_93;
340
- function fn_97(x_98) {
341
- return x_98;
342
- }
343
- return listedJoin_99(t_96, "", fn_97);
344
- }
345
- /** @param {RegexNode} regex_101 */
346
- pushRegex(regex_101) {
347
- let return_102;
348
- let t_103;
349
- let t_104;
350
- let t_105;
351
- let t_106;
352
- let t_107;
353
- let t_108;
354
- let t_109;
355
- let t_110;
356
- let t_111;
357
- let t_112;
358
- let t_113;
359
- let t_114;
360
- let t_115;
361
- let t_116;
362
- try {
363
- requireInstanceOf__117(regex_101, Capture);
364
- t_103 = true;
365
- } catch {
366
- t_103 = false;
418
+ format(regex_124) {
419
+ this.#pushRegex_125(regex_124);
420
+ function fn_126(x_127) {
421
+ return x_127;
367
422
  }
368
- s__1253_118: {
369
- if (t_103) {
370
- try {
371
- t_104 = requireInstanceOf__117(regex_101, Capture);
372
- } catch {
373
- break s__1253_118;
374
- }
375
- this.pushCapture(t_104);
376
- } else {
377
- try {
378
- requireInstanceOf__117(regex_101, CodePoints);
379
- t_105 = true;
380
- } catch {
381
- t_105 = false;
382
- }
383
- if (t_105) {
384
- try {
385
- t_106 = requireInstanceOf__117(regex_101, CodePoints);
386
- } catch {
387
- break s__1253_118;
388
- }
389
- this.pushCodePoints(t_106, false);
390
- } else {
391
- try {
392
- requireInstanceOf__117(regex_101, CodeRange);
393
- t_107 = true;
394
- } catch {
395
- t_107 = false;
396
- }
397
- if (t_107) {
398
- try {
399
- t_108 = requireInstanceOf__117(regex_101, CodeRange);
400
- } catch {
401
- break s__1253_118;
402
- }
403
- this.pushCodeRange(t_108);
404
- } else {
405
- try {
406
- requireInstanceOf__117(regex_101, CodeSet);
407
- t_109 = true;
408
- } catch {
409
- t_109 = false;
410
- }
411
- if (t_109) {
412
- try {
413
- t_110 = requireInstanceOf__117(regex_101, CodeSet);
414
- } catch {
415
- break s__1253_118;
416
- }
417
- this.pushCodeSet(t_110);
418
- } else {
419
- try {
420
- requireInstanceOf__117(regex_101, Or);
421
- t_111 = true;
422
- } catch {
423
- t_111 = false;
424
- }
425
- if (t_111) {
426
- try {
427
- t_112 = requireInstanceOf__117(regex_101, Or);
428
- } catch {
429
- break s__1253_118;
430
- }
431
- this.pushOr(t_112);
432
- } else {
433
- try {
434
- requireInstanceOf__117(regex_101, Repeat);
435
- t_113 = true;
436
- } catch {
437
- t_113 = false;
438
- }
439
- if (t_113) {
440
- try {
441
- t_114 = requireInstanceOf__117(regex_101, Repeat);
442
- } catch {
443
- break s__1253_118;
444
- }
445
- this.pushRepeat(t_114);
446
- } else {
447
- try {
448
- requireInstanceOf__117(regex_101, Sequence);
449
- t_115 = true;
450
- } catch {
451
- t_115 = false;
452
- }
453
- if (t_115) {
454
- try {
455
- t_116 = requireInstanceOf__117(regex_101, Sequence);
456
- } catch {
457
- break s__1253_118;
458
- }
459
- this.pushSequence(t_116);
460
- } else if (eqGeneric_119(regex_101, Begin)) {
461
- try {
462
- listBuilderAdd_120(this.#out_93, "^");
463
- } catch {
464
- break s__1253_118;
465
- }
466
- } else if (eqGeneric_119(regex_101, Dot)) {
467
- try {
468
- listBuilderAdd_120(this.#out_93, ".");
469
- } catch {
470
- break s__1253_118;
471
- }
472
- } else if (eqGeneric_119(regex_101, End)) {
473
- try {
474
- listBuilderAdd_120(this.#out_93, "\u0024");
475
- } catch {
476
- break s__1253_118;
477
- }
478
- } else if (eqGeneric_119(regex_101, WordBoundary)) {
479
- try {
480
- listBuilderAdd_120(this.#out_93, "\\b");
481
- } catch {
482
- break s__1253_118;
483
- }
484
- } else if (eqGeneric_119(regex_101, Digit)) {
485
- try {
486
- listBuilderAdd_120(this.#out_93, "\\d");
487
- } catch {
488
- break s__1253_118;
489
- }
490
- } else if (eqGeneric_119(regex_101, Space)) {
491
- try {
492
- listBuilderAdd_120(this.#out_93, "\\s");
493
- } catch {
494
- break s__1253_118;
495
- }
496
- } else if (eqGeneric_119(regex_101, Word)) {
497
- try {
498
- listBuilderAdd_120(this.#out_93, "\\w");
499
- } catch {
500
- break s__1253_118;
501
- }
502
- } else {
503
- void 0;
504
- }
505
- }
506
- }
507
- }
508
- }
509
- }
510
- }
511
- return_102 = void 0;
512
- return return_102;
423
+ return listedJoin_128(this.#out_122, "", fn_126);
424
+ }
425
+ /** @param {RegexNode} regex_130 */
426
+ #pushRegex_125(regex_130) {
427
+ let t_131;
428
+ let t_132;
429
+ let t_133;
430
+ let t_134;
431
+ let t_135;
432
+ let t_136;
433
+ let t_137;
434
+ if (regex_130 instanceof Capture) {
435
+ t_131 = requireInstanceOf__138(regex_130, Capture);
436
+ this.#pushCapture_139(t_131);
437
+ } else if (regex_130 instanceof CodePoints) {
438
+ t_132 = requireInstanceOf__138(regex_130, CodePoints);
439
+ this.#pushCodePoints_140(t_132, false);
440
+ } else if (regex_130 instanceof CodeRange) {
441
+ t_133 = requireInstanceOf__138(regex_130, CodeRange);
442
+ this.#pushCodeRange_141(t_133);
443
+ } else if (regex_130 instanceof CodeSet) {
444
+ t_134 = requireInstanceOf__138(regex_130, CodeSet);
445
+ this.#pushCodeSet_142(t_134);
446
+ } else if (regex_130 instanceof Or) {
447
+ t_135 = requireInstanceOf__138(regex_130, Or);
448
+ this.#pushOr_143(t_135);
449
+ } else if (regex_130 instanceof Repeat) {
450
+ t_136 = requireInstanceOf__138(regex_130, Repeat);
451
+ this.#pushRepeat_144(t_136);
452
+ } else if (regex_130 instanceof Sequence) {
453
+ t_137 = requireInstanceOf__138(regex_130, Sequence);
454
+ this.#pushSequence_145(t_137);
455
+ } else if (Object.is(regex_130, Begin)) {
456
+ listBuilderAdd_146(this.#out_122, "^");
457
+ } else if (Object.is(regex_130, Dot)) {
458
+ listBuilderAdd_146(this.#out_122, ".");
459
+ } else if (Object.is(regex_130, End)) {
460
+ listBuilderAdd_146(this.#out_122, "\u0024");
461
+ } else if (Object.is(regex_130, WordBoundary)) {
462
+ listBuilderAdd_146(this.#out_122, "\\b");
463
+ } else if (Object.is(regex_130, Digit)) {
464
+ listBuilderAdd_146(this.#out_122, "\\d");
465
+ } else if (Object.is(regex_130, Space)) {
466
+ listBuilderAdd_146(this.#out_122, "\\s");
467
+ } else if (Object.is(regex_130, Word)) {
468
+ listBuilderAdd_146(this.#out_122, "\\w");
513
469
  }
514
- throw Error();
515
- }
516
- /** @param {Capture} capture_122 */
517
- pushCapture(capture_122) {
518
- listBuilderAdd_120(this.#out_93, "(");
519
- let t_123 = this.#out_93;
520
- let t_124 = capture_122.name;
521
- this.pushCaptureName(t_123, t_124);
522
- let t_125 = capture_122.item;
523
- this.pushRegex(t_125);
524
- listBuilderAdd_120(this.#out_93, ")");
525
470
  return;
526
471
  }
527
- /**
528
- * @param {Array<string>} out_127
529
- * @param {string} name_128
530
- */
531
- pushCaptureName(out_127, name_128) {
532
- listBuilderAdd_120(out_127, strCat_129("?\u003c", name_128, "\u003e"));
472
+ /** @param {Capture} capture_148 */
473
+ #pushCapture_139(capture_148) {
474
+ listBuilderAdd_146(this.#out_122, "(");
475
+ let t_149 = this.#out_122;
476
+ let t_150 = capture_148.name;
477
+ this.#pushCaptureName_151(t_149, t_150);
478
+ let t_152 = capture_148.item;
479
+ this.#pushRegex_125(t_152);
480
+ listBuilderAdd_146(this.#out_122, ")");
533
481
  return;
534
482
  }
535
483
  /**
536
- * @param {number} code_131
537
- * @param {boolean} insideCodeSet_132
484
+ * @param {Array<string>} out_154
485
+ * @param {string} name_155
538
486
  */
539
- pushCode(code_131, insideCodeSet_132) {
540
- regexFormatterPushCodeTo_133(this, this.#out_93, code_131, insideCodeSet_132);
487
+ #pushCaptureName_151(out_154, name_155) {
488
+ listBuilderAdd_146(out_154, "?\u003c" + name_155 + "\u003e");
541
489
  return;
542
490
  }
543
491
  /**
544
- * @param {CodePoints} codePoints_135
545
- * @param {boolean} insideCodeSet_136
492
+ * @param {number} code_158
493
+ * @param {boolean} insideCodeSet_159
546
494
  */
547
- pushCodePoints(codePoints_135, insideCodeSet_136) {
548
- let t_137;
549
- let t_138;
550
- let t_139 = stringCodePoints_140(codePoints_135.value);
551
- let slice_141 = t_139;
552
- while (true) {
553
- if (! slice_141.isEmpty) {
554
- t_137 = slice_141.read();
555
- this.pushCode(t_137, insideCodeSet_136);
556
- t_138 = slice_141.advance(1);
557
- slice_141 = t_138;
558
- } else {
559
- break;
560
- }
561
- }
562
- return;
563
- }
564
- /** @param {CodeRange} codeRange_143 */
565
- pushCodeRange(codeRange_143) {
566
- listBuilderAdd_120(this.#out_93, "[");
567
- this.pushCodeRangeUnwrapped(codeRange_143);
568
- listBuilderAdd_120(this.#out_93, "]");
569
- return;
570
- }
571
- /** @param {CodeRange} codeRange_145 */
572
- pushCodeRangeUnwrapped(codeRange_145) {
573
- let t_146 = codeRange_145.min;
574
- this.pushCode(t_146, true);
575
- listBuilderAdd_120(this.#out_93, "-");
576
- let t_147 = codeRange_145.max;
577
- this.pushCode(t_147, true);
578
- return;
579
- }
580
- /** @param {CodeSet} codeSet_149 */
581
- pushCodeSet(codeSet_149) {
582
- let t_150;
583
- let t_151;
584
- let t_152;
585
- let t_153;
586
- const adjusted_154 = regexFormatterAdjustCodeSet_155(this, codeSet_149, regexRefs_85);
587
- try {
588
- requireInstanceOf__117(adjusted_154, CodeSet);
589
- t_151 = true;
590
- } catch {
591
- t_151 = false;
592
- }
593
- s__1260_156: {
594
- if (t_151) {
595
- s__1261_157: {
596
- try {
597
- t_152 = requireInstanceOf__117(adjusted_154, CodeSet);
598
- listBuilderAdd_120(this.#out_93, "[");
599
- } catch {
600
- break s__1261_157;
601
- }
602
- if (t_152.negated) {
603
- try {
604
- listBuilderAdd_120(this.#out_93, "^");
605
- } catch {
606
- break s__1261_157;
607
- }
608
- } else {
609
- void 0;
610
- }
611
- let i_158 = 0;
612
- while (true) {
613
- t_150 = t_152.items.length;
614
- if (i_158 < t_150) {
615
- try {
616
- t_153 = listedGet_159(t_152.items, i_158);
617
- } catch {
618
- break s__1261_157;
619
- }
620
- this.pushCodeSetItem(t_153);
621
- i_158 = i_158 + 1;
622
- } else {
623
- break;
624
- }
625
- }
626
- try {
627
- listBuilderAdd_120(this.#out_93, "]");
628
- break s__1260_156;
629
- } catch {
630
- }
631
- }
632
- throw Error();
633
- }
634
- this.pushRegex(adjusted_154);
635
- }
636
- return;
637
- }
638
- /** @param {CodePart} codePart_161 */
639
- pushCodeSetItem(codePart_161) {
640
- let return_162;
495
+ #pushCode_157(code_158, insideCodeSet_159) {
496
+ let return_160;
497
+ let t_161;
498
+ let t_162;
641
499
  let t_163;
642
500
  let t_164;
643
501
  let t_165;
644
502
  let t_166;
645
503
  let t_167;
646
504
  let t_168;
647
- try {
648
- requireInstanceOf__117(codePart_161, CodePoints);
649
- t_163 = true;
650
- } catch {
651
- t_163 = false;
652
- }
653
- s__1266_169: {
654
- if (t_163) {
655
- try {
656
- t_164 = requireInstanceOf__117(codePart_161, CodePoints);
657
- } catch {
658
- break s__1266_169;
659
- }
660
- this.pushCodePoints(t_164, true);
505
+ let t_169;
506
+ fn_170: {
507
+ let specialEscape_171;
508
+ if (code_158 === Codes_172.carriageReturn) {
509
+ specialEscape_171 = "r";
510
+ } else if (code_158 === Codes_172.newline) {
511
+ specialEscape_171 = "n";
512
+ } else if (code_158 === Codes_172.tab) {
513
+ specialEscape_171 = "t";
661
514
  } else {
662
- try {
663
- requireInstanceOf__117(codePart_161, CodeRange);
664
- t_165 = true;
665
- } catch {
666
- t_165 = false;
667
- }
668
- if (t_165) {
669
- try {
670
- t_166 = requireInstanceOf__117(codePart_161, CodeRange);
671
- } catch {
672
- break s__1266_169;
673
- }
674
- this.pushCodeRangeUnwrapped(t_166);
515
+ specialEscape_171 = "";
516
+ }
517
+ if (specialEscape_171 !== "") {
518
+ listBuilderAdd_146(this.#out_122, "\\");
519
+ listBuilderAdd_146(this.#out_122, specialEscape_171);
520
+ return_160 = void 0;
521
+ break fn_170;
522
+ }
523
+ if (code_158 <= 127) {
524
+ let escapeNeed_173;
525
+ escapeNeed_173 = listedGet_174(escapeNeeds_175, code_158);
526
+ if (escapeNeed_173 === 2) {
527
+ t_162 = true;
675
528
  } else {
676
- try {
677
- requireInstanceOf__117(codePart_161, SpecialSet);
678
- t_167 = true;
679
- } catch {
680
- t_167 = false;
681
- }
682
- if (t_167) {
683
- try {
684
- t_168 = requireInstanceOf__117(codePart_161, SpecialSet);
685
- } catch {
686
- break s__1266_169;
687
- }
688
- this.pushRegex(t_168);
529
+ if (insideCodeSet_159) {
530
+ t_161 = code_158 === Codes_172.dash;
689
531
  } else {
690
- void 0;
532
+ t_161 = false;
691
533
  }
534
+ t_162 = t_161;
692
535
  }
693
- }
694
- return_162 = void 0;
695
- return return_162;
696
- }
697
- throw Error();
698
- }
699
- /** @param {Or} or_171 */
700
- pushOr(or_171) {
701
- let t_172;
702
- let t_173;
703
- let t_174;
704
- s__1268_175: if (! ! or_171.items.length) {
705
- s__1269_176: {
706
- try {
707
- listBuilderAdd_120(this.#out_93, "(?:");
708
- t_173 = listedGet_159(or_171.items, 0);
709
- } catch {
710
- break s__1269_176;
711
- }
712
- this.pushRegex(t_173);
713
- let i_177 = 1;
714
- while (true) {
715
- t_172 = or_171.items.length;
716
- if (i_177 < t_172) {
717
- try {
718
- listBuilderAdd_120(this.#out_93, "|");
719
- t_174 = listedGet_159(or_171.items, i_177);
720
- } catch {
721
- break;
722
- }
723
- this.pushRegex(t_174);
724
- i_177 = i_177 + 1;
725
- } else {
726
- try {
727
- listBuilderAdd_120(this.#out_93, ")");
728
- } catch {
729
- break s__1269_176;
730
- }
731
- break s__1268_175;
732
- }
536
+ if (t_162) {
537
+ listBuilderAdd_146(this.#out_122, "\\");
538
+ t_163 = String.fromCodePoint(code_158);
539
+ listBuilderAdd_146(this.#out_122, t_163);
540
+ return_160 = void 0;
541
+ break fn_170;
542
+ } else if (escapeNeed_173 === 0) {
543
+ t_164 = String.fromCodePoint(code_158);
544
+ listBuilderAdd_146(this.#out_122, t_164);
545
+ return_160 = void 0;
546
+ break fn_170;
733
547
  }
734
548
  }
735
- throw Error();
736
- }
737
- return;
738
- }
739
- /** @param {Repeat} repeat_179 */
740
- pushRepeat(repeat_179) {
741
- let return_180;
742
- let t_181;
743
- let t_182;
744
- let t_183;
745
- let t_184;
746
- let t_185;
747
- let t_186;
748
- s__1273_187: {
749
- let min_188;
750
- let max_189;
751
- try {
752
- listBuilderAdd_120(this.#out_93, "(?:");
753
- t_181 = repeat_179.item;
754
- this.pushRegex(t_181);
755
- listBuilderAdd_120(this.#out_93, ")");
756
- min_188 = repeat_179.min;
757
- max_189 = repeat_179.max;
758
- } catch {
759
- break s__1273_187;
760
- }
761
- if (min_188 === 0) {
762
- t_182 = max_189 === 1;
763
- } else {
764
- t_182 = false;
765
- }
766
- if (t_182) {
767
- try {
768
- listBuilderAdd_120(this.#out_93, "?");
769
- } catch {
770
- break s__1273_187;
771
- }
549
+ if (code_158 >= Codes_172.supplementalMin) {
550
+ t_168 = true;
772
551
  } else {
773
- if (min_188 === 0) {
774
- t_183 = max_189 === null;
775
- } else {
776
- t_183 = false;
777
- }
778
- if (t_183) {
779
- try {
780
- listBuilderAdd_120(this.#out_93, "*");
781
- } catch {
782
- break s__1273_187;
783
- }
784
- } else {
785
- if (min_188 === 1) {
786
- t_184 = max_189 === null;
552
+ if (code_158 > Codes_172.highControlMax) {
553
+ if (Codes_172.surrogateMin <= code_158) {
554
+ t_165 = code_158 <= Codes_172.surrogateMax;
787
555
  } else {
788
- t_184 = false;
556
+ t_165 = false;
789
557
  }
790
- if (t_184) {
791
- try {
792
- listBuilderAdd_120(this.#out_93, "+");
793
- } catch {
794
- break s__1273_187;
795
- }
558
+ if (t_165) {
559
+ t_166 = true;
796
560
  } else {
797
- try {
798
- listBuilderAdd_120(this.#out_93, strCat_129("{", intToString_190(min_188)));
799
- } catch {
800
- break s__1273_187;
801
- }
802
- if (min_188 !== max_189) {
803
- try {
804
- listBuilderAdd_120(this.#out_93, ",");
805
- } catch {
806
- break s__1273_187;
807
- }
808
- if (max_189 !== null) {
809
- t_186 = this.#out_93;
810
- try {
811
- t_185 = requireIsSafeInteger__191(max_189);
812
- listBuilderAdd_120(t_186, intToString_190(t_185));
813
- } catch {
814
- break s__1273_187;
815
- }
816
- } else {
817
- void 0;
818
- }
819
- } else {
820
- void 0;
821
- }
822
- try {
823
- listBuilderAdd_120(this.#out_93, "}");
824
- } catch {
825
- break s__1273_187;
826
- }
561
+ t_166 = code_158 === Codes_172.uint16Max;
827
562
  }
563
+ t_167 = ! t_166;
564
+ } else {
565
+ t_167 = false;
828
566
  }
567
+ t_168 = t_167;
829
568
  }
830
- if (repeat_179.reluctant) {
831
- try {
832
- listBuilderAdd_120(this.#out_93, "?");
833
- } catch {
834
- break s__1273_187;
835
- }
569
+ if (t_168) {
570
+ t_169 = String.fromCodePoint(code_158);
571
+ listBuilderAdd_146(this.#out_122, t_169);
836
572
  } else {
837
- void 0;
573
+ regexFormatterPushCodeTo_176(this, this.#out_122, code_158, insideCodeSet_159);
838
574
  }
839
- return_180 = void 0;
840
- return return_180;
575
+ return_160 = void 0;
841
576
  }
842
- throw Error();
577
+ return return_160;
843
578
  }
844
- /** @param {Sequence} sequence_193 */
845
- pushSequence(sequence_193) {
846
- let return_194;
579
+ /**
580
+ * @param {CodePoints} codePoints_178
581
+ * @param {boolean} insideCodeSet_179
582
+ */
583
+ #pushCodePoints_140(codePoints_178, insideCodeSet_179) {
584
+ let t_180;
585
+ let t_181;
586
+ const value_182 = codePoints_178.value;
587
+ let index_183 = 0;
588
+ while (true) {
589
+ if (!(value_182.length > index_183)) {
590
+ break;
591
+ }
592
+ t_181 = stringGet_184(value_182, index_183);
593
+ this.#pushCode_157(t_181, insideCodeSet_179);
594
+ t_180 = stringNext_185(value_182, index_183);
595
+ index_183 = t_180;
596
+ }
597
+ return;
598
+ }
599
+ /** @param {CodeRange} codeRange_187 */
600
+ #pushCodeRange_141(codeRange_187) {
601
+ listBuilderAdd_146(this.#out_122, "[");
602
+ this.#pushCodeRangeUnwrapped_188(codeRange_187);
603
+ listBuilderAdd_146(this.#out_122, "]");
604
+ return;
605
+ }
606
+ /** @param {CodeRange} codeRange_190 */
607
+ #pushCodeRangeUnwrapped_188(codeRange_190) {
608
+ let t_191 = codeRange_190.min;
609
+ this.#pushCode_157(t_191, true);
610
+ listBuilderAdd_146(this.#out_122, "-");
611
+ let t_192 = codeRange_190.max;
612
+ this.#pushCode_157(t_192, true);
613
+ return;
614
+ }
615
+ /** @param {CodeSet} codeSet_194 */
616
+ #pushCodeSet_142(codeSet_194) {
847
617
  let t_195;
848
618
  let t_196;
849
- let i_197 = 0;
850
- s__1276_198: {
619
+ let t_197;
620
+ const adjusted_198 = regexFormatterAdjustCodeSet_199(this, codeSet_194, regexRefs_111);
621
+ if (adjusted_198 instanceof CodeSet) {
622
+ t_196 = requireInstanceOf__138(adjusted_198, CodeSet);
623
+ listBuilderAdd_146(this.#out_122, "[");
624
+ if (t_196.negated) {
625
+ listBuilderAdd_146(this.#out_122, "^");
626
+ }
627
+ let i_200 = 0;
851
628
  while (true) {
852
- t_195 = sequence_193.items.length;
853
- if (i_197 < t_195) {
854
- try {
855
- t_196 = listedGet_159(sequence_193.items, i_197);
856
- } catch {
857
- break;
858
- }
859
- this.pushRegex(t_196);
860
- i_197 = i_197 + 1;
861
- } else {
862
- return_194 = void 0;
863
- break s__1276_198;
629
+ t_195 = t_196.items.length;
630
+ if (!(i_200 < t_195)) {
631
+ break;
864
632
  }
633
+ t_197 = listedGet_174(t_196.items, i_200);
634
+ this.#pushCodeSetItem_201(t_197);
635
+ i_200 = i_200 + 1;
865
636
  }
866
- throw Error();
637
+ listBuilderAdd_146(this.#out_122, "]");
638
+ } else {
639
+ this.#pushRegex_125(adjusted_198);
867
640
  }
868
- return return_194;
641
+ return;
869
642
  }
870
- /**
871
- * @param {CodePart} codePart_200
872
- * @returns {number | null}
873
- */
874
- maxCode(codePart_200) {
875
- let return_201;
876
- let t_202;
877
- let t_203;
643
+ /** @param {CodePart} codePart_203 */
644
+ #pushCodeSetItem_201(codePart_203) {
878
645
  let t_204;
879
646
  let t_205;
880
647
  let t_206;
881
- let t_207;
882
- let t_208;
648
+ if (codePart_203 instanceof CodePoints) {
649
+ t_204 = requireInstanceOf__138(codePart_203, CodePoints);
650
+ this.#pushCodePoints_140(t_204, true);
651
+ } else if (codePart_203 instanceof CodeRange) {
652
+ t_205 = requireInstanceOf__138(codePart_203, CodeRange);
653
+ this.#pushCodeRangeUnwrapped_188(t_205);
654
+ } else if (codePart_203 instanceof SpecialSet) {
655
+ t_206 = requireInstanceOf__138(codePart_203, SpecialSet);
656
+ this.#pushRegex_125(t_206);
657
+ }
658
+ return;
659
+ }
660
+ /** @param {Or} or_208 */
661
+ #pushOr_143(or_208) {
883
662
  let t_209;
884
663
  let t_210;
885
664
  let t_211;
886
- try {
887
- requireInstanceOf__117(codePart_200, CodePoints);
888
- t_208 = true;
889
- } catch {
890
- t_208 = false;
665
+ if (! ! or_208.items.length) {
666
+ listBuilderAdd_146(this.#out_122, "(?:");
667
+ t_210 = listedGet_174(or_208.items, 0);
668
+ this.#pushRegex_125(t_210);
669
+ let i_212 = 1;
670
+ while (true) {
671
+ t_209 = or_208.items.length;
672
+ if (!(i_212 < t_209)) {
673
+ break;
674
+ }
675
+ listBuilderAdd_146(this.#out_122, "|");
676
+ t_211 = listedGet_174(or_208.items, i_212);
677
+ this.#pushRegex_125(t_211);
678
+ i_212 = i_212 + 1;
679
+ }
680
+ listBuilderAdd_146(this.#out_122, ")");
681
+ }
682
+ return;
683
+ }
684
+ /** @param {Repeat} repeat_214 */
685
+ #pushRepeat_144(repeat_214) {
686
+ let t_215;
687
+ let t_216;
688
+ let t_217;
689
+ let t_218;
690
+ let t_219;
691
+ listBuilderAdd_146(this.#out_122, "(?:");
692
+ let t_220 = repeat_214.item;
693
+ this.#pushRegex_125(t_220);
694
+ listBuilderAdd_146(this.#out_122, ")");
695
+ const min_221 = repeat_214.min;
696
+ let max_222;
697
+ max_222 = repeat_214.max;
698
+ if (min_221 === 0) {
699
+ t_217 = max_222 === 1;
700
+ } else {
701
+ t_217 = false;
891
702
  }
892
- s__1278_212: {
893
- if (t_208) {
894
- try {
895
- t_209 = requireInstanceOf__117(codePart_200, CodePoints);
896
- } catch {
897
- break s__1278_212;
703
+ if (t_217) {
704
+ listBuilderAdd_146(this.#out_122, "?");
705
+ } else {
706
+ if (min_221 === 0) {
707
+ t_218 = max_222 == null;
708
+ } else {
709
+ t_218 = false;
710
+ }
711
+ if (t_218) {
712
+ listBuilderAdd_146(this.#out_122, "*");
713
+ } else {
714
+ if (min_221 === 1) {
715
+ t_219 = max_222 == null;
716
+ } else {
717
+ t_219 = false;
898
718
  }
899
- const value_213 = t_209.value;
900
- if (! value_213) {
901
- return_201 = null;
719
+ if (t_219) {
720
+ listBuilderAdd_146(this.#out_122, "+");
902
721
  } else {
903
- let max_214 = 0;
904
- t_202 = stringCodePoints_140(value_213);
905
- let slice_215 = t_202;
906
- while (true) {
907
- if (! slice_215.isEmpty) {
908
- const next_216 = slice_215.read();
909
- if (next_216 > max_214) {
910
- max_214 = next_216;
911
- } else {
912
- void 0;
913
- }
914
- t_203 = slice_215.advance(1);
915
- slice_215 = t_203;
916
- } else {
917
- break;
722
+ t_215 = min_221.toString();
723
+ listBuilderAdd_146(this.#out_122, "{" + t_215);
724
+ if (min_221 !== max_222) {
725
+ listBuilderAdd_146(this.#out_122, ",");
726
+ if (!(max_222 == null)) {
727
+ t_216 = max_222.toString();
728
+ listBuilderAdd_146(this.#out_122, t_216);
918
729
  }
919
730
  }
920
- return_201 = max_214;
731
+ listBuilderAdd_146(this.#out_122, "}");
921
732
  }
733
+ }
734
+ }
735
+ if (repeat_214.reluctant) {
736
+ listBuilderAdd_146(this.#out_122, "?");
737
+ }
738
+ return;
739
+ }
740
+ /** @param {Sequence} sequence_224 */
741
+ #pushSequence_145(sequence_224) {
742
+ let t_225;
743
+ let t_226;
744
+ let i_227 = 0;
745
+ while (true) {
746
+ t_225 = sequence_224.items.length;
747
+ if (!(i_227 < t_225)) {
748
+ break;
749
+ }
750
+ t_226 = listedGet_174(sequence_224.items, i_227);
751
+ this.#pushRegex_125(t_226);
752
+ i_227 = i_227 + 1;
753
+ }
754
+ return;
755
+ }
756
+ /**
757
+ * @param {CodePart} codePart_229
758
+ * @returns {number | null}
759
+ */
760
+ maxCode(codePart_229) {
761
+ let return_230;
762
+ let t_231;
763
+ let t_232;
764
+ let t_233;
765
+ let t_234;
766
+ let t_235;
767
+ if (codePart_229 instanceof CodePoints) {
768
+ t_233 = requireInstanceOf__138(codePart_229, CodePoints);
769
+ const value_236 = t_233.value;
770
+ if (! value_236) {
771
+ return_230 = null;
922
772
  } else {
923
- try {
924
- requireInstanceOf__117(codePart_200, CodeRange);
925
- t_210 = true;
926
- } catch {
927
- t_210 = false;
928
- }
929
- if (t_210) {
930
- try {
931
- t_211 = requireInstanceOf__117(codePart_200, CodeRange);
932
- t_204 = t_211.max;
933
- return_201 = t_204;
934
- } catch {
935
- break s__1278_212;
936
- }
937
- } else if (eqGeneric_119(codePart_200, Digit)) {
938
- t_205 = stringCodePoints_140("9").read();
939
- try {
940
- return_201 = t_205;
941
- } catch {
942
- break s__1278_212;
943
- }
944
- } else if (eqGeneric_119(codePart_200, Space)) {
945
- t_206 = stringCodePoints_140(" ").read();
946
- try {
947
- return_201 = t_206;
948
- } catch {
949
- break s__1278_212;
773
+ let max_237 = 0;
774
+ let index_238 = 0;
775
+ while (true) {
776
+ if (!(value_236.length > index_238)) {
777
+ break;
950
778
  }
951
- } else if (eqGeneric_119(codePart_200, Word)) {
952
- t_207 = stringCodePoints_140("z").read();
953
- try {
954
- return_201 = t_207;
955
- } catch {
956
- break s__1278_212;
779
+ t_234 = stringGet_184(value_236, index_238);
780
+ const next_239 = t_234;
781
+ if (next_239 > max_237) {
782
+ max_237 = next_239;
957
783
  }
958
- } else {
959
- return_201 = null;
784
+ t_231 = stringNext_185(value_236, index_238);
785
+ index_238 = t_231;
960
786
  }
787
+ return_230 = max_237;
961
788
  }
962
- return return_201;
789
+ } else if (codePart_229 instanceof CodeRange) {
790
+ t_235 = requireInstanceOf__138(codePart_229, CodeRange);
791
+ t_232 = t_235.max;
792
+ return_230 = t_232;
793
+ } else if (Object.is(codePart_229, Digit)) {
794
+ return_230 = Codes_172.digit9;
795
+ } else if (Object.is(codePart_229, Space)) {
796
+ return_230 = Codes_172.space;
797
+ } else if (Object.is(codePart_229, Word)) {
798
+ return_230 = Codes_172.lowerZ;
799
+ } else {
800
+ return_230 = null;
963
801
  }
964
- throw Error();
802
+ return return_230;
965
803
  }
966
- /** @param {Array<string>} out_217 */
967
- constructor(out_217) {
968
- let t_218;
969
- if (!(out_217 !== void 0)) {
970
- t_218 = [];
971
- out_217 = t_218;
972
- }
973
- this.#out_93 = out_217;
804
+ constructor() {
805
+ super ();
806
+ let t_240 = [];
807
+ this.#out_122 = t_240;
974
808
  return;
975
809
  }
976
810
  }
977
- /** @type {RegexRefs_59} */
978
- const regexRefs_85 = new RegexRefs_59();
979
- class Begin_219 {
811
+ class Codes_172 extends type__10() {
812
+ /** @type {number} */
813
+ static #ampersand_241 = 38;
814
+ /** @returns {number} */
815
+ static get ampersand() {
816
+ return this.#ampersand_241;
817
+ }
818
+ /** @type {number} */
819
+ static #backslash_242 = 92;
820
+ /** @returns {number} */
821
+ static get backslash() {
822
+ return this.#backslash_242;
823
+ }
824
+ /** @type {number} */
825
+ static #caret_243 = 94;
826
+ /** @returns {number} */
827
+ static get caret() {
828
+ return this.#caret_243;
829
+ }
830
+ /** @type {number} */
831
+ static #carriageReturn_244 = 13;
832
+ /** @returns {number} */
833
+ static get carriageReturn() {
834
+ return this.#carriageReturn_244;
835
+ }
836
+ /** @type {number} */
837
+ static #curlyLeft_245 = 123;
838
+ /** @returns {number} */
839
+ static get curlyLeft() {
840
+ return this.#curlyLeft_245;
841
+ }
842
+ /** @type {number} */
843
+ static #curlyRight_246 = 125;
844
+ /** @returns {number} */
845
+ static get curlyRight() {
846
+ return this.#curlyRight_246;
847
+ }
848
+ /** @type {number} */
849
+ static #dash_247 = 45;
850
+ /** @returns {number} */
851
+ static get dash() {
852
+ return this.#dash_247;
853
+ }
854
+ /** @type {number} */
855
+ static #dot_248 = 46;
856
+ /** @returns {number} */
857
+ static get dot() {
858
+ return this.#dot_248;
859
+ }
860
+ /** @type {number} */
861
+ static #highControlMin_249 = 127;
862
+ /** @returns {number} */
863
+ static get highControlMin() {
864
+ return this.#highControlMin_249;
865
+ }
866
+ /** @type {number} */
867
+ static #highControlMax_250 = 159;
868
+ /** @returns {number} */
869
+ static get highControlMax() {
870
+ return this.#highControlMax_250;
871
+ }
872
+ /** @type {number} */
873
+ static #digit0_251 = 48;
874
+ /** @returns {number} */
875
+ static get digit0() {
876
+ return this.#digit0_251;
877
+ }
878
+ /** @type {number} */
879
+ static #digit9_252 = 57;
880
+ /** @returns {number} */
881
+ static get digit9() {
882
+ return this.#digit9_252;
883
+ }
884
+ /** @type {number} */
885
+ static #lowerA_253 = 97;
886
+ /** @returns {number} */
887
+ static get lowerA() {
888
+ return this.#lowerA_253;
889
+ }
890
+ /** @type {number} */
891
+ static #lowerZ_254 = 122;
892
+ /** @returns {number} */
893
+ static get lowerZ() {
894
+ return this.#lowerZ_254;
895
+ }
896
+ /** @type {number} */
897
+ static #newline_255 = 10;
898
+ /** @returns {number} */
899
+ static get newline() {
900
+ return this.#newline_255;
901
+ }
902
+ /** @type {number} */
903
+ static #peso_256 = 36;
904
+ /** @returns {number} */
905
+ static get peso() {
906
+ return this.#peso_256;
907
+ }
908
+ /** @type {number} */
909
+ static #pipe_257 = 124;
910
+ /** @returns {number} */
911
+ static get pipe() {
912
+ return this.#pipe_257;
913
+ }
914
+ /** @type {number} */
915
+ static #plus_258 = 43;
916
+ /** @returns {number} */
917
+ static get plus() {
918
+ return this.#plus_258;
919
+ }
920
+ /** @type {number} */
921
+ static #question_259 = 63;
922
+ /** @returns {number} */
923
+ static get question() {
924
+ return this.#question_259;
925
+ }
926
+ /** @type {number} */
927
+ static #roundLeft_260 = 40;
928
+ /** @returns {number} */
929
+ static get roundLeft() {
930
+ return this.#roundLeft_260;
931
+ }
932
+ /** @type {number} */
933
+ static #roundRight_261 = 41;
934
+ /** @returns {number} */
935
+ static get roundRight() {
936
+ return this.#roundRight_261;
937
+ }
938
+ /** @type {number} */
939
+ static #slash_262 = 47;
940
+ /** @returns {number} */
941
+ static get slash() {
942
+ return this.#slash_262;
943
+ }
944
+ /** @type {number} */
945
+ static #squareLeft_263 = 91;
946
+ /** @returns {number} */
947
+ static get squareLeft() {
948
+ return this.#squareLeft_263;
949
+ }
950
+ /** @type {number} */
951
+ static #squareRight_264 = 93;
952
+ /** @returns {number} */
953
+ static get squareRight() {
954
+ return this.#squareRight_264;
955
+ }
956
+ /** @type {number} */
957
+ static #star_265 = 42;
958
+ /** @returns {number} */
959
+ static get star() {
960
+ return this.#star_265;
961
+ }
962
+ /** @type {number} */
963
+ static #tab_266 = 9;
964
+ /** @returns {number} */
965
+ static get tab() {
966
+ return this.#tab_266;
967
+ }
968
+ /** @type {number} */
969
+ static #tilde_267 = 42;
970
+ /** @returns {number} */
971
+ static get tilde() {
972
+ return this.#tilde_267;
973
+ }
974
+ /** @type {number} */
975
+ static #upperA_268 = 65;
976
+ /** @returns {number} */
977
+ static get upperA() {
978
+ return this.#upperA_268;
979
+ }
980
+ /** @type {number} */
981
+ static #upperZ_269 = 90;
982
+ /** @returns {number} */
983
+ static get upperZ() {
984
+ return this.#upperZ_269;
985
+ }
986
+ /** @type {number} */
987
+ static #space_270 = 32;
988
+ /** @returns {number} */
989
+ static get space() {
990
+ return this.#space_270;
991
+ }
992
+ /** @type {number} */
993
+ static #surrogateMin_271 = 55296;
994
+ /** @returns {number} */
995
+ static get surrogateMin() {
996
+ return this.#surrogateMin_271;
997
+ }
998
+ /** @type {number} */
999
+ static #surrogateMax_272 = 57343;
1000
+ /** @returns {number} */
1001
+ static get surrogateMax() {
1002
+ return this.#surrogateMax_272;
1003
+ }
1004
+ /** @type {number} */
1005
+ static #supplementalMin_273 = 65536;
1006
+ /** @returns {number} */
1007
+ static get supplementalMin() {
1008
+ return this.#supplementalMin_273;
1009
+ }
1010
+ /** @type {number} */
1011
+ static #uint16Max_274 = 65535;
1012
+ /** @returns {number} */
1013
+ static get uint16Max() {
1014
+ return this.#uint16Max_274;
1015
+ }
1016
+ /** @type {number} */
1017
+ static #underscore_275 = 95;
1018
+ /** @returns {number} */
1019
+ static get underscore() {
1020
+ return this.#underscore_275;
1021
+ }
980
1022
  constructor() {
1023
+ super ();
1024
+ return;
1025
+ }
1026
+ }
1027
+ /** @type {RegexRefs_72} */
1028
+ const regexRefs_111 = new RegexRefs_72();
1029
+ class Begin_276 extends type__10(Special) {
1030
+ constructor() {
1031
+ super ();
981
1032
  return;
982
1033
  }
983
1034
  }
984
- Special.implementedBy(Begin_219);
985
1035
  /** @type {Special} */
986
- export const Begin = new Begin_219();
987
- class Dot_220 {
1036
+ export const Begin = new Begin_276();
1037
+ class Dot_277 extends type__10(Special) {
988
1038
  constructor() {
1039
+ super ();
989
1040
  return;
990
1041
  }
991
1042
  }
992
- Special.implementedBy(Dot_220);
993
1043
  /** @type {Special} */
994
- export const Dot = new Dot_220();
995
- class End_221 {
1044
+ export const Dot = new Dot_277();
1045
+ class End_278 extends type__10(Special) {
996
1046
  constructor() {
1047
+ super ();
997
1048
  return;
998
1049
  }
999
1050
  }
1000
- Special.implementedBy(End_221);
1001
1051
  /** @type {Special} */
1002
- export const End = new End_221();
1003
- class WordBoundary_222 {
1052
+ export const End = new End_278();
1053
+ class WordBoundary_279 extends type__10(Special) {
1004
1054
  constructor() {
1055
+ super ();
1005
1056
  return;
1006
1057
  }
1007
1058
  }
1008
- Special.implementedBy(WordBoundary_222);
1009
1059
  /** @type {Special} */
1010
- export const WordBoundary = new WordBoundary_222();
1011
- class Digit_223 {
1060
+ export const WordBoundary = new WordBoundary_279();
1061
+ class Digit_280 extends type__10(SpecialSet) {
1012
1062
  constructor() {
1063
+ super ();
1013
1064
  return;
1014
1065
  }
1015
1066
  }
1016
- SpecialSet.implementedBy(Digit_223);
1017
1067
  /** @type {SpecialSet} */
1018
- export const Digit = new Digit_223();
1019
- class Space_224 {
1068
+ export const Digit = new Digit_280();
1069
+ class Space_281 extends type__10(SpecialSet) {
1020
1070
  constructor() {
1071
+ super ();
1021
1072
  return;
1022
1073
  }
1023
1074
  }
1024
- SpecialSet.implementedBy(Space_224);
1025
1075
  /** @type {SpecialSet} */
1026
- export const Space = new Space_224();
1027
- class Word_225 {
1076
+ export const Space = new Space_281();
1077
+ class Word_282 extends type__10(SpecialSet) {
1028
1078
  constructor() {
1079
+ super ();
1029
1080
  return;
1030
1081
  }
1031
1082
  }
1032
- SpecialSet.implementedBy(Word_225);
1033
1083
  /** @type {SpecialSet} */
1034
- export const Word = new Word_225();
1084
+ export const Word = new Word_282();
1085
+ /** @returns {Array<number>} */
1086
+ function buildEscapeNeeds_283() {
1087
+ let t_284;
1088
+ let t_285;
1089
+ let t_286;
1090
+ let t_287;
1091
+ let t_288;
1092
+ let t_289;
1093
+ let t_290;
1094
+ let t_291;
1095
+ let t_292;
1096
+ let t_293;
1097
+ let t_294;
1098
+ let t_295;
1099
+ let t_296;
1100
+ let t_297;
1101
+ let t_298;
1102
+ let t_299;
1103
+ let t_300;
1104
+ let t_301;
1105
+ let t_302;
1106
+ let t_303;
1107
+ let t_304;
1108
+ let t_305;
1109
+ let t_306;
1110
+ let t_307;
1111
+ let t_308;
1112
+ const escapeNeeds_309 = [];
1113
+ let code_310 = 0;
1114
+ while (code_310 < 127) {
1115
+ if (code_310 === Codes_172.dash) {
1116
+ t_291 = true;
1117
+ } else {
1118
+ if (code_310 === Codes_172.space) {
1119
+ t_290 = true;
1120
+ } else {
1121
+ if (code_310 === Codes_172.underscore) {
1122
+ t_289 = true;
1123
+ } else {
1124
+ if (Codes_172.digit0 <= code_310) {
1125
+ t_284 = code_310 <= Codes_172.digit9;
1126
+ } else {
1127
+ t_284 = false;
1128
+ }
1129
+ if (t_284) {
1130
+ t_288 = true;
1131
+ } else {
1132
+ if (Codes_172.upperA <= code_310) {
1133
+ t_285 = code_310 <= Codes_172.upperZ;
1134
+ } else {
1135
+ t_285 = false;
1136
+ }
1137
+ if (t_285) {
1138
+ t_287 = true;
1139
+ } else {
1140
+ if (Codes_172.lowerA <= code_310) {
1141
+ t_286 = code_310 <= Codes_172.lowerZ;
1142
+ } else {
1143
+ t_286 = false;
1144
+ }
1145
+ t_287 = t_286;
1146
+ }
1147
+ t_288 = t_287;
1148
+ }
1149
+ t_289 = t_288;
1150
+ }
1151
+ t_290 = t_289;
1152
+ }
1153
+ t_291 = t_290;
1154
+ }
1155
+ if (t_291) {
1156
+ t_308 = 0;
1157
+ } else {
1158
+ if (code_310 === Codes_172.ampersand) {
1159
+ t_307 = true;
1160
+ } else {
1161
+ if (code_310 === Codes_172.backslash) {
1162
+ t_306 = true;
1163
+ } else {
1164
+ if (code_310 === Codes_172.caret) {
1165
+ t_305 = true;
1166
+ } else {
1167
+ if (code_310 === Codes_172.curlyLeft) {
1168
+ t_304 = true;
1169
+ } else {
1170
+ if (code_310 === Codes_172.curlyRight) {
1171
+ t_303 = true;
1172
+ } else {
1173
+ if (code_310 === Codes_172.dot) {
1174
+ t_302 = true;
1175
+ } else {
1176
+ if (code_310 === Codes_172.peso) {
1177
+ t_301 = true;
1178
+ } else {
1179
+ if (code_310 === Codes_172.pipe) {
1180
+ t_300 = true;
1181
+ } else {
1182
+ if (code_310 === Codes_172.plus) {
1183
+ t_299 = true;
1184
+ } else {
1185
+ if (code_310 === Codes_172.question) {
1186
+ t_298 = true;
1187
+ } else {
1188
+ if (code_310 === Codes_172.roundLeft) {
1189
+ t_297 = true;
1190
+ } else {
1191
+ if (code_310 === Codes_172.roundRight) {
1192
+ t_296 = true;
1193
+ } else {
1194
+ if (code_310 === Codes_172.slash) {
1195
+ t_295 = true;
1196
+ } else {
1197
+ if (code_310 === Codes_172.squareLeft) {
1198
+ t_294 = true;
1199
+ } else {
1200
+ if (code_310 === Codes_172.squareRight) {
1201
+ t_293 = true;
1202
+ } else {
1203
+ if (code_310 === Codes_172.star) {
1204
+ t_292 = true;
1205
+ } else {
1206
+ t_292 = code_310 === Codes_172.tilde;
1207
+ }
1208
+ t_293 = t_292;
1209
+ }
1210
+ t_294 = t_293;
1211
+ }
1212
+ t_295 = t_294;
1213
+ }
1214
+ t_296 = t_295;
1215
+ }
1216
+ t_297 = t_296;
1217
+ }
1218
+ t_298 = t_297;
1219
+ }
1220
+ t_299 = t_298;
1221
+ }
1222
+ t_300 = t_299;
1223
+ }
1224
+ t_301 = t_300;
1225
+ }
1226
+ t_302 = t_301;
1227
+ }
1228
+ t_303 = t_302;
1229
+ }
1230
+ t_304 = t_303;
1231
+ }
1232
+ t_305 = t_304;
1233
+ }
1234
+ t_306 = t_305;
1235
+ }
1236
+ t_307 = t_306;
1237
+ }
1238
+ if (t_307) {
1239
+ t_308 = 2;
1240
+ } else {
1241
+ t_308 = 1;
1242
+ }
1243
+ }
1244
+ listBuilderAdd_146(escapeNeeds_309, t_308);
1245
+ code_310 = code_310 + 1;
1246
+ }
1247
+ return listBuilderToList_311(escapeNeeds_309);
1248
+ }
1249
+ /** @type {Array<number>} */
1250
+ const escapeNeeds_175 = buildEscapeNeeds_283();
1035
1251
  /**
1036
- * @param {RegexNode} item_226
1252
+ * @param {RegexNode} item_312
1037
1253
  * @returns {RegexNode}
1038
1254
  */
1039
- export function entire(item_226) {
1040
- return new Sequence(listify_69(Begin, item_226, End));
1255
+ export function entire(item_312) {
1256
+ return new Sequence(Object.freeze([Begin, item_312, End]));
1041
1257
  };
1042
1258
  /**
1043
- * @param {RegexNode} item_227
1044
- * @param {boolean} reluctant_228
1259
+ * @param {RegexNode} item_313
1260
+ * @param {boolean | null} [reluctant_314]
1045
1261
  * @returns {Repeat}
1046
1262
  */
1047
- export function oneOrMore(item_227, reluctant_228) {
1048
- if (!(reluctant_228 !== void 0)) {
1049
- reluctant_228 = false;
1263
+ export function oneOrMore(item_313, reluctant_314) {
1264
+ let reluctant_315;
1265
+ if (reluctant_314 == null) {
1266
+ reluctant_315 = false;
1267
+ } else {
1268
+ reluctant_315 = reluctant_314;
1050
1269
  }
1051
- return new Repeat(item_227, 1, null, reluctant_228);
1270
+ return new Repeat(item_313, 1, null, reluctant_315);
1052
1271
  };
1053
1272
  /**
1054
- * @param {RegexNode} item_229
1055
- * @param {boolean} reluctant_230
1273
+ * @param {RegexNode} item_316
1274
+ * @param {boolean | null} [reluctant_317]
1056
1275
  * @returns {Repeat}
1057
1276
  */
1058
- export function optional(item_229, reluctant_230) {
1059
- if (!(reluctant_230 !== void 0)) {
1060
- reluctant_230 = false;
1277
+ export function optional(item_316, reluctant_317) {
1278
+ let reluctant_318;
1279
+ if (reluctant_317 == null) {
1280
+ reluctant_318 = false;
1281
+ } else {
1282
+ reluctant_318 = reluctant_317;
1061
1283
  }
1062
- return new Repeat(item_229, 0, 1, reluctant_230);
1284
+ return new Repeat(item_316, 0, 1, reluctant_318);
1063
1285
  };