@temperlang/std 0.2.1 → 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,631 +1,498 @@
1
1
  import {
2
- InterfaceType as InterfaceType_0, requireInstanceOf as requireInstanceOf__115, requireIsSafeInteger as requireIsSafeInteger__189, listify as listify_67, compiledRegexCompileFormatted as compiledRegexCompileFormatted_75, compiledRegexCompiledFound as compiledRegexCompiledFound_79, compiledRegexCompiledFind as compiledRegexCompiledFind_82, compiledRegexCompiledReplace as compiledRegexCompiledReplace_87, listJoin as listJoin_97, eqGeneric as eqGeneric_117, listBuilderAdd as listBuilderAdd_118, strCat as strCat_127, regexFormatterPushCodeTo as regexFormatterPushCodeTo_131, stringCodePoints as stringCodePoints_138, regexFormatterAdjustCodeSet as regexFormatterAdjustCodeSet_153, listGet as listGet_157, intToString as intToString_188
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 CompiledRegex(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: () => CompiledRegex, 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
- * Regex
21
- */
22
- export const Regex = new InterfaceType_0("Regex", [["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;
26
- /** @type {Regex} */
27
- #item_10;
41
+ #name_11;
42
+ /** @type {RegexNode} */
43
+ #item_12;
28
44
  /**
29
- * @param {string} name_11
30
- * @param {Regex} 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
- /** @returns {Regex} */
58
+ /** @returns {RegexNode} */
42
59
  get item() {
43
- return this.#item_10;
60
+ return this.#item_12;
44
61
  }
45
62
  };
46
- Regex.implementedBy(Capture);
47
- /**
48
- * @typedef {{}}
49
- * CodePart
50
- */
51
- export const CodePart = new InterfaceType_0("CodePart", [], [Regex], 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", [], [Regex], 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
- export class CodeSet {
107
+ /** @template ITEM_27 */
108
+ export class ItemizedRegex extends type__10(RegexNode) {
109
+ };
110
+ export class CodeSet extends type__10(ItemizedRegex) {
101
111
  /** @type {Array<CodePart>} */
102
- #items_24;
112
+ #items_28;
103
113
  /** @type {boolean} */
104
- #negated_25;
114
+ #negated_29;
105
115
  /**
106
- * @param {Array<CodePart>} items_26
107
- * @param {boolean} negated_27
116
+ * @param {Array<CodePart>} items_30
117
+ * @param {boolean | null} [negated_31]
108
118
  */
109
- constructor(items_26, negated_27) {
110
- if (!(negated_27 !== void 0)) {
111
- negated_27 = 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;
112
126
  }
113
- this.#items_24 = items_26;
114
- this.#negated_25 = negated_27;
127
+ this.#items_28 = items_30;
128
+ this.#negated_29 = negated_32;
115
129
  return;
116
130
  }
117
131
  /** @returns {Array<CodePart>} */
118
132
  get items() {
119
- return this.#items_24;
133
+ return this.#items_28;
120
134
  }
121
135
  /** @returns {boolean} */
122
136
  get negated() {
123
- return this.#negated_25;
137
+ return this.#negated_29;
124
138
  }
125
139
  };
126
- Regex.implementedBy(CodeSet);
127
- export class Or {
128
- /** @type {Array<Regex>} */
129
- #items_30;
130
- /** @param {Array<Regex>} items_31 */
131
- constructor(items_31) {
132
- this.#items_30 = items_31;
140
+ export class Or extends type__10(ItemizedRegex) {
141
+ /** @type {Array<RegexNode>} */
142
+ #items_35;
143
+ /** @param {Array<RegexNode>} items_36 */
144
+ constructor(items_36) {
145
+ super ();
146
+ this.#items_35 = items_36;
133
147
  return;
134
148
  }
135
- /** @returns {Array<Regex>} */
149
+ /** @returns {Array<RegexNode>} */
136
150
  get items() {
137
- return this.#items_30;
151
+ return this.#items_35;
138
152
  }
139
153
  };
140
- Regex.implementedBy(Or);
141
- export class Repeat {
142
- /** @type {Regex} */
143
- #item_33;
154
+ export class Repeat extends type__10(RegexNode) {
155
+ /** @type {RegexNode} */
156
+ #item_38;
144
157
  /** @type {number} */
145
- #min_34;
158
+ #min_39;
146
159
  /** @type {number | null} */
147
- #max_35;
160
+ #max_40;
148
161
  /** @type {boolean} */
149
- #reluctant_36;
162
+ #reluctant_41;
150
163
  /**
151
- * @param {Regex} item_37
152
- * @param {number} min_38
153
- * @param {number | null} max_39
154
- * @param {boolean} reluctant_40
164
+ * @param {RegexNode} item_42
165
+ * @param {number} min_43
166
+ * @param {number | null} max_44
167
+ * @param {boolean | null} [reluctant_45]
155
168
  */
156
- constructor(item_37, min_38, max_39, reluctant_40) {
157
- if (!(reluctant_40 !== void 0)) {
158
- reluctant_40 = 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;
159
176
  }
160
- this.#item_33 = item_37;
161
- this.#min_34 = min_38;
162
- this.#max_35 = max_39;
163
- this.#reluctant_36 = reluctant_40;
177
+ this.#item_38 = item_42;
178
+ this.#min_39 = min_43;
179
+ this.#max_40 = max_44;
180
+ this.#reluctant_41 = reluctant_46;
164
181
  return;
165
182
  }
166
- /** @returns {Regex} */
183
+ /** @returns {RegexNode} */
167
184
  get item() {
168
- return this.#item_33;
185
+ return this.#item_38;
169
186
  }
170
187
  /** @returns {number} */
171
188
  get min() {
172
- return this.#min_34;
189
+ return this.#min_39;
173
190
  }
174
191
  /** @returns {number | null} */
175
192
  get max() {
176
- return this.#max_35;
193
+ return this.#max_40;
177
194
  }
178
195
  /** @returns {boolean} */
179
196
  get reluctant() {
180
- return this.#reluctant_36;
197
+ return this.#reluctant_41;
181
198
  }
182
199
  };
183
- Regex.implementedBy(Repeat);
184
- export class Sequence {
185
- /** @type {Array<Regex>} */
186
- #items_45;
187
- /** @param {Array<Regex>} items_46 */
188
- constructor(items_46) {
189
- this.#items_45 = items_46;
200
+ export class Sequence extends type__10(ItemizedRegex) {
201
+ /** @type {Array<RegexNode>} */
202
+ #items_51;
203
+ /** @param {Array<RegexNode>} items_52 */
204
+ constructor(items_52) {
205
+ super ();
206
+ this.#items_51 = items_52;
190
207
  return;
191
208
  }
192
- /** @returns {Array<Regex>} */
209
+ /** @returns {Array<RegexNode>} */
193
210
  get items() {
194
- return this.#items_45;
211
+ return this.#items_51;
195
212
  }
196
213
  };
197
- Regex.implementedBy(Sequence);
198
- 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() {
199
239
  /** @type {string} */
200
- #name_48;
240
+ #name_60;
201
241
  /** @type {string} */
202
- #value_49;
203
- /** @type {number} */
204
- #codePointsBegin_50;
242
+ #value_61;
243
+ /** @type {globalThis.number} */
244
+ #begin_62;
245
+ /** @type {globalThis.number} */
246
+ #end_63;
205
247
  /**
206
- * @param {string} name_51
207
- * @param {string} value_52
208
- * @param {number} codePointsBegin_53
248
+ * @param {string} name_64
249
+ * @param {string} value_65
250
+ * @param {globalThis.number} begin_66
251
+ * @param {globalThis.number} end_67
209
252
  */
210
- constructor(name_51, value_52, codePointsBegin_53) {
211
- this.#name_48 = name_51;
212
- this.#value_49 = value_52;
213
- this.#codePointsBegin_50 = codePointsBegin_53;
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;
214
259
  return;
215
260
  }
216
261
  /** @returns {string} */
217
262
  get name() {
218
- return this.#name_48;
263
+ return this.#name_60;
219
264
  }
220
265
  /** @returns {string} */
221
266
  get value() {
222
- return this.#value_49;
267
+ return this.#value_61;
223
268
  }
224
- /** @returns {number} */
225
- get codePointsBegin() {
226
- return this.#codePointsBegin_50;
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;
227
276
  }
228
277
  };
229
- class RegexRefs_57 {
278
+ class RegexRefs_72 extends type__10() {
230
279
  /** @type {CodePoints} */
231
- #codePoints_58;
280
+ #codePoints_73;
232
281
  /** @type {Group} */
233
- #group_59;
282
+ #group_74;
283
+ /** @type {Match} */
284
+ #match_75;
234
285
  /** @type {Or} */
235
- #orObject_60;
286
+ #orObject_76;
236
287
  /**
237
- * @param {CodePoints} codePoints_61
238
- * @param {Group} group_62
239
- * @param {Or} orObject_63
288
+ * @param {CodePoints | null} [codePoints_77]
289
+ * @param {Group | null} [group_78]
290
+ * @param {Match | null} [match_79]
291
+ * @param {Or | null} [orObject_80]
240
292
  */
241
- constructor(codePoints_61, group_62, orObject_63) {
242
- let t_64;
243
- let t_65;
244
- let t_66;
245
- if (!(codePoints_61 !== void 0)) {
246
- t_64 = new CodePoints("");
247
- codePoints_61 = t_64;
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;
248
306
  }
249
- if (!(group_62 !== void 0)) {
250
- t_65 = new Group("", "", 0);
251
- group_62 = t_65;
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;
252
313
  }
253
- if (!(orObject_63 !== void 0)) {
254
- t_66 = new Or(listify_67());
255
- orObject_63 = t_66;
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;
256
321
  }
257
- this.#codePoints_58 = codePoints_61;
258
- this.#group_59 = group_62;
259
- this.#orObject_60 = orObject_63;
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;
328
+ }
329
+ this.#codePoints_73 = codePoints_86;
330
+ this.#group_74 = group_87;
331
+ this.#match_75 = match_88;
332
+ this.#orObject_76 = orObject_91;
260
333
  return;
261
334
  }
262
335
  /** @returns {CodePoints} */
263
336
  get codePoints() {
264
- return this.#codePoints_58;
337
+ return this.#codePoints_73;
265
338
  }
266
339
  /** @returns {Group} */
267
340
  get group() {
268
- return this.#group_59;
341
+ return this.#group_74;
342
+ }
343
+ /** @returns {Match} */
344
+ get match() {
345
+ return this.#match_75;
269
346
  }
270
347
  /** @returns {Or} */
271
348
  get orObject() {
272
- return this.#orObject_60;
349
+ return this.#orObject_76;
273
350
  }
274
351
  }
275
- export class CompiledRegex {
276
- /** @type {Regex} */
277
- #data_71;
278
- /** @param {Regex} data_72 */
279
- constructor(data_72) {
280
- this.#data_71 = data_72;
281
- let t_73 = this.format();
282
- let t_74 = compiledRegexCompileFormatted_75(this, t_73);
283
- this.#compiled_76 = t_74;
352
+ export class Regex extends type__10() {
353
+ /** @type {RegexNode} */
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;
284
362
  return;
285
363
  }
286
364
  /**
287
- * @param {string} text_78
365
+ * @param {string} text_104
288
366
  * @returns {boolean}
289
367
  */
290
- found(text_78) {
291
- return compiledRegexCompiledFound_79(this, this.#compiled_76, text_78);
368
+ found(text_104) {
369
+ return regexCompiledFound_105(this, this.#compiled_102, text_104);
292
370
  }
293
371
  /**
294
- * @param {string} text_81
295
- * @returns {Map<string, Group>}
372
+ * @param {string} text_107
373
+ * @param {globalThis.number | null} [begin_108]
374
+ * @returns {Match}
296
375
  */
297
- find(text_81) {
298
- return compiledRegexCompiledFind_82(this, this.#compiled_76, text_81, regexRefs_83);
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);
299
384
  }
300
385
  /**
301
- * @param {string} text_85
302
- * @param {(arg0: Map<string, Group>) => string} format_86
386
+ * @param {string} text_113
387
+ * @param {(arg0: Match) => string} format_114
303
388
  * @returns {string}
304
389
  */
305
- replace(text_85, format_86) {
306
- return compiledRegexCompiledReplace_87(this, this.#compiled_76, text_85, format_86, regexRefs_83);
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);
307
399
  }
308
400
  /** @type {unknown} */
309
- #compiled_76;
401
+ #compiled_102;
310
402
  /** @returns {string} */
311
- format() {
312
- return new RegexFormatter_89().format(this.#data_71);
403
+ #format_99() {
404
+ return new RegexFormatter_120().format(this.#data_96);
313
405
  }
314
- /** @returns {Regex} */
406
+ /** @returns {RegexNode} */
315
407
  get data() {
316
- return this.#data_71;
408
+ return this.#data_96;
317
409
  }
318
410
  };
319
- class RegexFormatter_89 {
411
+ class RegexFormatter_120 extends type__10() {
320
412
  /** @type {Array<string>} */
321
- #out_91;
413
+ #out_122;
322
414
  /**
323
- * @param {Regex} regex_93
415
+ * @param {RegexNode} regex_124
324
416
  * @returns {string}
325
417
  */
326
- format(regex_93) {
327
- this.pushRegex(regex_93);
328
- let t_94 = this.#out_91;
329
- function fn_95(x_96) {
330
- return x_96;
331
- }
332
- return listJoin_97(t_94, "", fn_95);
333
- }
334
- /** @param {Regex} regex_99 */
335
- pushRegex(regex_99) {
336
- let return_100;
337
- let t_101;
338
- let t_102;
339
- let t_103;
340
- let t_104;
341
- let t_105;
342
- let t_106;
343
- let t_107;
344
- let t_108;
345
- let t_109;
346
- let t_110;
347
- let t_111;
348
- let t_112;
349
- let t_113;
350
- let t_114;
351
- try {
352
- requireInstanceOf__115(regex_99, Capture);
353
- t_101 = true;
354
- } catch {
355
- t_101 = false;
418
+ format(regex_124) {
419
+ this.#pushRegex_125(regex_124);
420
+ function fn_126(x_127) {
421
+ return x_127;
356
422
  }
357
- s__1245_116: {
358
- if (t_101) {
359
- try {
360
- t_102 = requireInstanceOf__115(regex_99, Capture);
361
- } catch {
362
- break s__1245_116;
363
- }
364
- this.pushCapture(t_102);
365
- } else {
366
- try {
367
- requireInstanceOf__115(regex_99, CodePoints);
368
- t_103 = true;
369
- } catch {
370
- t_103 = false;
371
- }
372
- if (t_103) {
373
- try {
374
- t_104 = requireInstanceOf__115(regex_99, CodePoints);
375
- } catch {
376
- break s__1245_116;
377
- }
378
- this.pushCodePoints(t_104, false);
379
- } else {
380
- try {
381
- requireInstanceOf__115(regex_99, CodeRange);
382
- t_105 = true;
383
- } catch {
384
- t_105 = false;
385
- }
386
- if (t_105) {
387
- try {
388
- t_106 = requireInstanceOf__115(regex_99, CodeRange);
389
- } catch {
390
- break s__1245_116;
391
- }
392
- this.pushCodeRange(t_106);
393
- } else {
394
- try {
395
- requireInstanceOf__115(regex_99, CodeSet);
396
- t_107 = true;
397
- } catch {
398
- t_107 = false;
399
- }
400
- if (t_107) {
401
- try {
402
- t_108 = requireInstanceOf__115(regex_99, CodeSet);
403
- } catch {
404
- break s__1245_116;
405
- }
406
- this.pushCodeSet(t_108);
407
- } else {
408
- try {
409
- requireInstanceOf__115(regex_99, Or);
410
- t_109 = true;
411
- } catch {
412
- t_109 = false;
413
- }
414
- if (t_109) {
415
- try {
416
- t_110 = requireInstanceOf__115(regex_99, Or);
417
- } catch {
418
- break s__1245_116;
419
- }
420
- this.pushOr(t_110);
421
- } else {
422
- try {
423
- requireInstanceOf__115(regex_99, Repeat);
424
- t_111 = true;
425
- } catch {
426
- t_111 = false;
427
- }
428
- if (t_111) {
429
- try {
430
- t_112 = requireInstanceOf__115(regex_99, Repeat);
431
- } catch {
432
- break s__1245_116;
433
- }
434
- this.pushRepeat(t_112);
435
- } else {
436
- try {
437
- requireInstanceOf__115(regex_99, Sequence);
438
- t_113 = true;
439
- } catch {
440
- t_113 = false;
441
- }
442
- if (t_113) {
443
- try {
444
- t_114 = requireInstanceOf__115(regex_99, Sequence);
445
- } catch {
446
- break s__1245_116;
447
- }
448
- this.pushSequence(t_114);
449
- } else if (eqGeneric_117(regex_99, Begin)) {
450
- try {
451
- listBuilderAdd_118(this.#out_91, "^");
452
- } catch {
453
- break s__1245_116;
454
- }
455
- } else if (eqGeneric_117(regex_99, Dot)) {
456
- try {
457
- listBuilderAdd_118(this.#out_91, ".");
458
- } catch {
459
- break s__1245_116;
460
- }
461
- } else if (eqGeneric_117(regex_99, End)) {
462
- try {
463
- listBuilderAdd_118(this.#out_91, "\u0024");
464
- } catch {
465
- break s__1245_116;
466
- }
467
- } else if (eqGeneric_117(regex_99, WordBoundary)) {
468
- try {
469
- listBuilderAdd_118(this.#out_91, "\\b");
470
- } catch {
471
- break s__1245_116;
472
- }
473
- } else if (eqGeneric_117(regex_99, Digit)) {
474
- try {
475
- listBuilderAdd_118(this.#out_91, "\\d");
476
- } catch {
477
- break s__1245_116;
478
- }
479
- } else if (eqGeneric_117(regex_99, Space)) {
480
- try {
481
- listBuilderAdd_118(this.#out_91, "\\s");
482
- } catch {
483
- break s__1245_116;
484
- }
485
- } else if (eqGeneric_117(regex_99, Word)) {
486
- try {
487
- listBuilderAdd_118(this.#out_91, "\\w");
488
- } catch {
489
- break s__1245_116;
490
- }
491
- } else {
492
- void 0;
493
- }
494
- }
495
- }
496
- }
497
- }
498
- }
499
- }
500
- return_100 = void 0;
501
- return return_100;
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");
502
469
  }
503
- throw Error();
504
- }
505
- /** @param {Capture} capture_120 */
506
- pushCapture(capture_120) {
507
- listBuilderAdd_118(this.#out_91, "(");
508
- let t_121 = this.#out_91;
509
- let t_122 = capture_120.name;
510
- this.pushCaptureName(t_121, t_122);
511
- let t_123 = capture_120.item;
512
- this.pushRegex(t_123);
513
- listBuilderAdd_118(this.#out_91, ")");
514
470
  return;
515
471
  }
516
- /**
517
- * @param {Array<string>} out_125
518
- * @param {string} name_126
519
- */
520
- pushCaptureName(out_125, name_126) {
521
- listBuilderAdd_118(out_125, strCat_127("?\u003c", name_126, "\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, ")");
522
481
  return;
523
482
  }
524
483
  /**
525
- * @param {number} code_129
526
- * @param {boolean} insideCodeSet_130
484
+ * @param {Array<string>} out_154
485
+ * @param {string} name_155
527
486
  */
528
- pushCode(code_129, insideCodeSet_130) {
529
- regexFormatterPushCodeTo_131(this, this.#out_91, code_129, insideCodeSet_130);
487
+ #pushCaptureName_151(out_154, name_155) {
488
+ listBuilderAdd_146(out_154, "?\u003c" + name_155 + "\u003e");
530
489
  return;
531
490
  }
532
491
  /**
533
- * @param {CodePoints} codePoints_133
534
- * @param {boolean} insideCodeSet_134
492
+ * @param {number} code_158
493
+ * @param {boolean} insideCodeSet_159
535
494
  */
536
- pushCodePoints(codePoints_133, insideCodeSet_134) {
537
- let t_135;
538
- let t_136;
539
- let t_137 = stringCodePoints_138(codePoints_133.value);
540
- let slice_139 = t_137;
541
- while (true) {
542
- if (! slice_139.isEmpty) {
543
- t_135 = slice_139.read();
544
- this.pushCode(t_135, insideCodeSet_134);
545
- t_136 = slice_139.advance(1);
546
- slice_139 = t_136;
547
- } else {
548
- break;
549
- }
550
- }
551
- return;
552
- }
553
- /** @param {CodeRange} codeRange_141 */
554
- pushCodeRange(codeRange_141) {
555
- listBuilderAdd_118(this.#out_91, "[");
556
- this.pushCodeRangeUnwrapped(codeRange_141);
557
- listBuilderAdd_118(this.#out_91, "]");
558
- return;
559
- }
560
- /** @param {CodeRange} codeRange_143 */
561
- pushCodeRangeUnwrapped(codeRange_143) {
562
- let t_144 = codeRange_143.min;
563
- this.pushCode(t_144, true);
564
- listBuilderAdd_118(this.#out_91, "-");
565
- let t_145 = codeRange_143.max;
566
- this.pushCode(t_145, true);
567
- return;
568
- }
569
- /** @param {CodeSet} codeSet_147 */
570
- pushCodeSet(codeSet_147) {
571
- let t_148;
572
- let t_149;
573
- let t_150;
574
- let t_151;
575
- const adjusted_152 = regexFormatterAdjustCodeSet_153(this, codeSet_147, regexRefs_83);
576
- try {
577
- requireInstanceOf__115(adjusted_152, CodeSet);
578
- t_149 = true;
579
- } catch {
580
- t_149 = false;
581
- }
582
- s__1252_154: {
583
- if (t_149) {
584
- s__1253_155: {
585
- try {
586
- t_150 = requireInstanceOf__115(adjusted_152, CodeSet);
587
- listBuilderAdd_118(this.#out_91, "[");
588
- } catch {
589
- break s__1253_155;
590
- }
591
- if (t_150.negated) {
592
- try {
593
- listBuilderAdd_118(this.#out_91, "^");
594
- } catch {
595
- break s__1253_155;
596
- }
597
- } else {
598
- void 0;
599
- }
600
- let i_156 = 0;
601
- while (true) {
602
- t_148 = t_150.items.length;
603
- if (i_156 < t_148) {
604
- try {
605
- t_151 = listGet_157(t_150.items, i_156);
606
- } catch {
607
- break s__1253_155;
608
- }
609
- this.pushCodeSetItem(t_151);
610
- i_156 = i_156 + 1;
611
- } else {
612
- break;
613
- }
614
- }
615
- try {
616
- listBuilderAdd_118(this.#out_91, "]");
617
- break s__1252_154;
618
- } catch {
619
- }
620
- }
621
- throw Error();
622
- }
623
- this.pushRegex(adjusted_152);
624
- }
625
- return;
626
- }
627
- /** @param {CodePart} codePart_159 */
628
- pushCodeSetItem(codePart_159) {
495
+ #pushCode_157(code_158, insideCodeSet_159) {
629
496
  let return_160;
630
497
  let t_161;
631
498
  let t_162;
@@ -633,420 +500,786 @@ class RegexFormatter_89 {
633
500
  let t_164;
634
501
  let t_165;
635
502
  let t_166;
636
- try {
637
- requireInstanceOf__115(codePart_159, CodePoints);
638
- t_161 = true;
639
- } catch {
640
- t_161 = false;
641
- }
642
- s__1259_167: {
643
- if (t_161) {
644
- try {
645
- t_162 = requireInstanceOf__115(codePart_159, CodePoints);
646
- } catch {
647
- break s__1259_167;
648
- }
649
- this.pushCodePoints(t_162, true);
503
+ let t_167;
504
+ let t_168;
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";
650
514
  } else {
651
- try {
652
- requireInstanceOf__115(codePart_159, CodeRange);
653
- t_163 = true;
654
- } catch {
655
- t_163 = false;
656
- }
657
- if (t_163) {
658
- try {
659
- t_164 = requireInstanceOf__115(codePart_159, CodeRange);
660
- } catch {
661
- break s__1259_167;
662
- }
663
- this.pushCodeRangeUnwrapped(t_164);
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;
664
528
  } else {
665
- try {
666
- requireInstanceOf__115(codePart_159, SpecialSet);
667
- t_165 = true;
668
- } catch {
529
+ if (insideCodeSet_159) {
530
+ t_161 = code_158 === Codes_172.dash;
531
+ } else {
532
+ t_161 = false;
533
+ }
534
+ t_162 = t_161;
535
+ }
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;
547
+ }
548
+ }
549
+ if (code_158 >= Codes_172.supplementalMin) {
550
+ t_168 = true;
551
+ } else {
552
+ if (code_158 > Codes_172.highControlMax) {
553
+ if (Codes_172.surrogateMin <= code_158) {
554
+ t_165 = code_158 <= Codes_172.surrogateMax;
555
+ } else {
669
556
  t_165 = false;
670
557
  }
671
558
  if (t_165) {
672
- try {
673
- t_166 = requireInstanceOf__115(codePart_159, SpecialSet);
674
- } catch {
675
- break s__1259_167;
676
- }
677
- this.pushRegex(t_166);
559
+ t_166 = true;
678
560
  } else {
679
- void 0;
561
+ t_166 = code_158 === Codes_172.uint16Max;
680
562
  }
563
+ t_167 = ! t_166;
564
+ } else {
565
+ t_167 = false;
681
566
  }
567
+ t_168 = t_167;
568
+ }
569
+ if (t_168) {
570
+ t_169 = String.fromCodePoint(code_158);
571
+ listBuilderAdd_146(this.#out_122, t_169);
572
+ } else {
573
+ regexFormatterPushCodeTo_176(this, this.#out_122, code_158, insideCodeSet_159);
682
574
  }
683
575
  return_160 = void 0;
684
- return return_160;
685
576
  }
686
- throw Error();
687
- }
688
- /** @param {Or} or_169 */
689
- pushOr(or_169) {
690
- let t_170;
691
- let t_171;
692
- let t_172;
693
- s__1261_173: if (! ! or_169.items.length) {
694
- s__1262_174: {
695
- try {
696
- listBuilderAdd_118(this.#out_91, "(?:");
697
- t_171 = listGet_157(or_169.items, 0);
698
- } catch {
699
- break s__1262_174;
700
- }
701
- this.pushRegex(t_171);
702
- let i_175 = 1;
703
- while (true) {
704
- t_170 = or_169.items.length;
705
- if (i_175 < t_170) {
706
- try {
707
- listBuilderAdd_118(this.#out_91, "|");
708
- t_172 = listGet_157(or_169.items, i_175);
709
- } catch {
710
- break;
711
- }
712
- this.pushRegex(t_172);
713
- i_175 = i_175 + 1;
714
- } else {
715
- try {
716
- listBuilderAdd_118(this.#out_91, ")");
717
- } catch {
718
- break s__1262_174;
719
- }
720
- break s__1261_173;
721
- }
577
+ return return_160;
578
+ }
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) {
617
+ let t_195;
618
+ let t_196;
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;
628
+ while (true) {
629
+ t_195 = t_196.items.length;
630
+ if (!(i_200 < t_195)) {
631
+ break;
722
632
  }
633
+ t_197 = listedGet_174(t_196.items, i_200);
634
+ this.#pushCodeSetItem_201(t_197);
635
+ i_200 = i_200 + 1;
723
636
  }
724
- throw Error();
637
+ listBuilderAdd_146(this.#out_122, "]");
638
+ } else {
639
+ this.#pushRegex_125(adjusted_198);
725
640
  }
726
641
  return;
727
642
  }
728
- /** @param {Repeat} repeat_177 */
729
- pushRepeat(repeat_177) {
730
- let return_178;
731
- let t_179;
732
- let t_180;
733
- let t_181;
734
- let t_182;
735
- let t_183;
736
- let t_184;
737
- s__1266_185: {
738
- let min_186;
739
- let max_187;
740
- try {
741
- listBuilderAdd_118(this.#out_91, "(?:");
742
- t_179 = repeat_177.item;
743
- this.pushRegex(t_179);
744
- listBuilderAdd_118(this.#out_91, ")");
745
- min_186 = repeat_177.min;
746
- max_187 = repeat_177.max;
747
- } catch {
748
- break s__1266_185;
643
+ /** @param {CodePart} codePart_203 */
644
+ #pushCodeSetItem_201(codePart_203) {
645
+ let t_204;
646
+ let t_205;
647
+ let t_206;
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) {
662
+ let t_209;
663
+ let t_210;
664
+ let t_211;
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;
749
679
  }
750
- if (min_186 === 0) {
751
- t_180 = max_187 === 1;
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;
702
+ }
703
+ if (t_217) {
704
+ listBuilderAdd_146(this.#out_122, "?");
705
+ } else {
706
+ if (min_221 === 0) {
707
+ t_218 = max_222 == null;
752
708
  } else {
753
- t_180 = false;
709
+ t_218 = false;
754
710
  }
755
- if (t_180) {
756
- try {
757
- listBuilderAdd_118(this.#out_91, "?");
758
- } catch {
759
- break s__1266_185;
760
- }
711
+ if (t_218) {
712
+ listBuilderAdd_146(this.#out_122, "*");
761
713
  } else {
762
- if (min_186 === 0) {
763
- t_181 = max_187 === null;
714
+ if (min_221 === 1) {
715
+ t_219 = max_222 == null;
764
716
  } else {
765
- t_181 = false;
717
+ t_219 = false;
766
718
  }
767
- if (t_181) {
768
- try {
769
- listBuilderAdd_118(this.#out_91, "*");
770
- } catch {
771
- break s__1266_185;
772
- }
719
+ if (t_219) {
720
+ listBuilderAdd_146(this.#out_122, "+");
773
721
  } else {
774
- if (min_186 === 1) {
775
- t_182 = max_187 === null;
776
- } else {
777
- t_182 = false;
778
- }
779
- if (t_182) {
780
- try {
781
- listBuilderAdd_118(this.#out_91, "+");
782
- } catch {
783
- break s__1266_185;
784
- }
785
- } else {
786
- try {
787
- listBuilderAdd_118(this.#out_91, strCat_127("{", intToString_188(min_186)));
788
- } catch {
789
- break s__1266_185;
790
- }
791
- if (min_186 !== max_187) {
792
- try {
793
- listBuilderAdd_118(this.#out_91, ",");
794
- } catch {
795
- break s__1266_185;
796
- }
797
- if (max_187 !== null) {
798
- t_184 = this.#out_91;
799
- try {
800
- t_183 = requireIsSafeInteger__189(max_187);
801
- listBuilderAdd_118(t_184, intToString_188(t_183));
802
- } catch {
803
- break s__1266_185;
804
- }
805
- } else {
806
- void 0;
807
- }
808
- } else {
809
- void 0;
810
- }
811
- try {
812
- listBuilderAdd_118(this.#out_91, "}");
813
- } catch {
814
- break s__1266_185;
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);
815
729
  }
816
730
  }
731
+ listBuilderAdd_146(this.#out_122, "}");
817
732
  }
818
733
  }
819
- if (repeat_177.reluctant) {
820
- try {
821
- listBuilderAdd_118(this.#out_91, "?");
822
- } catch {
823
- break s__1266_185;
824
- }
825
- } else {
826
- void 0;
827
- }
828
- return_178 = void 0;
829
- return return_178;
830
734
  }
831
- throw Error();
832
- }
833
- /** @param {Sequence} sequence_191 */
834
- pushSequence(sequence_191) {
835
- let return_192;
836
- let t_193;
837
- let t_194;
838
- let i_195 = 0;
839
- s__1269_196: {
840
- while (true) {
841
- t_193 = sequence_191.items.length;
842
- if (i_195 < t_193) {
843
- try {
844
- t_194 = listGet_157(sequence_191.items, i_195);
845
- } catch {
846
- break;
847
- }
848
- this.pushRegex(t_194);
849
- i_195 = i_195 + 1;
850
- } else {
851
- return_192 = void 0;
852
- break s__1269_196;
853
- }
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;
854
749
  }
855
- throw Error();
750
+ t_226 = listedGet_174(sequence_224.items, i_227);
751
+ this.#pushRegex_125(t_226);
752
+ i_227 = i_227 + 1;
856
753
  }
857
- return return_192;
754
+ return;
858
755
  }
859
756
  /**
860
- * @param {CodePart} codePart_198
757
+ * @param {CodePart} codePart_229
861
758
  * @returns {number | null}
862
759
  */
863
- maxCode(codePart_198) {
864
- let return_199;
865
- let t_200;
866
- let t_201;
867
- let t_202;
868
- let t_203;
869
- let t_204;
870
- let t_205;
871
- let t_206;
872
- let t_207;
873
- let t_208;
874
- let t_209;
875
- try {
876
- requireInstanceOf__115(codePart_198, CodePoints);
877
- t_206 = true;
878
- } catch {
879
- t_206 = false;
880
- }
881
- s__1271_210: {
882
- if (t_206) {
883
- try {
884
- t_207 = requireInstanceOf__115(codePart_198, CodePoints);
885
- } catch {
886
- break s__1271_210;
887
- }
888
- const value_211 = t_207.value;
889
- if (! value_211) {
890
- return_199 = null;
891
- } else {
892
- let max_212 = 0;
893
- t_200 = stringCodePoints_138(value_211);
894
- let slice_213 = t_200;
895
- while (true) {
896
- if (! slice_213.isEmpty) {
897
- const next_214 = slice_213.read();
898
- if (next_214 > max_212) {
899
- max_212 = next_214;
900
- } else {
901
- void 0;
902
- }
903
- t_201 = slice_213.advance(1);
904
- slice_213 = t_201;
905
- } else {
906
- break;
907
- }
908
- }
909
- return_199 = max_212;
910
- }
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;
911
772
  } else {
912
- try {
913
- requireInstanceOf__115(codePart_198, CodeRange);
914
- t_208 = true;
915
- } catch {
916
- t_208 = false;
917
- }
918
- if (t_208) {
919
- try {
920
- t_209 = requireInstanceOf__115(codePart_198, CodeRange);
921
- t_202 = t_209.max;
922
- return_199 = t_202;
923
- } catch {
924
- break s__1271_210;
925
- }
926
- } else if (eqGeneric_117(codePart_198, Digit)) {
927
- t_203 = stringCodePoints_138("9").read();
928
- try {
929
- return_199 = t_203;
930
- } catch {
931
- break s__1271_210;
932
- }
933
- } else if (eqGeneric_117(codePart_198, Space)) {
934
- t_204 = stringCodePoints_138(" ").read();
935
- try {
936
- return_199 = t_204;
937
- } catch {
938
- break s__1271_210;
773
+ let max_237 = 0;
774
+ let index_238 = 0;
775
+ while (true) {
776
+ if (!(value_236.length > index_238)) {
777
+ break;
939
778
  }
940
- } else if (eqGeneric_117(codePart_198, Word)) {
941
- t_205 = stringCodePoints_138("z").read();
942
- try {
943
- return_199 = t_205;
944
- } catch {
945
- break s__1271_210;
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;
946
783
  }
947
- } else {
948
- return_199 = null;
784
+ t_231 = stringNext_185(value_236, index_238);
785
+ index_238 = t_231;
949
786
  }
787
+ return_230 = max_237;
950
788
  }
951
- return return_199;
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;
952
801
  }
953
- throw Error();
802
+ return return_230;
954
803
  }
955
- /** @param {Array<string>} out_215 */
956
- constructor(out_215) {
957
- let t_216;
958
- if (!(out_215 !== void 0)) {
959
- t_216 = [];
960
- out_215 = t_216;
961
- }
962
- this.#out_91 = out_215;
804
+ constructor() {
805
+ super ();
806
+ let t_240 = [];
807
+ this.#out_122 = t_240;
963
808
  return;
964
809
  }
965
810
  }
966
- /** @type {RegexRefs_57} */
967
- const regexRefs_83 = new RegexRefs_57();
968
- class Begin_217 {
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
+ }
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) {
969
1030
  constructor() {
1031
+ super ();
970
1032
  return;
971
1033
  }
972
1034
  }
973
- Special.implementedBy(Begin_217);
974
1035
  /** @type {Special} */
975
- export const Begin = new Begin_217();
976
- class Dot_218 {
1036
+ export const Begin = new Begin_276();
1037
+ class Dot_277 extends type__10(Special) {
977
1038
  constructor() {
1039
+ super ();
978
1040
  return;
979
1041
  }
980
1042
  }
981
- Special.implementedBy(Dot_218);
982
1043
  /** @type {Special} */
983
- export const Dot = new Dot_218();
984
- class End_219 {
1044
+ export const Dot = new Dot_277();
1045
+ class End_278 extends type__10(Special) {
985
1046
  constructor() {
1047
+ super ();
986
1048
  return;
987
1049
  }
988
1050
  }
989
- Special.implementedBy(End_219);
990
1051
  /** @type {Special} */
991
- export const End = new End_219();
992
- class WordBoundary_220 {
1052
+ export const End = new End_278();
1053
+ class WordBoundary_279 extends type__10(Special) {
993
1054
  constructor() {
1055
+ super ();
994
1056
  return;
995
1057
  }
996
1058
  }
997
- Special.implementedBy(WordBoundary_220);
998
1059
  /** @type {Special} */
999
- export const WordBoundary = new WordBoundary_220();
1000
- class Digit_221 {
1060
+ export const WordBoundary = new WordBoundary_279();
1061
+ class Digit_280 extends type__10(SpecialSet) {
1001
1062
  constructor() {
1063
+ super ();
1002
1064
  return;
1003
1065
  }
1004
1066
  }
1005
- SpecialSet.implementedBy(Digit_221);
1006
1067
  /** @type {SpecialSet} */
1007
- export const Digit = new Digit_221();
1008
- class Space_222 {
1068
+ export const Digit = new Digit_280();
1069
+ class Space_281 extends type__10(SpecialSet) {
1009
1070
  constructor() {
1071
+ super ();
1010
1072
  return;
1011
1073
  }
1012
1074
  }
1013
- SpecialSet.implementedBy(Space_222);
1014
1075
  /** @type {SpecialSet} */
1015
- export const Space = new Space_222();
1016
- class Word_223 {
1076
+ export const Space = new Space_281();
1077
+ class Word_282 extends type__10(SpecialSet) {
1017
1078
  constructor() {
1079
+ super ();
1018
1080
  return;
1019
1081
  }
1020
1082
  }
1021
- SpecialSet.implementedBy(Word_223);
1022
1083
  /** @type {SpecialSet} */
1023
- export const Word = new Word_223();
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();
1024
1251
  /**
1025
- * @param {Regex} item_224
1026
- * @returns {Regex}
1252
+ * @param {RegexNode} item_312
1253
+ * @returns {RegexNode}
1027
1254
  */
1028
- export function entire(item_224) {
1029
- return new Sequence(listify_67(Begin, item_224, End));
1255
+ export function entire(item_312) {
1256
+ return new Sequence(Object.freeze([Begin, item_312, End]));
1030
1257
  };
1031
1258
  /**
1032
- * @param {Regex} item_225
1033
- * @param {boolean} reluctant_226
1259
+ * @param {RegexNode} item_313
1260
+ * @param {boolean | null} [reluctant_314]
1034
1261
  * @returns {Repeat}
1035
1262
  */
1036
- export function oneOrMore(item_225, reluctant_226) {
1037
- if (!(reluctant_226 !== void 0)) {
1038
- reluctant_226 = 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;
1039
1269
  }
1040
- return new Repeat(item_225, 1, null, reluctant_226);
1270
+ return new Repeat(item_313, 1, null, reluctant_315);
1041
1271
  };
1042
1272
  /**
1043
- * @param {Regex} item_227
1044
- * @param {boolean} reluctant_228
1273
+ * @param {RegexNode} item_316
1274
+ * @param {boolean | null} [reluctant_317]
1045
1275
  * @returns {Repeat}
1046
1276
  */
1047
- export function optional(item_227, reluctant_228) {
1048
- if (!(reluctant_228 !== void 0)) {
1049
- reluctant_228 = 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;
1050
1283
  }
1051
- return new Repeat(item_227, 0, 1, reluctant_228);
1284
+ return new Repeat(item_316, 0, 1, reluctant_318);
1052
1285
  };