File tree 2 files changed +22
-15
lines changed
Sources/_StringProcessing
2 files changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,15 @@ extension PrettyPrinter {
71
71
print ( " let \( namedCapture) = Reference(Substring.self) " )
72
72
}
73
73
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
+ }
76
83
}
77
84
}
78
85
@@ -99,8 +106,10 @@ extension PrettyPrinter {
99
106
}
100
107
101
108
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
+ }
104
113
}
105
114
106
115
case let . nonCapturingGroup( kind, child) :
Original file line number Diff line number Diff line change @@ -100,19 +100,17 @@ extension RenderDSLTests {
100
100
}
101
101
""" )
102
102
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 "
112
109
}
110
+ " bc "
113
111
}
114
- """ )
115
- }
112
+ }
113
+ """ )
116
114
}
117
115
118
116
func testQuoting( ) throws {
You can’t perform that action at this time.
0 commit comments