diff --git a/Sources/Exercises/Participants/RegexParticipant.swift b/Sources/Exercises/Participants/RegexParticipant.swift index a73f9ecd0..d62ddc422 100644 --- a/Sources/Exercises/Participants/RegexParticipant.swift +++ b/Sources/Exercises/Participants/RegexParticipant.swift @@ -46,7 +46,7 @@ struct RegexLiteralParticipant: Participant { // MARK: - Regex literal private func extractFromCaptures( - _ match: Tuple4 + _ match: (Substring, Substring, Substring?, Substring) ) -> GraphemeBreakEntry? { guard let lowerScalar = Unicode.Scalar(hex: match.1), let upperScalar = match.2.map(Unicode.Scalar.init(hex:)) ?? lowerScalar, @@ -61,7 +61,7 @@ private func extractFromCaptures( private func graphemeBreakPropertyData( forLine line: String, using regex: RP -) -> GraphemeBreakEntry? where RP.Match == Tuple4 { +) -> GraphemeBreakEntry? where RP.Match == (Substring, Substring, Substring?, Substring) { line.match(regex).map(\.match).flatMap(extractFromCaptures) } @@ -71,7 +71,7 @@ private func graphemeBreakPropertyDataLiteral( return graphemeBreakPropertyData( forLine: line, using: r(#"([0-9A-F]+)(?:\.\.([0-9A-F]+))?\s+;\s+(\w+).*"#, - matching: Tuple4.self)) + matching: (Substring, Substring, Substring?, Substring).self)) } // MARK: - Builder DSL @@ -80,18 +80,18 @@ private func graphemeBreakPropertyData( forLine line: String ) -> GraphemeBreakEntry? { line.match { - OneOrMore(.hexDigit).tryCapture(Unicode.Scalar.init(hex:)) - Optionally { + oneOrMore(.hexDigit).tryCapture(Unicode.Scalar.init(hex:)) + optionally { ".." - OneOrMore(.hexDigit).tryCapture(Unicode.Scalar.init(hex:)) + oneOrMore(.hexDigit).tryCapture(Unicode.Scalar.init(hex:)) } - OneOrMore(.whitespace) + oneOrMore(.whitespace) ";" - OneOrMore(.whitespace) - OneOrMore(.word).tryCapture(Unicode.GraphemeBreakProperty.init) - Repeat(.any) + oneOrMore(.whitespace) + oneOrMore(.word).tryCapture(Unicode.GraphemeBreakProperty.init) + many(.any) }.map { - let (_, lower, upper, property) = $0.match.tuple + let (_, lower, upper, property) = $0.match return GraphemeBreakEntry(lower...(upper ?? lower), property) } } diff --git a/Sources/VariadicsGenerator/VariadicsGenerator.swift b/Sources/VariadicsGenerator/VariadicsGenerator.swift index 130e51c27..c82f4b1ff 100644 --- a/Sources/VariadicsGenerator/VariadicsGenerator.swift +++ b/Sources/VariadicsGenerator/VariadicsGenerator.swift @@ -89,7 +89,7 @@ struct StandardErrorStream: TextOutputStream { var standardError = StandardErrorStream() typealias Counter = Int64 -let patternProtocolName = "RegexProtocol" +let regexProtocolName = "RegexProtocol" let concatenationStructTypeBaseName = "Concatenate" let capturingGroupTypeBaseName = "CapturingGroup" let matchAssociatedTypeName = "Match" @@ -97,7 +97,6 @@ let captureAssociatedTypeName = "Capture" let patternBuilderTypeName = "RegexBuilder" let patternProtocolRequirementName = "regex" let PatternTypeBaseName = "Regex" -let emptyProtocolName = "EmptyCaptureProtocol" let baseMatchTypeName = "Substring" @main @@ -128,13 +127,19 @@ struct VariadicsGenerator: ParsableCommand { """) - for arity in 2...maxArity+1 { - emitTupleStruct(arity: arity) + print("Generating 'buildBlock(_:)' overloads...", to: &standardError) + for arity in 1.." + return "(\(genericParameters()))" } - func emitTupleStruct(arity: Int) { - output(""" - @frozen @dynamicMemberLookup - public struct Tuple\(arity)< - """) - outputForEach(0.. {") - // `public typealias Tuple = (_0, ...)` - output("\n public typealias Tuple = (") - outputForEach(0.. 0) + let captureTypes = (0..(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } + extension RegexBuilder { + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, \(captureTypes)) + { + regex } - """) - output("\n}\n") - output("extension Tuple\(arity): \(emptyProtocolName) where ") - outputForEach(1..") - } - output("\n public init(_ tuple: Tuple) { self.tuple = tuple }") - // `public init(_0: _0, ...) { ... }` - output("\n public init(") - outputForEach(0.. Bool {\n") - output(" ") - outputForEach(0..: RegexProtocol - // where R0.Match == Tuple2, R1.Match == Tuple2 + // where R0.Match == (W0, C0), R1.Match == (W1, C1) // { - // public typealias Match = Tuple3 + // public typealias Match = (Substring, C0, C1) // - // public let regex: Regex> + // public let regex: Regex<(Substring, C0, C1)> // // public init(_ r0: R0, _ r1: R1) { // self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -268,38 +235,38 @@ struct VariadicsGenerator: ParsableCommand { let typeName = "\(concatenationStructTypeBaseName)_\(leftArity)_\(rightArity)" output("public struct \(typeName)<\n ") emitGenericParameters(withConstraints: true) - output("\n>: \(patternProtocolName)") + output("\n>: \(regexProtocolName)") output(" where ") output("R0.Match == ") if leftArity == 0 { output("W0") } else { - output("Tuple\(leftArity+1)") + output(")") } output(", R1.Match == ") if rightArity == 0 { output("W1") } else { - output("Tuple\(rightArity+1)") + output(")") } output(" {\n") output(" public typealias \(matchAssociatedTypeName) = ") if leftArity+rightArity == 0 { output(baseMatchTypeName) } else { - output("Tuple\(leftArity+rightArity+1)<\(baseMatchTypeName), ") + output("(\(baseMatchTypeName), ") outputForEach(0..") + output(")") } output("\n") output(" public let \(patternProtocolRequirementName): \(PatternTypeBaseName)<\(matchAssociatedTypeName)>\n") @@ -337,41 +304,144 @@ struct VariadicsGenerator: ParsableCommand { // T + () = T output(""" extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( + , R0: \(regexProtocolName), R1: \(regexProtocolName)>( combining next: R1, into combined: R0 ) -> Regex< """) if leftArity == 0 { output(baseMatchTypeName) } else { - output("Tuple\(leftArity+1)<\(baseMatchTypeName)") + output("(\(baseMatchTypeName)") outputForEach(0..") + output(")") } output("> where R0.\(matchAssociatedTypeName) == ") if leftArity == 0 { output("W0") } else { - output("Tuple\(leftArity+1)") + output(")") } output(""" - , R1.\(matchAssociatedTypeName): \(emptyProtocolName) { + { .init(node: combined.regex.root.appending(next.regex.root)) } } """) } + + enum QuantifierKind: String, CaseIterable { + case zeroOrOne = "optionally" + case zeroOrMore = "many" + case oneOrMore = "oneOrMore" + + var typeName: String { + switch self { + case .zeroOrOne: return "_ZeroOrOne" + case .zeroOrMore: return "_ZeroOrMore" + case .oneOrMore: return "_OneOrMore" + } + } + + var operatorName: String { + switch self { + case .zeroOrOne: return ".?" + case .zeroOrMore: return ".+" + case .oneOrMore: return ".*" + } + } + + var astQuantifierAmount: String { + switch self { + case .zeroOrOne: return "zeroOrOne" + case .zeroOrMore: return "zeroOrMore" + case .oneOrMore: return "oneOrMore" + } + } + } + + func emitQuantifier(kind: QuantifierKind, arity: Int) { + assert(arity >= 0) + func genericParameters(withConstraints: Bool) -> String { + var result = "" + if arity > 0 { + result += "W" + result += (0..: \(regexProtocolName) \(componentConstraint) { + public typealias \(matchAssociatedTypeName) = \(matchType) + public let regex: Regex<\(matchAssociatedTypeName)> + public init(component: Component) { + self.regex = .init(node: .quantification(.\(kind.astQuantifierAmount), .eager, component.regex.root)) + } + } + + \(arity == 0 ? "@_disfavoredOverload" : "") + public func \(kind.rawValue)<\(genericParameters(withConstraints: true))>( + _ component: Component + ) -> \(kind.typeName)_\(arity)<\(genericParameters(withConstraints: false))> { + .init(component: component) + } + + \(arity == 0 ? "@_disfavoredOverload" : "") + public func \(kind.rawValue)<\(genericParameters(withConstraints: true))>( + @RegexBuilder _ component: () -> Component + ) -> \(kind.typeName)_\(arity)<\(genericParameters(withConstraints: false))> { + \(kind.rawValue)(component()) + } + + \(arity == 0 ? "@_disfavoredOverload" : "") + public postfix func \(kind.operatorName)<\(genericParameters(withConstraints: true))>( + _ component: Component + ) -> \(kind.typeName)_\(arity)<\(genericParameters(withConstraints: false))> { + \(kind.rawValue)(component) + } + + \(kind == .zeroOrOne ? + """ + extension RegexBuilder { + public static func buildLimitedAvailability<\(genericParameters(withConstraints: true))>( + _ component: Component + ) -> \(kind.typeName)_\(arity)<\(genericParameters(withConstraints: false))> { + \(kind.rawValue)(component) + } + } + """ : "") + + """) + } } diff --git a/Sources/_StringProcessing/RegexDSL/Builder.swift b/Sources/_StringProcessing/RegexDSL/Builder.swift index 754dff219..f4b3516c3 100644 --- a/Sources/_StringProcessing/RegexDSL/Builder.swift +++ b/Sources/_StringProcessing/RegexDSL/Builder.swift @@ -16,12 +16,6 @@ public enum RegexBuilder { r0 } - public static func buildBlock( - _ r0: R0 - ) -> Regex where R0.Match: EmptyCaptureProtocol { - .init(node: r0.regex.root) - } - public static func buildExpression(_ regex: R) -> R { regex } @@ -33,10 +27,4 @@ public enum RegexBuilder { public static func buildEither(second component: R) -> R { component } - - public static func buildLimitedAvailability( - _ component: R - ) -> Optionally { - .init(component) - } } diff --git a/Sources/_StringProcessing/RegexDSL/Concatenation.swift b/Sources/_StringProcessing/RegexDSL/Concatenation.swift index 575384d33..c243b68c6 100644 --- a/Sources/_StringProcessing/RegexDSL/Concatenation.swift +++ b/Sources/_StringProcessing/RegexDSL/Concatenation.swift @@ -13,247 +13,73 @@ import _MatchingEngine -@frozen @dynamicMemberLookup -public struct Tuple2<_0, _1> { - public typealias Tuple = (_0, _1) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } - } -} -extension Tuple2: EmptyCaptureProtocol where _1: EmptyCaptureProtocol {} -extension Tuple2: MatchProtocol { - public typealias Capture = _1 - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1) { - self.init((_0, _1)) - } -} -extension Tuple2: Equatable where _0: Equatable, _1: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 - } -} -@frozen @dynamicMemberLookup -public struct Tuple3<_0, _1, _2> { - public typealias Tuple = (_0, _1, _2) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } - } -} -extension Tuple3: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol {} -extension Tuple3: MatchProtocol { - public typealias Capture = Tuple2<_1, _2> - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1, _ _2: _2) { - self.init((_0, _1, _2)) - } -} -extension Tuple3: Equatable where _0: Equatable, _1: Equatable, _2: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 && lhs.tuple.2 == rhs.tuple.2 - } -} -@frozen @dynamicMemberLookup -public struct Tuple4<_0, _1, _2, _3> { - public typealias Tuple = (_0, _1, _2, _3) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } - } -} -extension Tuple4: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol, _3: EmptyCaptureProtocol {} -extension Tuple4: MatchProtocol { - public typealias Capture = Tuple3<_1, _2, _3> - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1, _ _2: _2, _ _3: _3) { - self.init((_0, _1, _2, _3)) - } -} -extension Tuple4: Equatable where _0: Equatable, _1: Equatable, _2: Equatable, _3: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 && lhs.tuple.2 == rhs.tuple.2 && lhs.tuple.3 == rhs.tuple.3 - } -} -@frozen @dynamicMemberLookup -public struct Tuple5<_0, _1, _2, _3, _4> { - public typealias Tuple = (_0, _1, _2, _3, _4) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } - } -} -extension Tuple5: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol, _3: EmptyCaptureProtocol, _4: EmptyCaptureProtocol {} -extension Tuple5: MatchProtocol { - public typealias Capture = Tuple4<_1, _2, _3, _4> - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1, _ _2: _2, _ _3: _3, _ _4: _4) { - self.init((_0, _1, _2, _3, _4)) - } -} -extension Tuple5: Equatable where _0: Equatable, _1: Equatable, _2: Equatable, _3: Equatable, _4: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 && lhs.tuple.2 == rhs.tuple.2 && lhs.tuple.3 == rhs.tuple.3 && lhs.tuple.4 == rhs.tuple.4 - } -} -@frozen @dynamicMemberLookup -public struct Tuple6<_0, _1, _2, _3, _4, _5> { - public typealias Tuple = (_0, _1, _2, _3, _4, _5) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } - } -} -extension Tuple6: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol, _3: EmptyCaptureProtocol, _4: EmptyCaptureProtocol, _5: EmptyCaptureProtocol {} -extension Tuple6: MatchProtocol { - public typealias Capture = Tuple5<_1, _2, _3, _4, _5> - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1, _ _2: _2, _ _3: _3, _ _4: _4, _ _5: _5) { - self.init((_0, _1, _2, _3, _4, _5)) - } -} -extension Tuple6: Equatable where _0: Equatable, _1: Equatable, _2: Equatable, _3: Equatable, _4: Equatable, _5: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 && lhs.tuple.2 == rhs.tuple.2 && lhs.tuple.3 == rhs.tuple.3 && lhs.tuple.4 == rhs.tuple.4 && lhs.tuple.5 == rhs.tuple.5 - } -} -@frozen @dynamicMemberLookup -public struct Tuple7<_0, _1, _2, _3, _4, _5, _6> { - public typealias Tuple = (_0, _1, _2, _3, _4, _5, _6) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } - } -} -extension Tuple7: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol, _3: EmptyCaptureProtocol, _4: EmptyCaptureProtocol, _5: EmptyCaptureProtocol, _6: EmptyCaptureProtocol {} -extension Tuple7: MatchProtocol { - public typealias Capture = Tuple6<_1, _2, _3, _4, _5, _6> - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1, _ _2: _2, _ _3: _3, _ _4: _4, _ _5: _5, _ _6: _6) { - self.init((_0, _1, _2, _3, _4, _5, _6)) - } -} -extension Tuple7: Equatable where _0: Equatable, _1: Equatable, _2: Equatable, _3: Equatable, _4: Equatable, _5: Equatable, _6: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 && lhs.tuple.2 == rhs.tuple.2 && lhs.tuple.3 == rhs.tuple.3 && lhs.tuple.4 == rhs.tuple.4 && lhs.tuple.5 == rhs.tuple.5 && lhs.tuple.6 == rhs.tuple.6 - } -} -@frozen @dynamicMemberLookup -public struct Tuple8<_0, _1, _2, _3, _4, _5, _6, _7> { - public typealias Tuple = (_0, _1, _2, _3, _4, _5, _6, _7) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } - } -} -extension Tuple8: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol, _3: EmptyCaptureProtocol, _4: EmptyCaptureProtocol, _5: EmptyCaptureProtocol, _6: EmptyCaptureProtocol, _7: EmptyCaptureProtocol {} -extension Tuple8: MatchProtocol { - public typealias Capture = Tuple7<_1, _2, _3, _4, _5, _6, _7> - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1, _ _2: _2, _ _3: _3, _ _4: _4, _ _5: _5, _ _6: _6, _ _7: _7) { - self.init((_0, _1, _2, _3, _4, _5, _6, _7)) - } -} -extension Tuple8: Equatable where _0: Equatable, _1: Equatable, _2: Equatable, _3: Equatable, _4: Equatable, _5: Equatable, _6: Equatable, _7: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 && lhs.tuple.2 == rhs.tuple.2 && lhs.tuple.3 == rhs.tuple.3 && lhs.tuple.4 == rhs.tuple.4 && lhs.tuple.5 == rhs.tuple.5 && lhs.tuple.6 == rhs.tuple.6 && lhs.tuple.7 == rhs.tuple.7 - } -} -@frozen @dynamicMemberLookup -public struct Tuple9<_0, _1, _2, _3, _4, _5, _6, _7, _8> { - public typealias Tuple = (_0, _1, _2, _3, _4, _5, _6, _7, _8) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } - } -} -extension Tuple9: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol, _3: EmptyCaptureProtocol, _4: EmptyCaptureProtocol, _5: EmptyCaptureProtocol, _6: EmptyCaptureProtocol, _7: EmptyCaptureProtocol, _8: EmptyCaptureProtocol {} -extension Tuple9: MatchProtocol { - public typealias Capture = Tuple8<_1, _2, _3, _4, _5, _6, _7, _8> - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1, _ _2: _2, _ _3: _3, _ _4: _4, _ _5: _5, _ _6: _6, _ _7: _7, _ _8: _8) { - self.init((_0, _1, _2, _3, _4, _5, _6, _7, _8)) - } -} -extension Tuple9: Equatable where _0: Equatable, _1: Equatable, _2: Equatable, _3: Equatable, _4: Equatable, _5: Equatable, _6: Equatable, _7: Equatable, _8: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 && lhs.tuple.2 == rhs.tuple.2 && lhs.tuple.3 == rhs.tuple.3 && lhs.tuple.4 == rhs.tuple.4 && lhs.tuple.5 == rhs.tuple.5 && lhs.tuple.6 == rhs.tuple.6 && lhs.tuple.7 == rhs.tuple.7 && lhs.tuple.8 == rhs.tuple.8 +extension RegexBuilder { + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, C0) + { + regex } } -@frozen @dynamicMemberLookup -public struct Tuple10<_0, _1, _2, _3, _4, _5, _6, _7, _8, _9> { - public typealias Tuple = (_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } +extension RegexBuilder { + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, C0, C1) + { + regex } } -extension Tuple10: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol, _3: EmptyCaptureProtocol, _4: EmptyCaptureProtocol, _5: EmptyCaptureProtocol, _6: EmptyCaptureProtocol, _7: EmptyCaptureProtocol, _8: EmptyCaptureProtocol, _9: EmptyCaptureProtocol {} -extension Tuple10: MatchProtocol { - public typealias Capture = Tuple9<_1, _2, _3, _4, _5, _6, _7, _8, _9> - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1, _ _2: _2, _ _3: _3, _ _4: _4, _ _5: _5, _ _6: _6, _ _7: _7, _ _8: _8, _ _9: _9) { - self.init((_0, _1, _2, _3, _4, _5, _6, _7, _8, _9)) +extension RegexBuilder { + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, C0, C1, C2) + { + regex } } -extension Tuple10: Equatable where _0: Equatable, _1: Equatable, _2: Equatable, _3: Equatable, _4: Equatable, _5: Equatable, _6: Equatable, _7: Equatable, _8: Equatable, _9: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 && lhs.tuple.2 == rhs.tuple.2 && lhs.tuple.3 == rhs.tuple.3 && lhs.tuple.4 == rhs.tuple.4 && lhs.tuple.5 == rhs.tuple.5 && lhs.tuple.6 == rhs.tuple.6 && lhs.tuple.7 == rhs.tuple.7 && lhs.tuple.8 == rhs.tuple.8 && lhs.tuple.9 == rhs.tuple.9 +extension RegexBuilder { + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, C0, C1, C2, C3) + { + regex } } -@frozen @dynamicMemberLookup -public struct Tuple11<_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10> { - public typealias Tuple = (_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - public var tuple: Tuple - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { - get { tuple[keyPath: keyPath] } - _modify { yield &tuple[keyPath: keyPath] } +extension RegexBuilder { + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, C0, C1, C2, C3, C4) + { + regex } } -extension Tuple11: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol, _3: EmptyCaptureProtocol, _4: EmptyCaptureProtocol, _5: EmptyCaptureProtocol, _6: EmptyCaptureProtocol, _7: EmptyCaptureProtocol, _8: EmptyCaptureProtocol, _9: EmptyCaptureProtocol, _10: EmptyCaptureProtocol {} -extension Tuple11: MatchProtocol { - public typealias Capture = Tuple10<_1, _2, _3, _4, _5, _6, _7, _8, _9, _10> - public init(_ tuple: Tuple) { self.tuple = tuple } - public init(_ _0: _0, _ _1: _1, _ _2: _2, _ _3: _3, _ _4: _4, _ _5: _5, _ _6: _6, _ _7: _7, _ _8: _8, _ _9: _9, _ _10: _10) { - self.init((_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10)) +extension RegexBuilder { + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, C0, C1, C2, C3, C4, C5) + { + regex } } -extension Tuple11: Equatable where _0: Equatable, _1: Equatable, _2: Equatable, _3: Equatable, _4: Equatable, _5: Equatable, _6: Equatable, _7: Equatable, _8: Equatable, _9: Equatable, _10: Equatable { - public static func == (lhs: Self, rhs: Self) -> Bool { - lhs.tuple.0 == rhs.tuple.0 && lhs.tuple.1 == rhs.tuple.1 && lhs.tuple.2 == rhs.tuple.2 && lhs.tuple.3 == rhs.tuple.3 && lhs.tuple.4 == rhs.tuple.4 && lhs.tuple.5 == rhs.tuple.5 && lhs.tuple.6 == rhs.tuple.6 && lhs.tuple.7 == rhs.tuple.7 && lhs.tuple.8 == rhs.tuple.8 && lhs.tuple.9 == rhs.tuple.9 && lhs.tuple.10 == rhs.tuple.10 +extension RegexBuilder { + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, C0, C1, C2, C3, C4, C5, C6) + { + regex } } -public struct Concatenate_0_0< - W0, W1, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == W1 { - public typealias Match = Substring - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) +extension RegexBuilder { + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, C0, C1, C2, C3, C4, C5, C6, C7) + { + regex } } extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_0_0 { - .init(combined, next) + public static func buildBlock(_ regex: R) -> R + where R.Match == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8) + { + regex } } public struct Concatenate_0_1< W0, W1, C0, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple2 { - public typealias Match = Tuple2 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0) { + public typealias Match = (Substring, C0) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -269,8 +95,8 @@ extension RegexBuilder { } public struct Concatenate_0_2< W0, W1, C0, C1, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple3 { - public typealias Match = Tuple3 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0, C1) { + public typealias Match = (Substring, C0, C1) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -286,8 +112,8 @@ extension RegexBuilder { } public struct Concatenate_0_3< W0, W1, C0, C1, C2, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple4 { - public typealias Match = Tuple4 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0, C1, C2) { + public typealias Match = (Substring, C0, C1, C2) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -303,8 +129,8 @@ extension RegexBuilder { } public struct Concatenate_0_4< W0, W1, C0, C1, C2, C3, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple5 { - public typealias Match = Tuple5 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0, C1, C2, C3) { + public typealias Match = (Substring, C0, C1, C2, C3) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -320,8 +146,8 @@ extension RegexBuilder { } public struct Concatenate_0_5< W0, W1, C0, C1, C2, C3, C4, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple6 { - public typealias Match = Tuple6 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0, C1, C2, C3, C4) { + public typealias Match = (Substring, C0, C1, C2, C3, C4) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -337,8 +163,8 @@ extension RegexBuilder { } public struct Concatenate_0_6< W0, W1, C0, C1, C2, C3, C4, C5, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple7 { - public typealias Match = Tuple7 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0, C1, C2, C3, C4, C5) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -354,8 +180,8 @@ extension RegexBuilder { } public struct Concatenate_0_7< W0, W1, C0, C1, C2, C3, C4, C5, C6, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple8 { - public typealias Match = Tuple8 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0, C1, C2, C3, C4, C5, C6) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -371,8 +197,8 @@ extension RegexBuilder { } public struct Concatenate_0_8< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple9 { - public typealias Match = Tuple9 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0, C1, C2, C3, C4, C5, C6, C7) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -388,8 +214,8 @@ extension RegexBuilder { } public struct Concatenate_0_9< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple10 { - public typealias Match = Tuple10 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0, C1, C2, C3, C4, C5, C6, C7, C8) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -405,8 +231,8 @@ extension RegexBuilder { } public struct Concatenate_0_10< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == W0, R1.Match == Tuple11 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == W0, R1.Match == (W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -420,27 +246,10 @@ extension RegexBuilder { .init(combined, next) } } -public struct Concatenate_1_0< - W0, W1, C0, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == W1 { - public typealias Match = Tuple2 - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) - } -} -extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_1_0 { - .init(combined, next) - } -} public struct Concatenate_1_1< W0, W1, C0, C1, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == Tuple2 { - public typealias Match = Tuple3 +>: RegexProtocol where R0.Match == (W0, C0), R1.Match == (W1, C1) { + public typealias Match = (Substring, C0, C1) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -456,8 +265,8 @@ extension RegexBuilder { } public struct Concatenate_1_2< W0, W1, C0, C1, C2, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == Tuple3 { - public typealias Match = Tuple4 +>: RegexProtocol where R0.Match == (W0, C0), R1.Match == (W1, C1, C2) { + public typealias Match = (Substring, C0, C1, C2) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -473,8 +282,8 @@ extension RegexBuilder { } public struct Concatenate_1_3< W0, W1, C0, C1, C2, C3, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == Tuple4 { - public typealias Match = Tuple5 +>: RegexProtocol where R0.Match == (W0, C0), R1.Match == (W1, C1, C2, C3) { + public typealias Match = (Substring, C0, C1, C2, C3) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -490,8 +299,8 @@ extension RegexBuilder { } public struct Concatenate_1_4< W0, W1, C0, C1, C2, C3, C4, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == Tuple5 { - public typealias Match = Tuple6 +>: RegexProtocol where R0.Match == (W0, C0), R1.Match == (W1, C1, C2, C3, C4) { + public typealias Match = (Substring, C0, C1, C2, C3, C4) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -507,8 +316,8 @@ extension RegexBuilder { } public struct Concatenate_1_5< W0, W1, C0, C1, C2, C3, C4, C5, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == Tuple6 { - public typealias Match = Tuple7 +>: RegexProtocol where R0.Match == (W0, C0), R1.Match == (W1, C1, C2, C3, C4, C5) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -524,8 +333,8 @@ extension RegexBuilder { } public struct Concatenate_1_6< W0, W1, C0, C1, C2, C3, C4, C5, C6, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == Tuple7 { - public typealias Match = Tuple8 +>: RegexProtocol where R0.Match == (W0, C0), R1.Match == (W1, C1, C2, C3, C4, C5, C6) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -541,8 +350,8 @@ extension RegexBuilder { } public struct Concatenate_1_7< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == Tuple8 { - public typealias Match = Tuple9 +>: RegexProtocol where R0.Match == (W0, C0), R1.Match == (W1, C1, C2, C3, C4, C5, C6, C7) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -558,8 +367,8 @@ extension RegexBuilder { } public struct Concatenate_1_8< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == Tuple9 { - public typealias Match = Tuple10 +>: RegexProtocol where R0.Match == (W0, C0), R1.Match == (W1, C1, C2, C3, C4, C5, C6, C7, C8) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -575,8 +384,8 @@ extension RegexBuilder { } public struct Concatenate_1_9< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple2, R1.Match == Tuple10 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == (W0, C0), R1.Match == (W1, C1, C2, C3, C4, C5, C6, C7, C8, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -590,27 +399,10 @@ extension RegexBuilder { .init(combined, next) } } -public struct Concatenate_2_0< - W0, W1, C0, C1, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple3, R1.Match == W1 { - public typealias Match = Tuple3 - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) - } -} -extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_2_0 { - .init(combined, next) - } -} public struct Concatenate_2_1< W0, W1, C0, C1, C2, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple3, R1.Match == Tuple2 { - public typealias Match = Tuple4 +>: RegexProtocol where R0.Match == (W0, C0, C1), R1.Match == (W1, C2) { + public typealias Match = (Substring, C0, C1, C2) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -626,8 +418,8 @@ extension RegexBuilder { } public struct Concatenate_2_2< W0, W1, C0, C1, C2, C3, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple3, R1.Match == Tuple3 { - public typealias Match = Tuple5 +>: RegexProtocol where R0.Match == (W0, C0, C1), R1.Match == (W1, C2, C3) { + public typealias Match = (Substring, C0, C1, C2, C3) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -643,8 +435,8 @@ extension RegexBuilder { } public struct Concatenate_2_3< W0, W1, C0, C1, C2, C3, C4, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple3, R1.Match == Tuple4 { - public typealias Match = Tuple6 +>: RegexProtocol where R0.Match == (W0, C0, C1), R1.Match == (W1, C2, C3, C4) { + public typealias Match = (Substring, C0, C1, C2, C3, C4) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -660,8 +452,8 @@ extension RegexBuilder { } public struct Concatenate_2_4< W0, W1, C0, C1, C2, C3, C4, C5, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple3, R1.Match == Tuple5 { - public typealias Match = Tuple7 +>: RegexProtocol where R0.Match == (W0, C0, C1), R1.Match == (W1, C2, C3, C4, C5) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -677,8 +469,8 @@ extension RegexBuilder { } public struct Concatenate_2_5< W0, W1, C0, C1, C2, C3, C4, C5, C6, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple3, R1.Match == Tuple6 { - public typealias Match = Tuple8 +>: RegexProtocol where R0.Match == (W0, C0, C1), R1.Match == (W1, C2, C3, C4, C5, C6) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -694,8 +486,8 @@ extension RegexBuilder { } public struct Concatenate_2_6< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple3, R1.Match == Tuple7 { - public typealias Match = Tuple9 +>: RegexProtocol where R0.Match == (W0, C0, C1), R1.Match == (W1, C2, C3, C4, C5, C6, C7) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -711,8 +503,8 @@ extension RegexBuilder { } public struct Concatenate_2_7< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple3, R1.Match == Tuple8 { - public typealias Match = Tuple10 +>: RegexProtocol where R0.Match == (W0, C0, C1), R1.Match == (W1, C2, C3, C4, C5, C6, C7, C8) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -728,8 +520,8 @@ extension RegexBuilder { } public struct Concatenate_2_8< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple3, R1.Match == Tuple9 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == (W0, C0, C1), R1.Match == (W1, C2, C3, C4, C5, C6, C7, C8, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -743,27 +535,10 @@ extension RegexBuilder { .init(combined, next) } } -public struct Concatenate_3_0< - W0, W1, C0, C1, C2, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple4, R1.Match == W1 { - public typealias Match = Tuple4 - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) - } -} -extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_3_0 { - .init(combined, next) - } -} public struct Concatenate_3_1< W0, W1, C0, C1, C2, C3, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple4, R1.Match == Tuple2 { - public typealias Match = Tuple5 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2), R1.Match == (W1, C3) { + public typealias Match = (Substring, C0, C1, C2, C3) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -779,8 +554,8 @@ extension RegexBuilder { } public struct Concatenate_3_2< W0, W1, C0, C1, C2, C3, C4, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple4, R1.Match == Tuple3 { - public typealias Match = Tuple6 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2), R1.Match == (W1, C3, C4) { + public typealias Match = (Substring, C0, C1, C2, C3, C4) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -796,8 +571,8 @@ extension RegexBuilder { } public struct Concatenate_3_3< W0, W1, C0, C1, C2, C3, C4, C5, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple4, R1.Match == Tuple4 { - public typealias Match = Tuple7 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2), R1.Match == (W1, C3, C4, C5) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -813,8 +588,8 @@ extension RegexBuilder { } public struct Concatenate_3_4< W0, W1, C0, C1, C2, C3, C4, C5, C6, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple4, R1.Match == Tuple5 { - public typealias Match = Tuple8 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2), R1.Match == (W1, C3, C4, C5, C6) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -830,8 +605,8 @@ extension RegexBuilder { } public struct Concatenate_3_5< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple4, R1.Match == Tuple6 { - public typealias Match = Tuple9 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2), R1.Match == (W1, C3, C4, C5, C6, C7) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -847,8 +622,8 @@ extension RegexBuilder { } public struct Concatenate_3_6< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple4, R1.Match == Tuple7 { - public typealias Match = Tuple10 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2), R1.Match == (W1, C3, C4, C5, C6, C7, C8) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -864,8 +639,8 @@ extension RegexBuilder { } public struct Concatenate_3_7< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple4, R1.Match == Tuple8 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2), R1.Match == (W1, C3, C4, C5, C6, C7, C8, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -879,27 +654,10 @@ extension RegexBuilder { .init(combined, next) } } -public struct Concatenate_4_0< - W0, W1, C0, C1, C2, C3, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple5, R1.Match == W1 { - public typealias Match = Tuple5 - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) - } -} -extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_4_0 { - .init(combined, next) - } -} public struct Concatenate_4_1< W0, W1, C0, C1, C2, C3, C4, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple5, R1.Match == Tuple2 { - public typealias Match = Tuple6 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3), R1.Match == (W1, C4) { + public typealias Match = (Substring, C0, C1, C2, C3, C4) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -915,8 +673,8 @@ extension RegexBuilder { } public struct Concatenate_4_2< W0, W1, C0, C1, C2, C3, C4, C5, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple5, R1.Match == Tuple3 { - public typealias Match = Tuple7 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3), R1.Match == (W1, C4, C5) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -932,8 +690,8 @@ extension RegexBuilder { } public struct Concatenate_4_3< W0, W1, C0, C1, C2, C3, C4, C5, C6, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple5, R1.Match == Tuple4 { - public typealias Match = Tuple8 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3), R1.Match == (W1, C4, C5, C6) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -949,8 +707,8 @@ extension RegexBuilder { } public struct Concatenate_4_4< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple5, R1.Match == Tuple5 { - public typealias Match = Tuple9 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3), R1.Match == (W1, C4, C5, C6, C7) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -966,8 +724,8 @@ extension RegexBuilder { } public struct Concatenate_4_5< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple5, R1.Match == Tuple6 { - public typealias Match = Tuple10 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3), R1.Match == (W1, C4, C5, C6, C7, C8) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -983,8 +741,8 @@ extension RegexBuilder { } public struct Concatenate_4_6< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple5, R1.Match == Tuple7 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3), R1.Match == (W1, C4, C5, C6, C7, C8, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -998,27 +756,10 @@ extension RegexBuilder { .init(combined, next) } } -public struct Concatenate_5_0< - W0, W1, C0, C1, C2, C3, C4, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple6, R1.Match == W1 { - public typealias Match = Tuple6 - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) - } -} -extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_5_0 { - .init(combined, next) - } -} public struct Concatenate_5_1< W0, W1, C0, C1, C2, C3, C4, C5, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple6, R1.Match == Tuple2 { - public typealias Match = Tuple7 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4), R1.Match == (W1, C5) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1034,8 +775,8 @@ extension RegexBuilder { } public struct Concatenate_5_2< W0, W1, C0, C1, C2, C3, C4, C5, C6, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple6, R1.Match == Tuple3 { - public typealias Match = Tuple8 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4), R1.Match == (W1, C5, C6) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1051,8 +792,8 @@ extension RegexBuilder { } public struct Concatenate_5_3< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple6, R1.Match == Tuple4 { - public typealias Match = Tuple9 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4), R1.Match == (W1, C5, C6, C7) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1068,8 +809,8 @@ extension RegexBuilder { } public struct Concatenate_5_4< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple6, R1.Match == Tuple5 { - public typealias Match = Tuple10 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4), R1.Match == (W1, C5, C6, C7, C8) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1085,8 +826,8 @@ extension RegexBuilder { } public struct Concatenate_5_5< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple6, R1.Match == Tuple6 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4), R1.Match == (W1, C5, C6, C7, C8, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1100,27 +841,10 @@ extension RegexBuilder { .init(combined, next) } } -public struct Concatenate_6_0< - W0, W1, C0, C1, C2, C3, C4, C5, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple7, R1.Match == W1 { - public typealias Match = Tuple7 - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) - } -} -extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_6_0 { - .init(combined, next) - } -} public struct Concatenate_6_1< W0, W1, C0, C1, C2, C3, C4, C5, C6, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple7, R1.Match == Tuple2 { - public typealias Match = Tuple8 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5), R1.Match == (W1, C6) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1136,8 +860,8 @@ extension RegexBuilder { } public struct Concatenate_6_2< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple7, R1.Match == Tuple3 { - public typealias Match = Tuple9 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5), R1.Match == (W1, C6, C7) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1153,8 +877,8 @@ extension RegexBuilder { } public struct Concatenate_6_3< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple7, R1.Match == Tuple4 { - public typealias Match = Tuple10 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5), R1.Match == (W1, C6, C7, C8) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1170,8 +894,8 @@ extension RegexBuilder { } public struct Concatenate_6_4< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple7, R1.Match == Tuple5 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5), R1.Match == (W1, C6, C7, C8, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1185,27 +909,10 @@ extension RegexBuilder { .init(combined, next) } } -public struct Concatenate_7_0< - W0, W1, C0, C1, C2, C3, C4, C5, C6, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple8, R1.Match == W1 { - public typealias Match = Tuple8 - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) - } -} -extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_7_0 { - .init(combined, next) - } -} public struct Concatenate_7_1< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple8, R1.Match == Tuple2 { - public typealias Match = Tuple9 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5, C6), R1.Match == (W1, C7) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1221,8 +928,8 @@ extension RegexBuilder { } public struct Concatenate_7_2< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple8, R1.Match == Tuple3 { - public typealias Match = Tuple10 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5, C6), R1.Match == (W1, C7, C8) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1238,8 +945,8 @@ extension RegexBuilder { } public struct Concatenate_7_3< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple8, R1.Match == Tuple4 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5, C6), R1.Match == (W1, C7, C8, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1253,27 +960,10 @@ extension RegexBuilder { .init(combined, next) } } -public struct Concatenate_8_0< - W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple9, R1.Match == W1 { - public typealias Match = Tuple9 - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) - } -} -extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_8_0 { - .init(combined, next) - } -} public struct Concatenate_8_1< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple9, R1.Match == Tuple2 { - public typealias Match = Tuple10 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5, C6, C7), R1.Match == (W1, C8) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1289,8 +979,8 @@ extension RegexBuilder { } public struct Concatenate_8_2< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple9, R1.Match == Tuple3 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5, C6, C7), R1.Match == (W1, C8, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1304,27 +994,10 @@ extension RegexBuilder { .init(combined, next) } } -public struct Concatenate_9_0< - W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple10, R1.Match == W1 { - public typealias Match = Tuple10 - public let regex: Regex - init(_ r0: R0, _ r1: R1) { - self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) - } -} -extension RegexBuilder { - @_disfavoredOverload - public static func buildBlock( - combining next: R1, into combined: R0 - ) -> Concatenate_9_0 { - .init(combined, next) - } -} public struct Concatenate_9_1< W0, W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, R0: RegexProtocol, R1: RegexProtocol ->: RegexProtocol where R0.Match == Tuple10, R1.Match == Tuple2 { - public typealias Match = Tuple11 +>: RegexProtocol where R0.Match == (W0, C0, C1, C2, C3, C4, C5, C6, C7, C8), R1.Match == (W1, C9) { + public typealias Match = (Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) public let regex: Regex init(_ r0: R0, _ r1: R1) { self.regex = .init(node: r0.regex.root.appending(r1.regex.root)) @@ -1339,75 +1012,1047 @@ extension RegexBuilder { } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex where R0.Match == W0, R1.Match: EmptyCaptureProtocol { + ) -> Regex where R0.Match == W0 { .init(node: combined.regex.root.appending(next.regex.root)) } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex> where R0.Match == Tuple2, R1.Match: EmptyCaptureProtocol { + ) -> Regex<(Substring, C0)> where R0.Match == (W0, C0) { .init(node: combined.regex.root.appending(next.regex.root)) } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex> where R0.Match == Tuple3, R1.Match: EmptyCaptureProtocol { + ) -> Regex<(Substring, C0, C1)> where R0.Match == (W0, C0, C1) { .init(node: combined.regex.root.appending(next.regex.root)) } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex> where R0.Match == Tuple4, R1.Match: EmptyCaptureProtocol { + ) -> Regex<(Substring, C0, C1, C2)> where R0.Match == (W0, C0, C1, C2) { .init(node: combined.regex.root.appending(next.regex.root)) } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex> where R0.Match == Tuple5, R1.Match: EmptyCaptureProtocol { + ) -> Regex<(Substring, C0, C1, C2, C3)> where R0.Match == (W0, C0, C1, C2, C3) { .init(node: combined.regex.root.appending(next.regex.root)) } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex> where R0.Match == Tuple6, R1.Match: EmptyCaptureProtocol { + ) -> Regex<(Substring, C0, C1, C2, C3, C4)> where R0.Match == (W0, C0, C1, C2, C3, C4) { .init(node: combined.regex.root.appending(next.regex.root)) } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex> where R0.Match == Tuple7, R1.Match: EmptyCaptureProtocol { + ) -> Regex<(Substring, C0, C1, C2, C3, C4, C5)> where R0.Match == (W0, C0, C1, C2, C3, C4, C5) { .init(node: combined.regex.root.appending(next.regex.root)) } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex> where R0.Match == Tuple8, R1.Match: EmptyCaptureProtocol { + ) -> Regex<(Substring, C0, C1, C2, C3, C4, C5, C6)> where R0.Match == (W0, C0, C1, C2, C3, C4, C5, C6) { .init(node: combined.regex.root.appending(next.regex.root)) } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex> where R0.Match == Tuple9, R1.Match: EmptyCaptureProtocol { + ) -> Regex<(Substring, C0, C1, C2, C3, C4, C5, C6, C7)> where R0.Match == (W0, C0, C1, C2, C3, C4, C5, C6, C7) { .init(node: combined.regex.root.appending(next.regex.root)) } } extension RegexBuilder { + @_disfavoredOverload public static func buildBlock( combining next: R1, into combined: R0 - ) -> Regex> where R0.Match == Tuple10, R1.Match: EmptyCaptureProtocol { + ) -> Regex<(Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8)> where R0.Match == (W0, C0, C1, C2, C3, C4, C5, C6, C7, C8) { .init(node: combined.regex.root.appending(next.regex.root)) } } -// END AUTO-GENERATED CONTENT \ No newline at end of file +public struct _ZeroOrOne_0: RegexProtocol { + public typealias Match = Substring + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + +@_disfavoredOverload +public func optionally( + _ component: Component +) -> _ZeroOrOne_0 { + .init(component: component) +} + +@_disfavoredOverload +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_0 { + optionally(component()) +} + +@_disfavoredOverload +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_0 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_0 { + optionally(component) + } +} +public struct _ZeroOrMore_0: RegexProtocol { + public typealias Match = Substring + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + +@_disfavoredOverload +public func many( + _ component: Component +) -> _ZeroOrMore_0 { + .init(component: component) +} + +@_disfavoredOverload +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_0 { + many(component()) +} + +@_disfavoredOverload +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_0 { + many(component) +} + + +public struct _OneOrMore_0: RegexProtocol { + public typealias Match = Substring + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + +@_disfavoredOverload +public func oneOrMore( + _ component: Component +) -> _OneOrMore_0 { + .init(component: component) +} + +@_disfavoredOverload +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_0 { + oneOrMore(component()) +} + +@_disfavoredOverload +public postfix func .*( + _ component: Component +) -> _OneOrMore_0 { + oneOrMore(component) +} + + +public struct _ZeroOrOne_1: RegexProtocol where Component.Match == (W, C0) { + public typealias Match = (Substring, C0?) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + + +public func optionally( + _ component: Component +) -> _ZeroOrOne_1 { + .init(component: component) +} + + +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_1 { + optionally(component()) +} + + +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_1 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_1 { + optionally(component) + } +} +public struct _ZeroOrMore_1: RegexProtocol where Component.Match == (W, C0) { + public typealias Match = (Substring, [C0]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + + +public func many( + _ component: Component +) -> _ZeroOrMore_1 { + .init(component: component) +} + + +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_1 { + many(component()) +} + + +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_1 { + many(component) +} + + +public struct _OneOrMore_1: RegexProtocol where Component.Match == (W, C0) { + public typealias Match = (Substring, [C0]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + + +public func oneOrMore( + _ component: Component +) -> _OneOrMore_1 { + .init(component: component) +} + + +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_1 { + oneOrMore(component()) +} + + +public postfix func .*( + _ component: Component +) -> _OneOrMore_1 { + oneOrMore(component) +} + + +public struct _ZeroOrOne_2: RegexProtocol where Component.Match == (W, C0, C1) { + public typealias Match = (Substring, (C0, C1)?) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + + +public func optionally( + _ component: Component +) -> _ZeroOrOne_2 { + .init(component: component) +} + + +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_2 { + optionally(component()) +} + + +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_2 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_2 { + optionally(component) + } +} +public struct _ZeroOrMore_2: RegexProtocol where Component.Match == (W, C0, C1) { + public typealias Match = (Substring, [(C0, C1)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + + +public func many( + _ component: Component +) -> _ZeroOrMore_2 { + .init(component: component) +} + + +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_2 { + many(component()) +} + + +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_2 { + many(component) +} + + +public struct _OneOrMore_2: RegexProtocol where Component.Match == (W, C0, C1) { + public typealias Match = (Substring, [(C0, C1)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + + +public func oneOrMore( + _ component: Component +) -> _OneOrMore_2 { + .init(component: component) +} + + +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_2 { + oneOrMore(component()) +} + + +public postfix func .*( + _ component: Component +) -> _OneOrMore_2 { + oneOrMore(component) +} + + +public struct _ZeroOrOne_3: RegexProtocol where Component.Match == (W, C0, C1, C2) { + public typealias Match = (Substring, (C0, C1, C2)?) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + + +public func optionally( + _ component: Component +) -> _ZeroOrOne_3 { + .init(component: component) +} + + +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_3 { + optionally(component()) +} + + +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_3 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_3 { + optionally(component) + } +} +public struct _ZeroOrMore_3: RegexProtocol where Component.Match == (W, C0, C1, C2) { + public typealias Match = (Substring, [(C0, C1, C2)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + + +public func many( + _ component: Component +) -> _ZeroOrMore_3 { + .init(component: component) +} + + +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_3 { + many(component()) +} + + +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_3 { + many(component) +} + + +public struct _OneOrMore_3: RegexProtocol where Component.Match == (W, C0, C1, C2) { + public typealias Match = (Substring, [(C0, C1, C2)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + + +public func oneOrMore( + _ component: Component +) -> _OneOrMore_3 { + .init(component: component) +} + + +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_3 { + oneOrMore(component()) +} + + +public postfix func .*( + _ component: Component +) -> _OneOrMore_3 { + oneOrMore(component) +} + + +public struct _ZeroOrOne_4: RegexProtocol where Component.Match == (W, C0, C1, C2, C3) { + public typealias Match = (Substring, (C0, C1, C2, C3)?) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + + +public func optionally( + _ component: Component +) -> _ZeroOrOne_4 { + .init(component: component) +} + + +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_4 { + optionally(component()) +} + + +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_4 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_4 { + optionally(component) + } +} +public struct _ZeroOrMore_4: RegexProtocol where Component.Match == (W, C0, C1, C2, C3) { + public typealias Match = (Substring, [(C0, C1, C2, C3)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + + +public func many( + _ component: Component +) -> _ZeroOrMore_4 { + .init(component: component) +} + + +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_4 { + many(component()) +} + + +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_4 { + many(component) +} + + +public struct _OneOrMore_4: RegexProtocol where Component.Match == (W, C0, C1, C2, C3) { + public typealias Match = (Substring, [(C0, C1, C2, C3)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + + +public func oneOrMore( + _ component: Component +) -> _OneOrMore_4 { + .init(component: component) +} + + +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_4 { + oneOrMore(component()) +} + + +public postfix func .*( + _ component: Component +) -> _OneOrMore_4 { + oneOrMore(component) +} + + +public struct _ZeroOrOne_5: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4) { + public typealias Match = (Substring, (C0, C1, C2, C3, C4)?) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + + +public func optionally( + _ component: Component +) -> _ZeroOrOne_5 { + .init(component: component) +} + + +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_5 { + optionally(component()) +} + + +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_5 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_5 { + optionally(component) + } +} +public struct _ZeroOrMore_5: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + + +public func many( + _ component: Component +) -> _ZeroOrMore_5 { + .init(component: component) +} + + +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_5 { + many(component()) +} + + +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_5 { + many(component) +} + + +public struct _OneOrMore_5: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + + +public func oneOrMore( + _ component: Component +) -> _OneOrMore_5 { + .init(component: component) +} + + +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_5 { + oneOrMore(component()) +} + + +public postfix func .*( + _ component: Component +) -> _OneOrMore_5 { + oneOrMore(component) +} + + +public struct _ZeroOrOne_6: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5) { + public typealias Match = (Substring, (C0, C1, C2, C3, C4, C5)?) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + + +public func optionally( + _ component: Component +) -> _ZeroOrOne_6 { + .init(component: component) +} + + +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_6 { + optionally(component()) +} + + +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_6 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_6 { + optionally(component) + } +} +public struct _ZeroOrMore_6: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4, C5)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + + +public func many( + _ component: Component +) -> _ZeroOrMore_6 { + .init(component: component) +} + + +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_6 { + many(component()) +} + + +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_6 { + many(component) +} + + +public struct _OneOrMore_6: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4, C5)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + + +public func oneOrMore( + _ component: Component +) -> _OneOrMore_6 { + .init(component: component) +} + + +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_6 { + oneOrMore(component()) +} + + +public postfix func .*( + _ component: Component +) -> _OneOrMore_6 { + oneOrMore(component) +} + + +public struct _ZeroOrOne_7: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5, C6) { + public typealias Match = (Substring, (C0, C1, C2, C3, C4, C5, C6)?) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + + +public func optionally( + _ component: Component +) -> _ZeroOrOne_7 { + .init(component: component) +} + + +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_7 { + optionally(component()) +} + + +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_7 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_7 { + optionally(component) + } +} +public struct _ZeroOrMore_7: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5, C6) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4, C5, C6)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + + +public func many( + _ component: Component +) -> _ZeroOrMore_7 { + .init(component: component) +} + + +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_7 { + many(component()) +} + + +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_7 { + many(component) +} + + +public struct _OneOrMore_7: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5, C6) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4, C5, C6)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + + +public func oneOrMore( + _ component: Component +) -> _OneOrMore_7 { + .init(component: component) +} + + +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_7 { + oneOrMore(component()) +} + + +public postfix func .*( + _ component: Component +) -> _OneOrMore_7 { + oneOrMore(component) +} + + +public struct _ZeroOrOne_8: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5, C6, C7) { + public typealias Match = (Substring, (C0, C1, C2, C3, C4, C5, C6, C7)?) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + + +public func optionally( + _ component: Component +) -> _ZeroOrOne_8 { + .init(component: component) +} + + +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_8 { + optionally(component()) +} + + +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_8 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_8 { + optionally(component) + } +} +public struct _ZeroOrMore_8: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5, C6, C7) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4, C5, C6, C7)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + + +public func many( + _ component: Component +) -> _ZeroOrMore_8 { + .init(component: component) +} + + +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_8 { + many(component()) +} + + +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_8 { + many(component) +} + + +public struct _OneOrMore_8: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5, C6, C7) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4, C5, C6, C7)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + + +public func oneOrMore( + _ component: Component +) -> _OneOrMore_8 { + .init(component: component) +} + + +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_8 { + oneOrMore(component()) +} + + +public postfix func .*( + _ component: Component +) -> _OneOrMore_8 { + oneOrMore(component) +} + + +public struct _ZeroOrOne_9: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8) { + public typealias Match = (Substring, (C0, C1, C2, C3, C4, C5, C6, C7, C8)?) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) + } +} + + +public func optionally( + _ component: Component +) -> _ZeroOrOne_9 { + .init(component: component) +} + + +public func optionally( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrOne_9 { + optionally(component()) +} + + +public postfix func .?( + _ component: Component +) -> _ZeroOrOne_9 { + optionally(component) +} + +extension RegexBuilder { + public static func buildLimitedAvailability( + _ component: Component + ) -> _ZeroOrOne_9 { + optionally(component) + } +} +public struct _ZeroOrMore_9: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4, C5, C6, C7, C8)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) + } +} + + +public func many( + _ component: Component +) -> _ZeroOrMore_9 { + .init(component: component) +} + + +public func many( + @RegexBuilder _ component: () -> Component +) -> _ZeroOrMore_9 { + many(component()) +} + + +public postfix func .+( + _ component: Component +) -> _ZeroOrMore_9 { + many(component) +} + + +public struct _OneOrMore_9: RegexProtocol where Component.Match == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8) { + public typealias Match = (Substring, [(C0, C1, C2, C3, C4, C5, C6, C7, C8)]) + public let regex: Regex + public init(component: Component) { + self.regex = .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) + } +} + + +public func oneOrMore( + _ component: Component +) -> _OneOrMore_9 { + .init(component: component) +} + + +public func oneOrMore( + @RegexBuilder _ component: () -> Component +) -> _OneOrMore_9 { + oneOrMore(component()) +} + + +public postfix func .*( + _ component: Component +) -> _OneOrMore_9 { + oneOrMore(component) +} + + + + +// END AUTO-GENERATED CONTENT diff --git a/Sources/_StringProcessing/RegexDSL/Core.swift b/Sources/_StringProcessing/RegexDSL/Core.swift index bcdf96c5d..f161ee227 100644 --- a/Sources/_StringProcessing/RegexDSL/Core.swift +++ b/Sources/_StringProcessing/RegexDSL/Core.swift @@ -23,34 +23,12 @@ public struct RegexMatch { /// A type that represents a regular expression. public protocol RegexProtocol { - associatedtype Match: MatchProtocol + associatedtype Match var regex: Regex { get } } -/// A `RegexProtocol` that has a single component child. -/// -/// This protocol adds an init supporting static lookup for character classes -public protocol RegexProtocolWithComponent: RegexProtocol { - associatedtype Component: RegexProtocol - - // Label needed for disambiguation - init(component: Component) -} -extension RegexProtocolWithComponent -where Component == CharacterClass { - // This gives us static member lookup - public init(_ component: Component) { - self.init(component: component) - } -} -extension RegexProtocolWithComponent { - public init(_ component: Component) { - self.init(component: component) - } -} - /// A regular expression. -public struct Regex: RegexProtocol { +public struct Regex: RegexProtocol { /// A program representation that caches any lowered representation for /// execution. internal class Program { @@ -167,10 +145,8 @@ extension RegexProtocol { return nil } let convertedMatch: Match - if Match.self == Tuple2.self { - convertedMatch = Tuple2( - input[range], DynamicCaptures(captures) - ) as! Match + if Match.self == (Substring, DynamicCaptures).self { + convertedMatch = (input[range], DynamicCaptures(captures)) as! Match } else { let typeErasedMatch = captures.matchValue( withWholeMatch: input[range] @@ -187,10 +163,8 @@ extension RegexProtocol { return nil } let convertedMatch: Match - if Match.self == Tuple2.self { - convertedMatch = Tuple2( - input[result.range], DynamicCaptures.empty - ) as! Match + if Match.self == (Substring, DynamicCaptures).self { + convertedMatch = (input[result.range], DynamicCaptures.empty) as! Match } else { assert(Match.self == Substring.self) convertedMatch = input[result.range] as! Match @@ -221,7 +195,7 @@ extension Substring { match(content()) } } -public struct MockRegexLiteral: RegexProtocol { +public struct MockRegexLiteral: RegexProtocol { public typealias MatchValue = Substring public let regex: Regex @@ -241,16 +215,3 @@ public func r( } fileprivate typealias DefaultEngine = TortoiseVM - -public protocol EmptyCaptureProtocol {} -public struct EmptyCapture: EmptyCaptureProtocol {} -extension Array: EmptyCaptureProtocol where Element: EmptyCaptureProtocol {} -extension Optional: EmptyCaptureProtocol where Wrapped: EmptyCaptureProtocol {} - -public protocol MatchProtocol { - associatedtype Capture -} -extension Substring: MatchProtocol { - public typealias Capture = EmptyCapture -} - diff --git a/Sources/_StringProcessing/RegexDSL/DSL.swift b/Sources/_StringProcessing/RegexDSL/DSL.swift index d90af6db8..a2daf579e 100644 --- a/Sources/_StringProcessing/RegexDSL/DSL.swift +++ b/Sources/_StringProcessing/RegexDSL/DSL.swift @@ -14,7 +14,6 @@ import _MatchingEngine // MARK: - Primitives extension String: RegexProtocol { - public typealias Capture = EmptyCapture public typealias Match = Substring public var regex: Regex { @@ -24,7 +23,6 @@ extension String: RegexProtocol { } extension Character: RegexProtocol { - public typealias Capture = EmptyCapture public typealias Match = Substring public var regex: Regex { @@ -33,7 +31,6 @@ extension Character: RegexProtocol { } extension CharacterClass: RegexProtocol { - public typealias Capture = EmptyCapture public typealias Match = Substring public var regex: Regex { @@ -46,97 +43,81 @@ extension CharacterClass: RegexProtocol { // MARK: - Combinators -// TODO: We want variadic generics! -// Overloads are auto-generated in Concatenation.swift. -// -// public struct Concatenate: RegexContent { -// public let regex: Regex<(R...).filter { $0 != Void.self }> -// -// public init(_ components: R...) { -// regex = .init(ast: .concatenation([#splat(components...)])) -// } -// } +// MARK: Concatenation -// MARK: Repetition +// Note: Concatenation overloads are currently gyb'd. -/// A regular expression. -public struct OneOrMore: RegexProtocolWithComponent { - public typealias Match = Tuple2 +// TODO: Variadic generics +// struct Concatenation +// where R0.Match == (W0, C0...), R1.Match == (W1, C1...) +// { +// typealias Match = (Substring, C0..., C1...) +// let regex: Regex +// init(_ first: R0, _ second: R1) { +// regex = .init(concat(r0, r1)) +// } +// } - public let regex: Regex +// MARK: Quantification - public init(component: Component) { - self.regex = .init(node: .quantification( - .oneOrMore, .eager, component.regex.root) - ) - } +// Note: Quantifiers are currently gyb'd. - public init(@RegexBuilder _ content: () -> Component) { - self.init(content()) - } -} +// TODO: Variadic generics +// struct _OneOrMore +// where R.Match == (W, C...) +// { +// typealias Match = (Substring, [(C...)]) +// let regex: Regex +// init(_ component: Component) { +// regex = .init(oneOrMore(r0)) +// } +// } +// +// struct _OneOrMoreNonCapturing { +// typealias Match = Substring +// let regex: Regex +// init(_ component: Component) { +// regex = .init(oneOrMore(r0)) +// } +// } +// +// func oneOrMore( +// _ component: Component +// ) -> R { +// _OneOrMore(component) +// } +// +// @_disfavoredOverload +// func oneOrMore( +// _ component: Component +// ) -> R { +// _OneOrMoreNonCapturing(component) +// } +postfix operator .? +postfix operator .* postfix operator .+ -public postfix func .+ ( - lhs: R -) -> OneOrMore { - .init(lhs) -} - -public struct Repeat< - Component: RegexProtocol ->: RegexProtocolWithComponent { - public typealias Match = Tuple2 - - public let regex: Regex - - public init(component: Component) { - self.regex = .init(node: .quantification( - .zeroOrMore, .eager, component.regex.root)) - } - - public init(@RegexBuilder _ content: () -> Component) { - self.init(content()) - } +// Overloads for quantifying over a character class. +public func zeroOrOne(_ cc: CharacterClass) -> _ZeroOrOne_0 { + .init(component: cc) } -postfix operator .* - -public postfix func .* ( - lhs: R -) -> Repeat { - .init(lhs) +public func many(_ cc: CharacterClass) -> _ZeroOrMore_0 { + .init(component: cc) } -public struct Optionally: RegexProtocolWithComponent { - public typealias Match = Tuple2 - - public let regex: Regex - - public init(component: Component) { - self.regex = .init(node: .quantification( - .zeroOrOne, .eager, component.regex.root)) - } - - public init(@RegexBuilder _ content: () -> Component) { - self.init(content()) - } +public func oneOrMore(_ cc: CharacterClass) -> _OneOrMore_0 { + .init(component: cc) } -postfix operator .? - -public postfix func .? ( - lhs: R -) -> Optionally { - .init(lhs) -} +// MARK: Alternation // TODO: Support heterogeneous capture alternation. public struct Alternation< Component1: RegexProtocol, Component2: RegexProtocol ->: RegexProtocol where Component1.Match.Capture == Component2.Match.Capture { - public typealias Match = Tuple2 +>: RegexProtocol { + public typealias Match = Component1.Match public let regex: Regex @@ -161,7 +142,7 @@ public func | ( // MARK: - Capture -public struct CapturingGroup: RegexProtocol { +public struct CapturingGroup: RegexProtocol { public let regex: Regex init( diff --git a/Sources/_StringProcessing/RegexDSL/DSLCapture.swift b/Sources/_StringProcessing/RegexDSL/DSLCapture.swift index 4d2dba9a3..05d974239 100644 --- a/Sources/_StringProcessing/RegexDSL/DSLCapture.swift +++ b/Sources/_StringProcessing/RegexDSL/DSLCapture.swift @@ -10,93 +10,97 @@ //===----------------------------------------------------------------------===// extension RegexProtocol { - public func capture() -> CapturingGroup> where Match.Capture: EmptyCaptureProtocol { + @_disfavoredOverload + public func capture() -> CapturingGroup<(Substring, Substring)> { .init(self) } + @_disfavoredOverload public func capture( _ transform: @escaping (Substring) -> NewCapture - ) -> CapturingGroup> where Match.Capture: EmptyCaptureProtocol { + ) -> CapturingGroup<(Substring, NewCapture)> { .init(self, transform: transform) } + @_disfavoredOverload public func tryCapture( _ transform: @escaping (Substring) throws -> NewCapture - ) -> CapturingGroup> where Match.Capture: EmptyCaptureProtocol { + ) -> CapturingGroup<(Substring, NewCapture)> { .init(self, transform: transform) } + @_disfavoredOverload public func tryCapture( _ transform: @escaping (Substring) -> NewCapture? - ) -> CapturingGroup> where Match.Capture: EmptyCaptureProtocol { + ) -> CapturingGroup<(Substring, NewCapture)> { .init(self, transform: transform) } - public func capture() -> CapturingGroup> - where Match.Capture == C0 { + public func capture() -> CapturingGroup<(Substring, Substring, C0)> + where Match == (W, C0) { .init(self) } - public func capture( + public func capture( _ transform: @escaping (Substring) -> NewCapture - ) -> CapturingGroup> where Match.Capture == C0 { + ) -> CapturingGroup<(Substring, NewCapture, C0)> where Match == (W, C0) { .init(self, transform: transform) } - public func tryCapture( + public func tryCapture( _ transform: @escaping (Substring) throws -> NewCapture - ) -> CapturingGroup> where Match.Capture == C0 { + ) -> CapturingGroup<(Substring, NewCapture, C0)> where Match == (W, C0) { .init(self, transform: transform) } - public func tryCapture( + public func tryCapture( _ transform: @escaping (Substring) -> NewCapture? - ) -> CapturingGroup> where Match.Capture == C0 { + ) -> CapturingGroup<(Substring, NewCapture, C0)> where Match == (W, C0) { .init(self, transform: transform) } - public func capture() -> CapturingGroup> where Match.Capture == Tuple2 { + public func capture() -> CapturingGroup<(Substring, Substring, C0, C1)> where Match == (W, C0, C1) { .init(self) } - public func capture( + public func capture( _ transform: @escaping (Substring) -> NewCapture - ) -> CapturingGroup> where Match.Capture == Tuple2 { + ) -> CapturingGroup<(Substring, NewCapture, C0, C1)> where Match == (W, C0, C1) { .init(self, transform: transform) } - public func tryCapture( + public func tryCapture( _ transform: @escaping (Substring) throws -> NewCapture - ) -> CapturingGroup> where Match.Capture == Tuple2 { + ) -> CapturingGroup<(Substring, NewCapture, C0, C1)> where Match == (W, C0, C1) { .init(self, transform: transform) } - public func tryCapture( + public func tryCapture( _ transform: @escaping (Substring) -> NewCapture? - ) -> CapturingGroup> where Match.Capture == Tuple2 { + ) -> CapturingGroup<(Substring, NewCapture, C0, C1)> where Match == (W, C0, C1) { .init(self, transform: transform) } - public func capture() -> CapturingGroup> - where Match.Capture == Tuple3 { + public func capture() -> CapturingGroup<(Substring, Substring, C0, C1, C2)> + where Match == (W, C0, C1, C2) { .init(self) } - public func capture( + public func capture( _ transform: @escaping (Substring) -> NewCapture - ) -> CapturingGroup> where Match.Capture == Tuple3 { + ) -> CapturingGroup<(Substring, NewCapture, C0, C1, C2)> where Match == (W, C0, C1, C2) { .init(self, transform: transform) } - public func tryCapture( + public func tryCapture( _ transform: @escaping (Substring) throws -> NewCapture - ) -> CapturingGroup> where Match.Capture == Tuple3 { + ) -> CapturingGroup<(Substring, NewCapture, C0, C1, C2)> where Match == (W, C0, C1, C2) { .init(self, transform: transform) } - public func tryCapture( + public func tryCapture( _ transform: @escaping (Substring) -> NewCapture? - ) -> CapturingGroup> where Match.Capture == Tuple3 { + ) -> CapturingGroup<(Substring, NewCapture, C0, C1, C2)> where Match == (W, C0, C1, C2) { .init(self, transform: transform) } } diff --git a/Sources/_StringProcessing/RegexDSL/DynamicCaptures.swift b/Sources/_StringProcessing/RegexDSL/DynamicCaptures.swift index 18f0b31a1..dadd6339f 100644 --- a/Sources/_StringProcessing/RegexDSL/DynamicCaptures.swift +++ b/Sources/_StringProcessing/RegexDSL/DynamicCaptures.swift @@ -11,7 +11,7 @@ import _MatchingEngine -extension Regex where Match == Tuple2 { +extension Regex where Match == (Substring, DynamicCaptures) { public init(_ pattern: String) throws { self.init(ast: try parse(pattern, .traditional)) } diff --git a/Tests/RegexTests/AlgorithmsTests.swift b/Tests/RegexTests/AlgorithmsTests.swift index 5a848a6e4..8041214b0 100644 --- a/Tests/RegexTests/AlgorithmsTests.swift +++ b/Tests/RegexTests/AlgorithmsTests.swift @@ -116,7 +116,7 @@ class RegexConsumerTests: XCTestCase { } func testMatches() { - let regex = Regex(OneOrMore(.digit).capture { 2 * Int($0)! }) + let regex = Regex(oneOrMore(.digit).capture { 2 * Int($0)! }) let str = "foo 160 bar 99 baz" XCTAssertEqual(str.matches(of: regex).map(\.result.1), [320, 198]) } @@ -133,7 +133,7 @@ class RegexConsumerTests: XCTestCase { XCTAssertEqual(input.replacing(regex, with: replace), result) } - let int = OneOrMore(.digit).capture { Int($0)! } + let int = oneOrMore(.digit).capture { Int($0)! } replaceTest( int, @@ -148,13 +148,13 @@ class RegexConsumerTests: XCTestCase { { match in "\(match.result.1 + match.result.2)" }) replaceTest( - OneOrMore { int; "," }, + oneOrMore { int; "," }, input: "3,5,8,0, 1,0,2,-5,x8,8,", result: "16 3-5x16", { match in "\(match.result.1.reduce(0, +))" }) replaceTest( - Regex { int; "x"; int; Optionally { "x"; int } }, + Regex { int; "x"; int; optionally { "x"; int } }, input: "2x3 5x4x3 6x0 1x2x3x4", result: "6 60 0 6x4", { match in "\(match.result.1 * match.result.2 * (match.result.3 ?? 1))" }) diff --git a/Tests/RegexTests/RegexDSLTests.swift b/Tests/RegexTests/RegexDSLTests.swift index 629e91240..1e803396d 100644 --- a/Tests/RegexTests/RegexDSLTests.swift +++ b/Tests/RegexTests/RegexDSLTests.swift @@ -20,15 +20,14 @@ class RegexDSLTests: XCTestCase { "1".tryCapture { Int($0) } // Int } // Assert the inferred capture type. - let _: Tuple3.Type = type(of: regex).Match.self + let _: (Substring, Substring, Int).Type = type(of: regex).Match.self let maybeMatch = "ab1".match(regex) let match = try XCTUnwrap(maybeMatch) - XCTAssertEqual(match.match, Tuple3("ab1", "b", 1)) + XCTAssertTrue(match.match == ("ab1", "b", 1)) let substring = "ab1"[...] - let substringMatch = try XCTUnwrap( - substring.match(regex)) - XCTAssertEqual(match.match, substringMatch.match) + let substringMatch = try XCTUnwrap(substring.match(regex)) + XCTAssertTrue(match.match == substringMatch.match) } func testCharacterClasses() throws { @@ -38,43 +37,43 @@ class RegexDSLTests: XCTestCase { "c".capture() // Substring } // Assert the inferred capture type. - let _: Tuple3.Type = type(of: regex).Match.self + let _: (Substring, Substring, Substring).Type = type(of: regex).Match.self let maybeMatch = "a c".match(regex) let match = try XCTUnwrap(maybeMatch) - XCTAssertTrue(match.match == Tuple3("a c", " ", "c")) + XCTAssertTrue(match.match == ("a c", " ", "c")) } func testCombinators() throws { let regex = Regex { "a".+ - OneOrMore(Character("b")).capture() // Substring - Repeat("c").capture() // Substring + oneOrMore(Character("b")).capture() // Substring + many("c").capture() // Substring CharacterClass.hexDigit.capture().* // [Substring] "e".? ("t" | "k").capture() // Substring } // Assert the inferred capture type. - let _: Tuple5.Type + let _: (Substring, Substring, Substring, [Substring], Substring).Type = type(of: regex).Match.self let maybeMatch = "aaaabccccdddk".match(regex) let match = try XCTUnwrap(maybeMatch) XCTAssertTrue( match.match - == Tuple5("aaaabccccdddk", "b", "cccc", ["d", "d", "d"], "k")) + == ("aaaabccccdddk", "b", "cccc", ["d", "d", "d"], "k")) } func testNestedGroups() throws { let regex = Regex { "a".+ - OneOrMore { - OneOrMore("b").capture() - Repeat("c").capture() + oneOrMore { + oneOrMore("b").capture() + many("c").capture() "d".capture().* "e".? } } // Assert the inferred capture type. - let _: Tuple2]>.Type + let _: (Substring, [(Substring, Substring, [Substring])]).Type = type(of: regex).Match.self let maybeMatch = "aaaabccccddd".match(regex) let match = try XCTUnwrap(maybeMatch) @@ -82,7 +81,20 @@ class RegexDSLTests: XCTestCase { XCTAssertEqual(match.match.0, "aaaabccccddd") XCTAssertTrue( match.match.1[0] - == Tuple3("b", "cccc", ["d", "d", "d"])) + == ("b", "cccc", ["d", "d", "d"])) + } + + func testCapturelessQuantification() throws { + // This test is to make sure that a captureless quantification, when used + // straight out of the quantifier (without being wrapped in a builder), is + // able to produce a regex whose `Match` type does not contain any sort of + // void. + let regex = many(.digit) + // Assert the inferred capture type. + let _: Substring.Type = type(of: regex).Match.self + let input = "123123" + let match = try XCTUnwrap(input.match(regex)?.match) + XCTAssertTrue(match == input) } func testQuantificationWithTransformedCapture() throws { @@ -104,21 +116,20 @@ class RegexDSLTests: XCTestCase { } let regex = Regex { "a".+ - OneOrMore(.whitespace) - Optionally { - OneOrMore(.digit).capture { Int($0)! } + oneOrMore(.whitespace) + optionally { + oneOrMore(.digit).capture { Int($0)! } } - Repeat { - OneOrMore(.whitespace) - OneOrMore(.word).capture { Word($0)! } + many { + oneOrMore(.whitespace) + oneOrMore(.word).capture { Word($0)! } } } // Assert the inferred capture type. - let _: Tuple3.Type - = type(of: regex).Match.self + let _: (Substring, Int?, [Word]).Type = type(of: regex).Match.self do { let input = "aaa 123 apple orange apple" - let match = input.match(regex)?.match.tuple + let match = input.match(regex)?.match let (whole, number, words) = try XCTUnwrap(match) XCTAssertTrue(whole == input) XCTAssertEqual(number, 123) @@ -126,7 +137,7 @@ class RegexDSLTests: XCTestCase { } do { let input = "aaa " - let match = input.match(regex)?.match.tuple + let match = input.match(regex)?.match let (whole, number, words) = try XCTUnwrap(match) XCTAssertTrue(whole == input) XCTAssertEqual(number, nil) @@ -138,11 +149,11 @@ class RegexDSLTests: XCTestCase { let regex1 = Regex { "a".+ Regex { - OneOrMore("b").capture() + oneOrMore("b").capture() "e".? }.capture() } - let _: Tuple3.Type + let _: (Substring, Substring, Substring).Type = type(of: regex1).Match.self let regex2 = Regex { "a".+ @@ -151,7 +162,7 @@ class RegexDSLTests: XCTestCase { "e".? }.capture() } - let _: Tuple3.Type + let _: (Substring, Substring, [Int]).Type = type(of: regex2).Match.self let regex3 = Regex { "a".+ @@ -161,31 +172,31 @@ class RegexDSLTests: XCTestCase { "e".? }.capture() } - let _: Tuple4.Type + let _: (Substring, Substring, Int, [Double]).Type = type(of: regex3).Match.self let regex4 = Regex { "a".+ - OneOrMore { - OneOrMore("b").capture() - Repeat("c").capture() + oneOrMore { + oneOrMore("b").capture() + many("c").capture() "d".capture().* "e".? }.capture() } - let _: Tuple3< - Substring, Substring, [Tuple3]>.Type + let _: ( + Substring, Substring, [(Substring, Substring, [Substring])]).Type = type(of: regex4).Match.self } func testUnicodeScalarPostProcessing() throws { let spaces = Regex { - Repeat { + many { CharacterClass.whitespace } } let unicodeScalar = Regex { - OneOrMore { + oneOrMore { CharacterClass.hexDigit } spaces @@ -193,7 +204,7 @@ class RegexDSLTests: XCTestCase { let unicodeData = Regex { unicodeScalar - Optionally { + optionally { ".." unicodeScalar } @@ -201,17 +212,17 @@ class RegexDSLTests: XCTestCase { ";" spaces - OneOrMore { + oneOrMore { CharacterClass.word }.capture() - Repeat { + many { CharacterClass.any } } // Assert the inferred capture type. - let _: Tuple2.Type = type(of: unicodeData).Match.self + let _: (Substring, Substring).Type = type(of: unicodeData).Match.self let unicodeLine = "1BCA0..1BCA3 ; Control # Cf [4] SHORTHAND FORMAT LETTER OVERLAP..SHORTHAND FORMAT UP STEP" @@ -226,26 +237,26 @@ class RegexDSLTests: XCTestCase { """ let regexWithCapture = Regex { - OneOrMore(CharacterClass.hexDigit).capture(Unicode.Scalar.init(hex:)) - Optionally { + oneOrMore(CharacterClass.hexDigit).capture(Unicode.Scalar.init(hex:)) + optionally { ".." - OneOrMore(CharacterClass.hexDigit).capture(Unicode.Scalar.init(hex:)) + oneOrMore(CharacterClass.hexDigit).capture(Unicode.Scalar.init(hex:)) } - OneOrMore(CharacterClass.whitespace) + oneOrMore(CharacterClass.whitespace) ";" - OneOrMore(CharacterClass.whitespace) - OneOrMore(CharacterClass.word).capture() - Repeat(CharacterClass.any) + oneOrMore(CharacterClass.whitespace) + oneOrMore(CharacterClass.word).capture() + many(CharacterClass.any) } // Regex<(Substring, Unicode.Scalar?, Unicode.Scalar??, Substring)> do { // Assert the inferred capture type. - typealias ExpectedMatch = Tuple4< + typealias ExpectedMatch = ( Substring, Unicode.Scalar?, Unicode.Scalar??, Substring - > + ) let _: ExpectedMatch.Type = type(of: regexWithCapture).Match.self let maybeMatchResult = line.match(regexWithCapture) let matchResult = try XCTUnwrap(maybeMatchResult) - let (wholeMatch, lower, upper, propertyString) = matchResult.match.tuple + let (wholeMatch, lower, upper, propertyString) = matchResult.match XCTAssertEqual(wholeMatch, Substring(line)) XCTAssertEqual(lower, Unicode.Scalar(0xA6F0)) XCTAssertEqual(upper, Unicode.Scalar(0xA6F1)) @@ -253,26 +264,26 @@ class RegexDSLTests: XCTestCase { } let regexWithTryCapture = Regex { - OneOrMore(CharacterClass.hexDigit).tryCapture(Unicode.Scalar.init(hex:)) - Optionally { + oneOrMore(CharacterClass.hexDigit).tryCapture(Unicode.Scalar.init(hex:)) + optionally { ".." - OneOrMore(CharacterClass.hexDigit).tryCapture(Unicode.Scalar.init(hex:)) + oneOrMore(CharacterClass.hexDigit).tryCapture(Unicode.Scalar.init(hex:)) } - OneOrMore(CharacterClass.whitespace) + oneOrMore(CharacterClass.whitespace) ";" - OneOrMore(CharacterClass.whitespace) - OneOrMore(CharacterClass.word).capture() - Repeat(CharacterClass.any) + oneOrMore(CharacterClass.whitespace) + oneOrMore(CharacterClass.word).capture() + many(CharacterClass.any) } // Regex<(Substring, Unicode.Scalar, Unicode.Scalar?, Substring)> do { // Assert the inferred capture type. - typealias ExpectedMatch = Tuple4< + typealias ExpectedMatch = ( Substring, Unicode.Scalar, Unicode.Scalar?, Substring - > + ) let _: ExpectedMatch.Type = type(of: regexWithTryCapture).Match.self let maybeMatchResult = line.match(regexWithTryCapture) let matchResult = try XCTUnwrap(maybeMatchResult) - let (wholeMatch, lower, upper, propertyString) = matchResult.match.tuple + let (wholeMatch, lower, upper, propertyString) = matchResult.match XCTAssertEqual(wholeMatch, Substring(line)) XCTAssertEqual(lower, Unicode.Scalar(0xA6F0)) XCTAssertEqual(upper, Unicode.Scalar(0xA6F1)) @@ -282,10 +293,10 @@ class RegexDSLTests: XCTestCase { do { let regexLiteral = try MockRegexLiteral( #"([0-9A-F]+)(?:\.\.([0-9A-F]+))?\s+;\s+(\w+).*"#, - matching: Tuple4.self) + matching: (Substring, Substring, Substring?, Substring).self) let maybeMatchResult = line.match(regexLiteral) let matchResult = try XCTUnwrap(maybeMatchResult) - let (wholeMatch, lower, upper, propertyString) = matchResult.match.tuple + let (wholeMatch, lower, upper, propertyString) = matchResult.match XCTAssertEqual(wholeMatch, Substring(line)) XCTAssertEqual(lower, "A6F0") XCTAssertEqual(upper, "A6F1")