File tree Expand file tree Collapse file tree 2 files changed +22
-15
lines changed
Sources/_StringProcessing Expand file tree Collapse file tree 2 files changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,15 @@ extension PrettyPrinter {
7171 print ( " let \( namedCapture) = Reference(Substring.self) " )
7272 }
7373
74- printBlock ( " Regex " ) { printer in
75- printer. printAsPattern ( convertedFromAST: node)
74+ switch node {
75+ case . concatenation( _) :
76+ printAsPattern ( convertedFromAST: node)
77+ case . convertedRegexLiteral( . concatenation( _) , _) :
78+ printAsPattern ( convertedFromAST: node)
79+ default :
80+ printBlock ( " Regex " ) { printer in
81+ printer. printAsPattern ( convertedFromAST: node)
82+ }
7683 }
7784 }
7885
@@ -99,8 +106,10 @@ extension PrettyPrinter {
99106 }
100107
101108 case let . concatenation( c) :
102- c. forEach {
103- printAsPattern ( convertedFromAST: $0)
109+ printBlock ( " Regex " ) { printer in
110+ c. forEach {
111+ printer. printAsPattern ( convertedFromAST: $0)
112+ }
104113 }
105114
106115 case let . nonCapturingGroup( kind, child) :
Original file line number Diff line number Diff line change @@ -97,19 +97,17 @@ extension RenderDSLTests {
9797 }
9898 """ )
9999
100- try XCTExpectFailure ( " Concatenations in alternations aren't grouped " ) {
101- try testConversion ( #"\da|b"# , """
102- Regex {
103- ChoiceOf {
104- Regex {
105- .digit
106- " a "
107- }
108- " bc "
100+ try testConversion ( #"\da|bc"# , """
101+ Regex {
102+ ChoiceOf {
103+ Regex {
104+ One(.digit)
105+ " a "
109106 }
107+ " bc "
110108 }
111- """ )
112- }
109+ }
110+ """ )
113111 }
114112
115113 func testQuoting( ) throws {
You can’t perform that action at this time.
0 commit comments