File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Sources/_StringProcessing Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ extension PrettyPrinter {
58
58
// TODO: Handle global options...
59
59
let node = ast. root. dslTreeNode
60
60
61
- // If we have any named captures, create referencs to those above the regex.
61
+ // If we have any named captures, create references to those above the regex.
62
62
let namedCaptures = node. getNamedCaptures ( )
63
63
64
64
for namedCapture in namedCaptures {
@@ -226,6 +226,23 @@ extension PrettyPrinter {
226
226
227
227
var charMembers = " "
228
228
229
+
230
+ // This iterates through all of the character class members collecting all
231
+ // of the members who can be stuffed into a singular '.anyOf(...)' vs.
232
+ // having multiple. This does alter the original representation, but the
233
+ // result is the same. For example:
234
+ //
235
+ // Convert: '[abc\d\Qxyz\E[:space:]def]'
236
+ //
237
+ // CharacterClass(
238
+ // .anyOf("abcxyzdef"),
239
+ // .digit,
240
+ // .whitespace
241
+ // )
242
+ //
243
+ // This also allows us to determine if after collecting all of the members
244
+ // and stuffing them if we can just emit a standalone '.anyOf' instead of
245
+ // initializing a 'CharacterClass'.
229
246
let nonCharMembers = ccc. members. filter {
230
247
switch $0 {
231
248
case let . atom( a) :
You can’t perform that action at this time.
0 commit comments