@@ -538,52 +538,65 @@ struct VariadicsGenerator: ParsableCommand {
538538 output ( """
539539 // MARK: - Non-builder capture arity \( arity)
540540
541- public func capture< \( genericParams) >(_ component: R) -> \( regexTypeName) < \( newMatchType ( newCaptureType: " W " ) ) > \( whereClause) {
542- .init(node: .group(.capture, component.regex.root))
541+ public func capture< \( genericParams) >(
542+ _ component: R, as reference: Reference? = nil
543+ ) -> \( regexTypeName) < \( newMatchType ( newCaptureType: " W " ) ) > \( whereClause) {
544+ .init(node: .group(.capture, component.regex.root, reference?.id))
543545 }
544546
545547 public func capture< \( genericParams) , NewCapture>(
546- _ component: R, transform: @escaping (Substring) -> NewCapture
548+ _ component: R,
549+ as reference: Reference? = nil,
550+ transform: @escaping (Substring) -> NewCapture
547551 ) -> \( regexTypeName) < \( newMatchType ( newCaptureType: " NewCapture " ) ) > \( whereClause) {
548552 .init(node: .groupTransform(
549553 .capture,
550554 component.regex.root,
551555 CaptureTransform(resultType: NewCapture.self) {
552556 transform($0) as Any
553- }))
557+ },
558+ reference?.id))
554559 }
555560
556561 public func tryCapture< \( genericParams) , NewCapture>(
557- _ component: R, transform: @escaping (Substring) throws -> NewCapture
562+ _ component: R,
563+ as reference: Reference? = nil,
564+ transform: @escaping (Substring) throws -> NewCapture
558565 ) -> \( regexTypeName) < \( newMatchType ( newCaptureType: " NewCapture " ) ) > \( whereClause) {
559566 .init(node: .groupTransform(
560567 .capture,
561568 component.regex.root,
562569 CaptureTransform(resultType: NewCapture.self) {
563570 try transform($0) as Any
564- }))
571+ },
572+ reference?.id))
565573 }
566574
567575 public func tryCapture< \( genericParams) , NewCapture>(
568- _ component: R, transform: @escaping (Substring) -> NewCapture?
576+ _ component: R,
577+ as reference: Reference? = nil,
578+ transform: @escaping (Substring) -> NewCapture?
569579 ) -> \( regexTypeName) < \( newMatchType ( newCaptureType: " NewCapture " ) ) > \( whereClause) {
570580 .init(node: .groupTransform(
571581 .capture,
572582 component.regex.root,
573583 CaptureTransform(resultType: NewCapture.self) {
574584 transform($0) as Any?
575- }))
585+ },
586+ reference?.id))
576587 }
577588
578589 // MARK: - Builder capture arity \( arity)
579590
580591 public func capture< \( genericParams) >(
592+ as reference: Reference? = nil,
581593 @RegexBuilder _ component: () -> R
582594 ) -> \( regexTypeName) < \( newMatchType ( newCaptureType: " W " ) ) > \( whereClause) {
583- .init(node: .group(.capture, component().regex.root))
595+ .init(node: .group(.capture, component().regex.root, reference?.id ))
584596 }
585597
586598 public func capture< \( genericParams) , NewCapture>(
599+ as reference: Reference? = nil,
587600 @RegexBuilder _ component: () -> R,
588601 transform: @escaping (Substring) -> NewCapture
589602 ) -> \( regexTypeName) < \( newMatchType ( newCaptureType: " NewCapture " ) ) > \( whereClause) {
@@ -592,10 +605,12 @@ struct VariadicsGenerator: ParsableCommand {
592605 component().regex.root,
593606 CaptureTransform(resultType: NewCapture.self) {
594607 transform($0) as Any
595- }))
608+ },
609+ reference?.id))
596610 }
597611
598612 public func tryCapture< \( genericParams) , NewCapture>(
613+ as reference: Reference? = nil,
599614 @RegexBuilder _ component: () -> R,
600615 transform: @escaping (Substring) throws -> NewCapture
601616 ) -> \( regexTypeName) < \( newMatchType ( newCaptureType: " NewCapture " ) ) > \( whereClause) {
@@ -604,10 +619,12 @@ struct VariadicsGenerator: ParsableCommand {
604619 component().regex.root,
605620 CaptureTransform(resultType: NewCapture.self) {
606621 try transform($0) as Any
607- }))
622+ },
623+ reference?.id))
608624 }
609625
610626 public func tryCapture< \( genericParams) , NewCapture>(
627+ as reference: Reference? = nil,
611628 @RegexBuilder _ component: () -> R,
612629 transform: @escaping (Substring) -> NewCapture?
613630 ) -> \( regexTypeName) < \( newMatchType ( newCaptureType: " NewCapture " ) ) > \( whereClause) {
@@ -616,7 +633,8 @@ struct VariadicsGenerator: ParsableCommand {
616633 component().regex.root,
617634 CaptureTransform(resultType: NewCapture.self) {
618635 transform($0) as Any?
619- }))
636+ },
637+ reference?.id))
620638 }
621639
622640 """ )
0 commit comments