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 @@ -97,19 +97,17 @@ extension RenderDSLTests {
97
97
}
98
98
""" )
99
99
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 "
109
106
}
107
+ " bc "
110
108
}
111
- """ )
112
- }
109
+ }
110
+ """ )
113
111
}
114
112
115
113
func testQuoting( ) throws {
You can’t perform that action at this time.
0 commit comments