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 @@ -100,19 +100,17 @@ extension RenderDSLTests {
100100 }
101101 """ )
102102
103- try XCTExpectFailure ( " Concatenations in alternations aren't grouped " ) {
104- try testConversion ( #"\da|b"# , """
105- Regex {
106- ChoiceOf {
107- Regex {
108- .digit
109- " a "
110- }
111- " bc "
103+ try testConversion ( #"\da|bc"# , """
104+ Regex {
105+ ChoiceOf {
106+ Regex {
107+ .digit
108+ " a "
112109 }
110+ " bc "
113111 }
114- """ )
115- }
112+ }
113+ """ )
116114 }
117115
118116 func testQuoting( ) throws {
You can’t perform that action at this time.
0 commit comments