File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
Sources/_StringProcessing Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -518,6 +518,14 @@ extension PrettyPrinter {
518518 } else {
519519 output ( base. 0 )
520520 }
521+
522+ case let . characterClass( cc) :
523+ if wrap {
524+ output ( " One( \( cc. _patternBase) ) " )
525+ } else {
526+ output ( cc. _patternBase)
527+ }
528+
521529 default :
522530 print ( " // TODO: Atom \( a) " )
523531 }
Original file line number Diff line number Diff line change @@ -276,4 +276,40 @@ extension RenderDSLTests {
276276 }
277277 """# )
278278 }
279+
280+ func testCharacterClass( ) throws {
281+ try testConversion ( #"[abc]+"# , #"""
282+ Regex {
283+ OneOrMore(.anyOf("abc"))
284+ }
285+ """# )
286+
287+ try testConversion ( #"[[:whitespace:]]"# , #"""
288+ Regex {
289+ One(.whitespace)
290+ }
291+ """# )
292+
293+ try testConversion ( #"[\b\w]+"# , #"""
294+ Regex {
295+ OneOrMore {
296+ CharacterClass(
297+ .anyOf("\u{8}"),
298+ .word
299+ )
300+ }
301+ }
302+ """# )
303+
304+ try testConversion ( #"[abc\sd]+"# , #"""
305+ Regex {
306+ OneOrMore {
307+ CharacterClass(
308+ .anyOf("abcd"),
309+ .whitespace
310+ )
311+ }
312+ }
313+ """# )
314+ }
279315}
You can’t perform that action at this time.
0 commit comments