@@ -211,19 +211,14 @@ struct VariadicsGenerator: ParsableCommand {
211211 }
212212
213213 func emitConcatenation( leftArity: Int , rightArity: Int ) {
214- func genericParameters ( withConstraints : Bool ) -> String {
214+ let genericParams : String = {
215215 var result = " W0, W1 "
216216 result += ( 0 ..< leftArity+ rightArity) . map {
217217 " , C \( $0) "
218218 } . joined ( )
219- result += " , "
220- if withConstraints {
221- result += " R0: \( regexProtocolName) , R1: \( regexProtocolName) "
222- } else {
223- result += " R0, R1 "
224- }
219+ result += " , R0: \( regexProtocolName) , R1: \( regexProtocolName) "
225220 return result
226- }
221+ } ( )
227222
228223 // Emit concatenation type declaration.
229224
@@ -260,13 +255,13 @@ struct VariadicsGenerator: ParsableCommand {
260255 // Emit concatenation builder.
261256 output ( " extension \( patternBuilderTypeName) { \n " )
262257 output ( """
263- @_disfavoredOverload
264- public static func buildBlock< \( genericParameters ( withConstraints: true ) ) >(
265- combining next: R1, into combined: R0
266- ) -> \( regexTypeName) < \( matchType) > \( whereClause) {
267- .init(node: combined.regex.root.appending(next.regex.root))
268- }
258+ @_disfavoredOverload
259+ public static func buildBlock< \( genericParams) >(
260+ combining next: R1, into combined: R0
261+ ) -> \( regexTypeName) < \( matchType) > \( whereClause) {
262+ .init(node: combined.regex.root.appending(next.regex.root))
269263 }
264+ }
270265
271266 """ )
272267 }
@@ -338,19 +333,16 @@ struct VariadicsGenerator: ParsableCommand {
338333
339334 func emitQuantifier( kind: QuantifierKind , arity: Int ) {
340335 assert ( arity >= 0 )
341- func genericParameters ( withConstraints : Bool ) -> String {
336+ let genericParams : String = {
342337 var result = " "
343338 if arity > 0 {
344339 result += " W "
345340 result += ( 0 ..< arity) . map { " , C \( $0) " } . joined ( )
346341 result += " , "
347342 }
348- result += " Component "
349- if withConstraints {
350- result += " : \( regexProtocolName) "
351- }
343+ result += " Component: \( regexProtocolName) "
352344 return result
353- }
345+ } ( )
354346 let captures = ( 0 ..< arity) . map { " C \( $0) " } . joined ( separator: " , " )
355347 let capturesTupled = arity == 1 ? captures : " ( \( captures) ) "
356348 let whereClause : String = arity == 0 ? " " :
@@ -366,21 +358,23 @@ struct VariadicsGenerator: ParsableCommand {
366358 let matchType = arity == 0 ? baseMatchTypeName : " ( \( baseMatchTypeName) , \( quantifiedCaptures) ) "
367359 output ( """
368360 \( arity == 0 ? " @_disfavoredOverload " : " " )
369- public func \( kind. rawValue) < \( genericParameters ( withConstraints: true ) ) >(
370- _ component: Component
361+ public func \( kind. rawValue) < \( genericParams) >(
362+ _ component: Component,
363+ _ behavior: QuantificationBehavior = .eagerly
371364 ) -> \( regexTypeName) < \( matchType) > \( whereClause) {
372- .init(node: .quantification(. \( kind. astQuantifierAmount) , .eager , component.regex.root))
365+ .init(node: .quantification(. \( kind. astQuantifierAmount) , behavior.astKind , component.regex.root))
373366 }
374367
375368 \( arity == 0 ? " @_disfavoredOverload " : " " )
376- public func \( kind. rawValue) < \( genericParameters ( withConstraints: true ) ) >(
369+ public func \( kind. rawValue) < \( genericParams) >(
370+ _ behavior: QuantificationBehavior = .eagerly,
377371 @RegexBuilder _ component: () -> Component
378372 ) -> \( regexTypeName) < \( matchType) > \( whereClause) {
379- .init(node: .quantification(. \( kind. astQuantifierAmount) , .eager , component().regex.root))
373+ .init(node: .quantification(. \( kind. astQuantifierAmount) , behavior.astKind , component().regex.root))
380374 }
381375
382376 \( arity == 0 ? " @_disfavoredOverload " : " " )
383- public postfix func \( kind. operatorName) < \( genericParameters ( withConstraints : true ) ) >(
377+ public postfix func \( kind. operatorName) < \( genericParams ) >(
384378 _ component: Component
385379 ) -> \( regexTypeName) < \( matchType) > \( whereClause) {
386380 .init(node: .quantification(. \( kind. astQuantifierAmount) , .eager, component.regex.root))
@@ -389,7 +383,7 @@ struct VariadicsGenerator: ParsableCommand {
389383 \( kind == . zeroOrOne ?
390384 """
391385 extension RegexBuilder {
392- public static func buildLimitedAvailability< \( genericParameters ( withConstraints : true ) ) >(
386+ public static func buildLimitedAvailability< \( genericParams ) >(
393387 _ component: Component
394388 ) -> \( regexTypeName) < \( matchType) > \( whereClause) {
395389 .init(node: .quantification(. \( kind. astQuantifierAmount) , .eager, component.regex.root))
0 commit comments