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 {
5858 // TODO: Handle global options...
5959 let node = ast. root. dslTreeNode
6060
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.
6262 let namedCaptures = node. getNamedCaptures ( )
6363
6464 for namedCapture in namedCaptures {
@@ -226,6 +226,23 @@ extension PrettyPrinter {
226226
227227 var charMembers = " "
228228
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'.
229246 let nonCharMembers = ccc. members. filter {
230247 switch $0 {
231248 case let . atom( a) :
You can’t perform that action at this time.
0 commit comments