diff --git a/Package.swift b/Package.swift index 71641ae28..e95d98b67 100644 --- a/Package.swift +++ b/Package.swift @@ -14,8 +14,8 @@ let package = Package( name: "Prototypes", targets: ["Prototypes"]), .library( - name: "_MatchingEngine", - targets: ["_MatchingEngine"]), + name: "_RegexParser", + targets: ["_RegexParser"]), .executable( name: "VariadicsGenerator", targets: ["VariadicsGenerator"]) @@ -27,7 +27,7 @@ let package = Package( // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( - name: "_MatchingEngine", + name: "_RegexParser", dependencies: [], swiftSettings: [ .unsafeFlags(["-enable-library-evolution"]) @@ -35,19 +35,19 @@ let package = Package( .testTarget( name: "MatchingEngineTests", dependencies: [ - "_MatchingEngine", "_StringProcessing"]), + "_RegexParser", "_StringProcessing"]), .target( name: "_CUnicode", dependencies: []), .target( name: "_StringProcessing", - dependencies: ["_MatchingEngine", "_CUnicode"], + dependencies: ["_RegexParser", "_CUnicode"], swiftSettings: [ .unsafeFlags(["-enable-library-evolution"]), ]), .target( name: "RegexBuilder", - dependencies: ["_StringProcessing", "_MatchingEngine"], + dependencies: ["_StringProcessing", "_RegexParser"], swiftSettings: [ .unsafeFlags(["-enable-library-evolution"]), .unsafeFlags(["-Xfrontend", "-enable-experimental-pairwise-build-block"]) @@ -63,7 +63,7 @@ let package = Package( ]), .target( name: "Prototypes", - dependencies: ["_MatchingEngine", "_StringProcessing"]), + dependencies: ["_RegexParser", "_StringProcessing"]), // MARK: Scripts .executableTarget( @@ -75,14 +75,14 @@ let package = Package( name: "PatternConverter", dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), - "_MatchingEngine", + "_RegexParser", "_StringProcessing" ]), // MARK: Exercises .target( name: "Exercises", - dependencies: ["_MatchingEngine", "Prototypes", "_StringProcessing", "RegexBuilder"], + dependencies: ["_RegexParser", "Prototypes", "_StringProcessing", "RegexBuilder"], swiftSettings: [ .unsafeFlags(["-Xfrontend", "-enable-experimental-pairwise-build-block"]) ]), diff --git a/README.md b/README.md index 69c545243..e8a6e387e 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ See [Declarative String Processing Overview][decl-string] ## Integration with Swift -`_MatchingEngine`, `_CUnicode` and `_StringProcessing` are specially integrated modules that are built as part of apple/swift. +`_RegexParser` and `_StringProcessing` are specially integrated modules that are built as part of apple/swift. -Specifically, `_MatchingEngine` contains the parser for regular expression literals and is built both as part of the compiler and as a core library. `_CUnicode` and `_StringProcessing` are built together as a core library named `_StringProcessing`. +Specifically, `_RegexParser` contains the parser for regular expression literals and is built both as part of the compiler and as a core library. `_CUnicode` and `_StringProcessing` are built together as a core library named `_StringProcessing`. | Module | Swift toolchain component | | ------------------- | ------------------------------------------------------------------------------------ | -| `_MatchingEngine` | `SwiftCompilerSources/Sources/ExperimentalRegex` and `stdlib/public/_MatchingEngine` | +| `_RegexParser` | `SwiftCompilerSources/Sources/_RegexParser` and `stdlib/public/_RegexParser` | | `_CUnicode` | `stdlib/public/_StringProcessing` | | `_StringProcessing` | `stdlib/public/_StringProcessing` | @@ -65,10 +65,9 @@ To integrate the latest changes in apple/swift-experimental-string-processing to ### Development notes -Compiler integration can be tricky. Use special caution when developing `_MatchingEngine`, `_CUnicode` and `_StringProcessing` modules. +Compiler integration can be tricky. Use special caution when developing `_RegexParser` and `_StringProcessing` modules. - Do not change the names of these modules without due approval from compiler and infrastructure teams. - Do not modify the existing ABI (e.g. C API, serialization format) between the regular expression parser and the Swift compiler unless absolutely necessary. - Always minimize the number of lockstep integrations, i.e. when apple/swift-experimental-string-processing and apple/swift have to change together. Whenever possible, introduce new API first, migrate Swift compiler onto it, and then deprecate old API. Use versioning if helpful. - In `_StringProcessing`, do not write fully qualified references to symbols in `_CUnicode`, and always wrap `import _CUnicode` in a `#if canImport(_CUnicode)`. This is because `_CUnicode` is built as part of `_StringProcessing` with CMake. -- In `_MatchingEngine`, do not write fully qualified references to `_MatchingEngine` itself. This is because `_MatchingEngine` is built as `ExperimentalRegex` in `SwiftCompilerSources/` with CMake. diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 19feadbd9..7b4e5e3ed 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -1,6 +1,6 @@ -add_subdirectory(_Unicode) -add_subdirectory(_MatchingEngine) +add_subdirectory(RegexBuilder) +add_subdirectory(_RegexParser) add_subdirectory(_StringProcessing) add_subdirectory(Prototypes) add_subdirectory(VariadicsGenerator) diff --git a/Sources/Exercises/Participant.swift b/Sources/Exercises/Participant.swift index 2f7ec183b..ad20d7fbd 100644 --- a/Sources/Exercises/Participant.swift +++ b/Sources/Exercises/Participant.swift @@ -29,22 +29,25 @@ public protocol Participant { // ... } +// Errors that may be thrown from default implementations +private enum ParticipantError: Error { + case unsupported +} + // Default impls extension Participant { - static var unsupported: Error { "Unsupported" } - // Produce a function that will parse a grapheme break entry from a line public static func graphemeBreakProperty() throws -> (String) -> GraphemeBreakEntry? { - throw unsupported + throw ParticipantError.unsupported } // Produce a function that will extract the bodies of C-style comments from its input public static func cComments() throws -> (String) -> [Substring] { - throw unsupported + throw ParticipantError.unsupported } // Produce a function that will extract the bodies of Swift-style comments from its input public static func swiftComments() throws -> (String) -> [Substring] { - throw unsupported + throw ParticipantError.unsupported } } diff --git a/Sources/PatternConverter/PatternConverter.swift b/Sources/PatternConverter/PatternConverter.swift index 32a4bd8e9..ff47e4be2 100644 --- a/Sources/PatternConverter/PatternConverter.swift +++ b/Sources/PatternConverter/PatternConverter.swift @@ -12,7 +12,7 @@ // swift run PatternConverter import ArgumentParser -import _MatchingEngine +import _RegexParser import _StringProcessing @main @@ -52,7 +52,7 @@ struct PatternConverter: ParsableCommand { let delim = experimentalSyntax ? "|" : "/" print("Converting '\(delim)\(regex)\(delim)'") - let ast = try _MatchingEngine.parse( + let ast = try _RegexParser.parse( regex, experimentalSyntax ? .experimental : .traditional) diff --git a/Sources/Prototypes/CMakeLists.txt b/Sources/Prototypes/CMakeLists.txt index 60768f5a3..f9532c54d 100644 --- a/Sources/Prototypes/CMakeLists.txt +++ b/Sources/Prototypes/CMakeLists.txt @@ -15,4 +15,4 @@ add_library(Prototypes TourOfTypes/CharacterClass.swift TourOfTypes/Literal.swift) target_link_libraries(Prototypes PUBLIC - _MatchingEngine) + _RegexParser) diff --git a/Sources/Prototypes/Combinators/Combinators.swift b/Sources/Prototypes/Combinators/Combinators.swift index eddef70b0..448110c95 100644 --- a/Sources/Prototypes/Combinators/Combinators.swift +++ b/Sources/Prototypes/Combinators/Combinators.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser /* diff --git a/Sources/RegexBuilder/Anchor.swift b/Sources/RegexBuilder/Anchor.swift index ea2dde382..ba910bd30 100644 --- a/Sources/RegexBuilder/Anchor.swift +++ b/Sources/RegexBuilder/Anchor.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser @_spi(RegexBuilder) import _StringProcessing public struct Anchor { @@ -107,16 +107,26 @@ extension Anchor { } } -public func lookahead( - negative: Bool = false, - @RegexComponentBuilder _ content: () -> R -) -> Regex { - Regex(node: .nonCapturingGroup(negative ? .negativeLookahead : .lookahead, content().regex.root)) -} - -public func lookahead( - _ component: R, - negative: Bool = false -) -> Regex { - Regex(node: .nonCapturingGroup(negative ? .negativeLookahead : .lookahead, component.regex.root)) +public struct Lookahead: _BuiltinRegexComponent { + public var regex: Regex + + init(_ regex: Regex) { + self.regex = regex + } + + public init( + _ component: R, + negative: Bool = false + ) where R.Output == Output { + self.init(node: .nonCapturingGroup( + negative ? .negativeLookahead : .lookahead, component.regex.root)) + } + + public init( + negative: Bool = false, + @RegexComponentBuilder _ component: () -> R + ) where R.Output == Output { + self.init(node: .nonCapturingGroup( + negative ? .negativeLookahead : .lookahead, component().regex.root)) + } } diff --git a/Sources/RegexBuilder/CMakeLists.txt b/Sources/RegexBuilder/CMakeLists.txt new file mode 100644 index 000000000..c2a0d9738 --- /dev/null +++ b/Sources/RegexBuilder/CMakeLists.txt @@ -0,0 +1,10 @@ + +add_library(RegexBuilder + Anchor.swift + Builder.swift + DSL.swift + Match.swift + Variadics.swift) +target_compile_options(RegexBuilder PRIVATE + -enable-library-evolution + -Xfrontend -enable-experimental-pairwise-build-block) diff --git a/Sources/RegexBuilder/DSL.swift b/Sources/RegexBuilder/DSL.swift index 816668b67..457439a43 100644 --- a/Sources/RegexBuilder/DSL.swift +++ b/Sources/RegexBuilder/DSL.swift @@ -9,14 +9,14 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser @_spi(RegexBuilder) import _StringProcessing extension Regex { public init( @RegexComponentBuilder _ content: () -> Content ) where Content.Output == Output { - self.init(content()) + self = content().regex } } @@ -165,10 +165,6 @@ public struct Repeat: _BuiltinRegexComponent { // Variadics.swift. } -postfix operator .? -postfix operator .* -postfix operator .+ - // MARK: Alternation // TODO: Variadic generics diff --git a/Sources/RegexBuilder/Variadics.swift b/Sources/RegexBuilder/Variadics.swift index 60292252a..f59b1f13a 100644 --- a/Sources/RegexBuilder/Variadics.swift +++ b/Sources/RegexBuilder/Variadics.swift @@ -11,7 +11,7 @@ // BEGIN AUTO-GENERATED CONTENT -import _MatchingEngine +import _RegexParser @_spi(RegexBuilder) import _StringProcessing extension RegexComponentBuilder { @@ -498,13 +498,6 @@ extension Optionally { } } -@_disfavoredOverload -public postfix func .?( - _ component: Component -) -> Optionally { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -532,13 +525,6 @@ extension ZeroOrMore { } } -@_disfavoredOverload -public postfix func .*( - _ component: Component -) -> ZeroOrMore { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { @_disfavoredOverload @@ -560,13 +546,6 @@ extension OneOrMore { } } -@_disfavoredOverload -public postfix func .+( - _ component: Component -) -> OneOrMore { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { @_disfavoredOverload @@ -625,12 +604,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?)> where Component.Output == (W, C0) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -656,12 +629,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?)> where Component.Output == (W, C0) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -681,12 +648,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0)> where Component.Output == (W, C0) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -741,12 +702,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?, C1?)> where Component.Output == (W, C0, C1) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -772,12 +727,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?, C1?)> where Component.Output == (W, C0, C1) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -797,12 +746,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0, C1)> where Component.Output == (W, C0, C1) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -857,12 +800,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?, C1?, C2?)> where Component.Output == (W, C0, C1, C2) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -888,12 +825,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?, C1?, C2?)> where Component.Output == (W, C0, C1, C2) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -913,12 +844,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0, C1, C2)> where Component.Output == (W, C0, C1, C2) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -973,12 +898,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?, C1?, C2?, C3?)> where Component.Output == (W, C0, C1, C2, C3) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -1004,12 +923,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?, C1?, C2?, C3?)> where Component.Output == (W, C0, C1, C2, C3) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -1029,12 +942,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0, C1, C2, C3)> where Component.Output == (W, C0, C1, C2, C3) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -1089,12 +996,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?, C1?, C2?, C3?, C4?)> where Component.Output == (W, C0, C1, C2, C3, C4) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -1120,12 +1021,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?, C1?, C2?, C3?, C4?)> where Component.Output == (W, C0, C1, C2, C3, C4) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -1145,12 +1040,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0, C1, C2, C3, C4)> where Component.Output == (W, C0, C1, C2, C3, C4) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -1205,12 +1094,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?, C1?, C2?, C3?, C4?, C5?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -1236,12 +1119,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?, C1?, C2?, C3?, C4?, C5?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -1261,12 +1138,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0, C1, C2, C3, C4, C5)> where Component.Output == (W, C0, C1, C2, C3, C4, C5) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -1321,12 +1192,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -1352,12 +1217,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -1377,12 +1236,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0, C1, C2, C3, C4, C5, C6)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -1437,12 +1290,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?, C7?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6, C7) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -1468,12 +1315,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?, C7?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6, C7) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -1493,12 +1334,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0, C1, C2, C3, C4, C5, C6, C7)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6, C7) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -1553,12 +1388,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -1584,12 +1413,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -1609,12 +1432,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -1669,12 +1486,6 @@ extension Optionally { } } -public postfix func .?( - _ component: Component -) -> Optionally<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) { - .init(node: .quantification(.zeroOrOne, .eager, component.regex.root)) -} - extension RegexComponentBuilder { public static func buildLimitedAvailability( _ component: Component @@ -1700,12 +1511,6 @@ extension ZeroOrMore { } } -public postfix func .*( - _ component: Component -) -> ZeroOrMore<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) { - .init(node: .quantification(.zeroOrMore, .eager, component.regex.root)) -} - extension OneOrMore { public init( @@ -1725,12 +1530,6 @@ extension OneOrMore { } } -public postfix func .+( - _ component: Component -) -> OneOrMore<(Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)> where Component.Output == (W, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) { - .init(node: .quantification(.oneOrMore, .eager, component.regex.root)) -} - extension Repeat { public init( @@ -1774,10 +1573,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf where R0: RegexComponent, R1: RegexComponent { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1785,10 +1580,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1796,10 +1587,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?, C1?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0, C1) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1807,10 +1594,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?, C1?, C2?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0, C1, C2) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1818,10 +1601,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?, C1?, C2?, C3?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0, C1, C2, C3) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1829,10 +1608,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?, C1?, C2?, C3?, C4?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0, C1, C2, C3, C4) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1840,10 +1615,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?, C1?, C2?, C3?, C4?, C5?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0, C1, C2, C3, C4, C5) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1851,10 +1622,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0, C1, C2, C3, C4, C5, C6) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1862,10 +1629,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?, C7?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0, C1, C2, C3, C4, C5, C6, C7) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1873,10 +1636,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0, C1, C2, C3, C4, C5, C6, C7, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1884,10 +1643,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0?, C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?)> where R0: RegexComponent, R1: RegexComponent, R1.Output == (W1, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1895,10 +1650,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1906,10 +1657,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0), R1.Output == (W1, C1) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1917,10 +1664,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1?, C2?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0), R1.Output == (W1, C1, C2) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1928,10 +1671,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1?, C2?, C3?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0), R1.Output == (W1, C1, C2, C3) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1939,10 +1678,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1?, C2?, C3?, C4?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0), R1.Output == (W1, C1, C2, C3, C4) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1950,10 +1685,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1?, C2?, C3?, C4?, C5?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0), R1.Output == (W1, C1, C2, C3, C4, C5) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1961,10 +1692,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1?, C2?, C3?, C4?, C5?, C6?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0), R1.Output == (W1, C1, C2, C3, C4, C5, C6) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1972,10 +1699,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1?, C2?, C3?, C4?, C5?, C6?, C7?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0), R1.Output == (W1, C1, C2, C3, C4, C5, C6, C7) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1983,10 +1706,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0), R1.Output == (W1, C1, C2, C3, C4, C5, C6, C7, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -1994,10 +1713,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0), R1.Output == (W1, C1, C2, C3, C4, C5, C6, C7, C8, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2005,10 +1720,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2016,10 +1727,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1), R1.Output == (W1, C2) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2027,10 +1734,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2?, C3?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1), R1.Output == (W1, C2, C3) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2038,10 +1741,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2?, C3?, C4?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1), R1.Output == (W1, C2, C3, C4) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2049,10 +1748,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2?, C3?, C4?, C5?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1), R1.Output == (W1, C2, C3, C4, C5) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2060,10 +1755,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2?, C3?, C4?, C5?, C6?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1), R1.Output == (W1, C2, C3, C4, C5, C6) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2071,10 +1762,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2?, C3?, C4?, C5?, C6?, C7?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1), R1.Output == (W1, C2, C3, C4, C5, C6, C7) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2082,10 +1769,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2?, C3?, C4?, C5?, C6?, C7?, C8?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1), R1.Output == (W1, C2, C3, C4, C5, C6, C7, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2093,10 +1776,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1), R1.Output == (W1, C2, C3, C4, C5, C6, C7, C8, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2104,10 +1783,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2115,10 +1790,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2), R1.Output == (W1, C3) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2126,10 +1797,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3?, C4?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2), R1.Output == (W1, C3, C4) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2137,10 +1804,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3?, C4?, C5?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2), R1.Output == (W1, C3, C4, C5) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2148,10 +1811,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3?, C4?, C5?, C6?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2), R1.Output == (W1, C3, C4, C5, C6) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2159,10 +1818,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3?, C4?, C5?, C6?, C7?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2), R1.Output == (W1, C3, C4, C5, C6, C7) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2170,10 +1825,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3?, C4?, C5?, C6?, C7?, C8?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2), R1.Output == (W1, C3, C4, C5, C6, C7, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2181,10 +1832,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3?, C4?, C5?, C6?, C7?, C8?, C9?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2), R1.Output == (W1, C3, C4, C5, C6, C7, C8, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2192,10 +1839,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2203,10 +1846,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3), R1.Output == (W1, C4) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2214,10 +1853,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4?, C5?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3), R1.Output == (W1, C4, C5) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2225,10 +1860,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4?, C5?, C6?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3), R1.Output == (W1, C4, C5, C6) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2236,10 +1867,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4?, C5?, C6?, C7?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3), R1.Output == (W1, C4, C5, C6, C7) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2247,10 +1874,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4?, C5?, C6?, C7?, C8?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3), R1.Output == (W1, C4, C5, C6, C7, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2258,10 +1881,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4?, C5?, C6?, C7?, C8?, C9?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3), R1.Output == (W1, C4, C5, C6, C7, C8, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2269,10 +1888,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2280,10 +1895,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4), R1.Output == (W1, C5) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2291,10 +1902,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5?, C6?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4), R1.Output == (W1, C5, C6) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2302,10 +1909,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5?, C6?, C7?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4), R1.Output == (W1, C5, C6, C7) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2313,10 +1916,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5?, C6?, C7?, C8?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4), R1.Output == (W1, C5, C6, C7, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2324,10 +1923,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5?, C6?, C7?, C8?, C9?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4), R1.Output == (W1, C5, C6, C7, C8, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2335,10 +1930,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2346,10 +1937,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5), R1.Output == (W1, C6) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2357,10 +1944,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6?, C7?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5), R1.Output == (W1, C6, C7) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2368,10 +1951,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6?, C7?, C8?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5), R1.Output == (W1, C6, C7, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2379,10 +1958,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6?, C7?, C8?, C9?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5), R1.Output == (W1, C6, C7, C8, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2390,10 +1965,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5, C6) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2401,10 +1972,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6, C7?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5, C6), R1.Output == (W1, C7) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2412,10 +1979,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6, C7?, C8?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5, C6), R1.Output == (W1, C7, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2423,10 +1986,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6, C7?, C8?, C9?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5, C6), R1.Output == (W1, C7, C8, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2434,10 +1993,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6, C7)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5, C6, C7) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2445,10 +2000,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5, C6, C7), R1.Output == (W1, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2456,10 +2007,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8?, C9?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5, C6, C7), R1.Output == (W1, C8, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2467,10 +2014,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5, C6, C7, C8) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock( accumulated: R0, next: R1 @@ -2478,10 +2021,6 @@ extension AlternationBuilder { .init(node: accumulated.regex.root.appendingAlternationCase(next.regex.root)) } } - -public func | (lhs: R0, rhs: R1) -> ChoiceOf<(Substring, C0, C1, C2, C3, C4, C5, C6, C7, C8, C9?)> where R0: RegexComponent, R1: RegexComponent, R0.Output == (W0, C0, C1, C2, C3, C4, C5, C6, C7, C8), R1.Output == (W1, C9) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) -} extension AlternationBuilder { public static func buildPartialBlock(first regex: R) -> ChoiceOf<(W, C0?)> where R: RegexComponent, R.Output == (W, C0) { .init(node: .orderedChoice([regex.regex.root])) diff --git a/Sources/VariadicsGenerator/VariadicsGenerator.swift b/Sources/VariadicsGenerator/VariadicsGenerator.swift index 1f41e68d6..ff406e9fb 100644 --- a/Sources/VariadicsGenerator/VariadicsGenerator.swift +++ b/Sources/VariadicsGenerator/VariadicsGenerator.swift @@ -120,7 +120,7 @@ struct VariadicsGenerator: ParsableCommand { // BEGIN AUTO-GENERATED CONTENT - import _MatchingEngine + import _RegexParser @_spi(RegexBuilder) import _StringProcessing @@ -380,13 +380,6 @@ struct VariadicsGenerator: ParsableCommand { } } - \(params.disfavored)\ - public postfix func \(kind.operatorName)<\(params.genericParams)>( - _ component: Component - ) -> \(kind.rawValue)<\(params.matchType)> \(params.whereClause) { - .init(node: .quantification(.\(kind.astQuantifierAmount), .eager, component.regex.root)) - } - \(kind == .zeroOrOne ? """ extension \(concatBuilderName) { @@ -499,10 +492,6 @@ struct VariadicsGenerator: ParsableCommand { } } - public func | <\(genericParams)>(lhs: R0, rhs: R1) -> ChoiceOf<\(matchType)> \(whereClause) { - .init(node: lhs.regex.root.appendingAlternationCase(rhs.regex.root)) - } - """) } diff --git a/Sources/_MatchingEngine/CMakeLists.txt b/Sources/_MatchingEngine/CMakeLists.txt deleted file mode 100644 index f7cb97ce3..000000000 --- a/Sources/_MatchingEngine/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ - -add_library(_MatchingEngine - Engine/Backtracking.swift - Engine/Builder.swift - Engine/Capture.swift - Engine/Consume.swift - Engine/Engine.swift - Engine/InstPayload.swift - Engine/Instruction.swift - Engine/Processor.swift - Engine/Program.swift - Engine/Registers.swift - Engine/Tracing.swift - Regex/AST/AST.swift - Regex/AST/ASTAction.swift - Regex/AST/ASTProtocols.swift - Regex/AST/Atom.swift - Regex/AST/Conditional.swift - Regex/AST/CustomCharClass.swift - Regex/AST/Group.swift - Regex/AST/MatchingOptions.swift - Regex/AST/Quantification.swift - Regex/Parse/CaptureStructure.swift - Regex/Parse/CharacterPropertyClassification.swift - Regex/Parse/Diagnostics.swift - Regex/Parse/LexicalAnalysis.swift - Regex/Parse/Mocking.swift - Regex/Parse/Parse.swift - Regex/Parse/Source.swift - Regex/Parse/SourceLocation.swift - Regex/Parse/SyntaxOptions.swift - Regex/Printing/DumpAST.swift - Regex/Printing/PrettyPrinter.swift - Regex/Printing/PrintAsCanonical.swift - Regex/Printing/PrintAsPattern.swift - Regex/Printing/RenderRanges.swift - Utility/AllScalars.swift - Utility/Formatting.swift - Utility/Misc.swift - Utility/MissingUnicode.swift - Utility/Protocols.swift - Utility/TypeConstruction.swift - Utility/TypedIndex.swift - Utility/TypedInt.swift) -target_compile_options(_MatchingEngine PRIVATE - -enable-library-evolution) diff --git a/Sources/_RegexParser/CMakeLists.txt b/Sources/_RegexParser/CMakeLists.txt new file mode 100644 index 000000000..48856b453 --- /dev/null +++ b/Sources/_RegexParser/CMakeLists.txt @@ -0,0 +1,28 @@ + +add_library(_RegexParser + AST/AST.swift + AST/ASTAction.swift + AST/ASTProtocols.swift + AST/Atom.swift + AST/Conditional.swift + AST/CustomCharClass.swift + AST/Group.swift + AST/MatchingOptions.swift + AST/Quantification.swift + Parse/CaptureStructure.swift + Parse/CharacterPropertyClassification.swift + Parse/DelimiterLexing.swift + Parse/Diagnostics.swift + Parse/LexicalAnalysis.swift + Parse/Mocking.swift + Parse/Parse.swift + Parse/Source.swift + Parse/SourceLocation.swift + Parse/SyntaxOptions.swift + Printing/DumpAST.swift + Printing/PrettyPrinter.swift + Printing/PrintAsCanonical.swift + Printing/RenderRanges.swift + TreeProtocols.swift) +target_compile_options(_RegexParser PRIVATE + -enable-library-evolution) diff --git a/Sources/_MatchingEngine/Regex/AST/AST.swift b/Sources/_RegexParser/Regex/AST/AST.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/AST/AST.swift rename to Sources/_RegexParser/Regex/AST/AST.swift diff --git a/Sources/_MatchingEngine/Regex/AST/ASTAction.swift b/Sources/_RegexParser/Regex/AST/ASTAction.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/AST/ASTAction.swift rename to Sources/_RegexParser/Regex/AST/ASTAction.swift diff --git a/Sources/_MatchingEngine/Regex/AST/ASTProtocols.swift b/Sources/_RegexParser/Regex/AST/ASTProtocols.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/AST/ASTProtocols.swift rename to Sources/_RegexParser/Regex/AST/ASTProtocols.swift diff --git a/Sources/_MatchingEngine/Regex/AST/Atom.swift b/Sources/_RegexParser/Regex/AST/Atom.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/AST/Atom.swift rename to Sources/_RegexParser/Regex/AST/Atom.swift diff --git a/Sources/_MatchingEngine/Regex/AST/Conditional.swift b/Sources/_RegexParser/Regex/AST/Conditional.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/AST/Conditional.swift rename to Sources/_RegexParser/Regex/AST/Conditional.swift diff --git a/Sources/_MatchingEngine/Regex/AST/CustomCharClass.swift b/Sources/_RegexParser/Regex/AST/CustomCharClass.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/AST/CustomCharClass.swift rename to Sources/_RegexParser/Regex/AST/CustomCharClass.swift diff --git a/Sources/_MatchingEngine/Regex/AST/Group.swift b/Sources/_RegexParser/Regex/AST/Group.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/AST/Group.swift rename to Sources/_RegexParser/Regex/AST/Group.swift diff --git a/Sources/_MatchingEngine/Regex/AST/MatchingOptions.swift b/Sources/_RegexParser/Regex/AST/MatchingOptions.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/AST/MatchingOptions.swift rename to Sources/_RegexParser/Regex/AST/MatchingOptions.swift diff --git a/Sources/_MatchingEngine/Regex/AST/Quantification.swift b/Sources/_RegexParser/Regex/AST/Quantification.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/AST/Quantification.swift rename to Sources/_RegexParser/Regex/AST/Quantification.swift diff --git a/Sources/_MatchingEngine/Regex/Parse/CaptureStructure.swift b/Sources/_RegexParser/Regex/Parse/CaptureStructure.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Parse/CaptureStructure.swift rename to Sources/_RegexParser/Regex/Parse/CaptureStructure.swift diff --git a/Sources/_MatchingEngine/Regex/Parse/CharacterPropertyClassification.swift b/Sources/_RegexParser/Regex/Parse/CharacterPropertyClassification.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Parse/CharacterPropertyClassification.swift rename to Sources/_RegexParser/Regex/Parse/CharacterPropertyClassification.swift diff --git a/Sources/_MatchingEngine/Regex/Parse/DelimiterLexing.swift b/Sources/_RegexParser/Regex/Parse/DelimiterLexing.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Parse/DelimiterLexing.swift rename to Sources/_RegexParser/Regex/Parse/DelimiterLexing.swift diff --git a/Sources/_MatchingEngine/Regex/Parse/Diagnostics.swift b/Sources/_RegexParser/Regex/Parse/Diagnostics.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Parse/Diagnostics.swift rename to Sources/_RegexParser/Regex/Parse/Diagnostics.swift diff --git a/Sources/_MatchingEngine/Regex/Parse/LexicalAnalysis.swift b/Sources/_RegexParser/Regex/Parse/LexicalAnalysis.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Parse/LexicalAnalysis.swift rename to Sources/_RegexParser/Regex/Parse/LexicalAnalysis.swift diff --git a/Sources/_MatchingEngine/Regex/Parse/Mocking.swift b/Sources/_RegexParser/Regex/Parse/Mocking.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Parse/Mocking.swift rename to Sources/_RegexParser/Regex/Parse/Mocking.swift diff --git a/Sources/_MatchingEngine/Regex/Parse/Parse.swift b/Sources/_RegexParser/Regex/Parse/Parse.swift similarity index 98% rename from Sources/_MatchingEngine/Regex/Parse/Parse.swift rename to Sources/_RegexParser/Regex/Parse/Parse.swift index e7b687912..296956fdc 100644 --- a/Sources/_MatchingEngine/Regex/Parse/Parse.swift +++ b/Sources/_RegexParser/Regex/Parse/Parse.swift @@ -122,15 +122,6 @@ extension ParsingContext { // Diagnostics extension Parser { - mutating func report( - _ str: String, _ function: String = #function, _ line: Int = #line - ) throws -> Never { - throw """ - ERROR: \(str) - (error detected in parser at \(function):\(line)) - """ - } - fileprivate func loc( _ start: Source.Position ) -> SourceLocation { @@ -529,5 +520,3 @@ public func parseWithDelimiters( let (contents, delim) = droppingRegexDelimiters(String(regex)) return try parse(contents, delim.defaultSyntaxOptions) } - -extension String: Error {} diff --git a/Sources/_MatchingEngine/Regex/Parse/Source.swift b/Sources/_RegexParser/Regex/Parse/Source.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Parse/Source.swift rename to Sources/_RegexParser/Regex/Parse/Source.swift diff --git a/Sources/_MatchingEngine/Regex/Parse/SourceLocation.swift b/Sources/_RegexParser/Regex/Parse/SourceLocation.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Parse/SourceLocation.swift rename to Sources/_RegexParser/Regex/Parse/SourceLocation.swift diff --git a/Sources/_MatchingEngine/Regex/Parse/SyntaxOptions.swift b/Sources/_RegexParser/Regex/Parse/SyntaxOptions.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Parse/SyntaxOptions.swift rename to Sources/_RegexParser/Regex/Parse/SyntaxOptions.swift diff --git a/Sources/_MatchingEngine/Regex/Printing/DumpAST.swift b/Sources/_RegexParser/Regex/Printing/DumpAST.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Printing/DumpAST.swift rename to Sources/_RegexParser/Regex/Printing/DumpAST.swift diff --git a/Sources/_MatchingEngine/Regex/Printing/PrettyPrinter.swift b/Sources/_RegexParser/Regex/Printing/PrettyPrinter.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Printing/PrettyPrinter.swift rename to Sources/_RegexParser/Regex/Printing/PrettyPrinter.swift diff --git a/Sources/_MatchingEngine/Regex/Printing/PrintAsCanonical.swift b/Sources/_RegexParser/Regex/Printing/PrintAsCanonical.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Printing/PrintAsCanonical.swift rename to Sources/_RegexParser/Regex/Printing/PrintAsCanonical.swift diff --git a/Sources/_MatchingEngine/Regex/Printing/RenderRanges.swift b/Sources/_RegexParser/Regex/Printing/RenderRanges.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/Printing/RenderRanges.swift rename to Sources/_RegexParser/Regex/Printing/RenderRanges.swift diff --git a/Sources/_MatchingEngine/Regex/TreeProtocols.swift b/Sources/_RegexParser/Regex/TreeProtocols.swift similarity index 100% rename from Sources/_MatchingEngine/Regex/TreeProtocols.swift rename to Sources/_RegexParser/Regex/TreeProtocols.swift diff --git a/Sources/_MatchingEngine/Utility/AllScalars.swift b/Sources/_RegexParser/Utility/AllScalars.swift similarity index 100% rename from Sources/_MatchingEngine/Utility/AllScalars.swift rename to Sources/_RegexParser/Utility/AllScalars.swift diff --git a/Sources/_MatchingEngine/Utility/Errors.swift b/Sources/_RegexParser/Utility/Errors.swift similarity index 100% rename from Sources/_MatchingEngine/Utility/Errors.swift rename to Sources/_RegexParser/Utility/Errors.swift diff --git a/Sources/_MatchingEngine/Utility/Misc.swift b/Sources/_RegexParser/Utility/Misc.swift similarity index 100% rename from Sources/_MatchingEngine/Utility/Misc.swift rename to Sources/_RegexParser/Utility/Misc.swift diff --git a/Sources/_MatchingEngine/Utility/MissingUnicode.swift b/Sources/_RegexParser/Utility/MissingUnicode.swift similarity index 100% rename from Sources/_MatchingEngine/Utility/MissingUnicode.swift rename to Sources/_RegexParser/Utility/MissingUnicode.swift diff --git a/Sources/_MatchingEngine/Utility/TypeConstruction.swift b/Sources/_RegexParser/Utility/TypeConstruction.swift similarity index 100% rename from Sources/_MatchingEngine/Utility/TypeConstruction.swift rename to Sources/_RegexParser/Utility/TypeConstruction.swift diff --git a/Sources/_StringProcessing/ByteCodeGen.swift b/Sources/_StringProcessing/ByteCodeGen.swift index c9599b925..d03a1e382 100644 --- a/Sources/_StringProcessing/ByteCodeGen.swift +++ b/Sources/_StringProcessing/ByteCodeGen.swift @@ -1,4 +1,4 @@ -import _MatchingEngine +import _RegexParser extension Compiler { struct ByteCodeGen { diff --git a/Sources/_StringProcessing/CMakeLists.txt b/Sources/_StringProcessing/CMakeLists.txt index c20dcc240..963b6074c 100644 --- a/Sources/_StringProcessing/CMakeLists.txt +++ b/Sources/_StringProcessing/CMakeLists.txt @@ -12,6 +12,12 @@ add_library(_StringProcessing Algorithms/Consumers/ManyConsumer.swift Algorithms/Consumers/PredicateConsumer.swift Algorithms/Consumers/RegexConsumer.swift + Algorithms/Matching/FirstMatch.swift + Algorithms/Matching/Matches.swift + Algorithms/Matching/MatchingCollectionConsumer.swift + Algorithms/Matching/MatchingCollectionSearcher.swift + Algorithms/Matching/MatchReplace.swift + Algorithms/Matching/MatchResult.swift Algorithms/Searchers/CollectionSearcher.swift Algorithms/Searchers/ConsumerSearcher.swift Algorithms/Searchers/NaivePatternSearcher.swift @@ -19,24 +25,54 @@ add_library(_StringProcessing Algorithms/Searchers/PredicateSearcher.swift Algorithms/Searchers/TwoWaySearcher.swift Algorithms/Searchers/ZSearcher.swift - ASTBuilder.swift + Engine/Backtracking.swift + Engine/Consume.swift + Engine/Engine.swift + Engine/InstPayload.swift + Engine/Instruction.swift + Engine/MEBuilder.swift + Engine/MECapture.swift + Engine/MEProgram.swift + Engine/Processor.swift + Engine/Register.swift + Engine/Structuralize.swift + Engine/Tracing.swift + Regex/AnyRegexOutput.swift + Regex/ASTConversion.swift + Regex/Core.swift + Regex/DSLConsumers.swift + Regex/DSLTree.swift + Regex/Match.swift + Regex/Options.swift + Unicode/CaseConversion.swift + Unicode/CharacterProps.swift + Unicode/Comparison.swift + Unicode/Data.swift + Unicode/Decoding.swift + Unicode/Encodings.swift + Unicode/Formatting.swift + Unicode/Graphemes.swift + Unicode/NecessaryEvils.swift + Unicode/Normalization.swift + Unicode/NumberParsing.swift + Unicode/ScalarProps.swift + Unicode/Transcoding.swift + Unicode/UCD.swift + Unicode/Validation.swift + Utility/ASTBuilder.swift + Utility/Protocols.swift + Utility/Traced.swift + Utility/TypedIndex.swift + Utility/TypedInt.swift + ByteCodeGen.swift Capture.swift CharacterClass.swift Compiler.swift ConsumerInterface.swift Executor.swift - Legacy/HareVM.swift - Legacy/LegacyCompile.swift - Legacy/RECode.swift - Legacy/TortoiseVM.swift - Legacy/VirtualMachine.swift - RegexDSL/Builder.swift - RegexDSL/Concatenation.swift - RegexDSL/Core.swift - RegexDSL/DSL.swift - RegexDSL/DSLCapture.swift - RegexDSL/DynamicCaptures.swift) + MatchingOptions.swift + PrintAsPattern.swift) target_compile_options(_StringProcessing PRIVATE -enable-library-evolution) target_link_libraries(_StringProcessing PUBLIC - _MatchingEngine) + _RegexParser) diff --git a/Sources/_StringProcessing/Capture.swift b/Sources/_StringProcessing/Capture.swift index 55e74684c..f7dff424e 100644 --- a/Sources/_StringProcessing/Capture.swift +++ b/Sources/_StringProcessing/Capture.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser /// A structured capture struct StructuredCapture { diff --git a/Sources/_StringProcessing/CharacterClass.swift b/Sources/_StringProcessing/CharacterClass.swift index 7989c0943..0b95e08b4 100644 --- a/Sources/_StringProcessing/CharacterClass.swift +++ b/Sources/_StringProcessing/CharacterClass.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser // NOTE: This is a model type. We want to be able to get one from // an AST, but this isn't a natural thing to produce in the context diff --git a/Sources/_StringProcessing/Compiler.swift b/Sources/_StringProcessing/Compiler.swift index 1d72a8d27..90192bdaf 100644 --- a/Sources/_StringProcessing/Compiler.swift +++ b/Sources/_StringProcessing/Compiler.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser class Compiler { let tree: DSLTree diff --git a/Sources/_StringProcessing/ConsumerInterface.swift b/Sources/_StringProcessing/ConsumerInterface.swift index 8bddb3a87..0a2d93ff1 100644 --- a/Sources/_StringProcessing/ConsumerInterface.swift +++ b/Sources/_StringProcessing/ConsumerInterface.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser extension DSLTree.Node { /// Attempt to generate a consumer from this AST node diff --git a/Sources/_StringProcessing/Engine/MEBuilder.swift b/Sources/_StringProcessing/Engine/MEBuilder.swift index 78171a001..2b849874b 100644 --- a/Sources/_StringProcessing/Engine/MEBuilder.swift +++ b/Sources/_StringProcessing/Engine/MEBuilder.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine // For errors +import _RegexParser // For errors extension MEProgram where Input.Element: Hashable { struct Builder { diff --git a/Sources/_StringProcessing/Engine/MECapture.swift b/Sources/_StringProcessing/Engine/MECapture.swift index bac632e9e..301212736 100644 --- a/Sources/_StringProcessing/Engine/MECapture.swift +++ b/Sources/_StringProcessing/Engine/MECapture.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser /* diff --git a/Sources/_StringProcessing/Engine/MEProgram.swift b/Sources/_StringProcessing/Engine/MEProgram.swift index 1e58ddf54..a31134cc9 100644 --- a/Sources/_StringProcessing/Engine/MEProgram.swift +++ b/Sources/_StringProcessing/Engine/MEProgram.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser struct MEProgram where Input.Element: Equatable { typealias ConsumeFunction = (Input, Range) -> Input.Index? diff --git a/Sources/_StringProcessing/Engine/Registers.swift b/Sources/_StringProcessing/Engine/Registers.swift index 2cc3cddf5..a2a5be104 100644 --- a/Sources/_StringProcessing/Engine/Registers.swift +++ b/Sources/_StringProcessing/Engine/Registers.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser struct SentinelValue: Hashable, CustomStringConvertible { var description: String { "" } diff --git a/Sources/_StringProcessing/Engine/Structuralize.swift b/Sources/_StringProcessing/Engine/Structuralize.swift index 30e7b9efe..02a03c09c 100644 --- a/Sources/_StringProcessing/Engine/Structuralize.swift +++ b/Sources/_StringProcessing/Engine/Structuralize.swift @@ -1,4 +1,4 @@ -import _MatchingEngine +import _RegexParser extension CaptureStructure { var optionalCount: Int { diff --git a/Sources/_StringProcessing/Executor.swift b/Sources/_StringProcessing/Executor.swift index 15c1fe434..148ddf468 100644 --- a/Sources/_StringProcessing/Executor.swift +++ b/Sources/_StringProcessing/Executor.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser struct Executor { // TODO: consider let, for now lets us toggle tracing diff --git a/Sources/_StringProcessing/MatchingOptions.swift b/Sources/_StringProcessing/MatchingOptions.swift index 073c78b2f..899891184 100644 --- a/Sources/_StringProcessing/MatchingOptions.swift +++ b/Sources/_StringProcessing/MatchingOptions.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser /// A type that represents the current state of regex matching options, with /// stack-based scoping. diff --git a/Sources/_StringProcessing/PrintAsPattern.swift b/Sources/_StringProcessing/PrintAsPattern.swift index f30d8d54b..0cf16ab05 100644 --- a/Sources/_StringProcessing/PrintAsPattern.swift +++ b/Sources/_StringProcessing/PrintAsPattern.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser // TODO: Add an expansion level, both from top to bottom. // After `printAsCanonical` is fleshed out, these two diff --git a/Sources/_StringProcessing/Regex/ASTConversion.swift b/Sources/_StringProcessing/Regex/ASTConversion.swift index 72dd11cdf..5336a1892 100644 --- a/Sources/_StringProcessing/Regex/ASTConversion.swift +++ b/Sources/_StringProcessing/Regex/ASTConversion.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser extension AST { var dslTree: DSLTree { diff --git a/Sources/_StringProcessing/Regex/AnyRegexOutput.swift b/Sources/_StringProcessing/Regex/AnyRegexOutput.swift index b1d9bfafa..2f99470fc 100644 --- a/Sources/_StringProcessing/Regex/AnyRegexOutput.swift +++ b/Sources/_StringProcessing/Regex/AnyRegexOutput.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser extension Regex where Output == AnyRegexOutput { public init(_ pattern: String) throws { diff --git a/Sources/_StringProcessing/Regex/Core.swift b/Sources/_StringProcessing/Regex/Core.swift index c6433ef3e..29d18ef22 100644 --- a/Sources/_StringProcessing/Regex/Core.swift +++ b/Sources/_StringProcessing/Regex/Core.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser /// A type that represents a regular expression. @@ -81,12 +81,6 @@ public struct Regex: RegexComponent { self.init(ast: try! parseWithDelimiters(pattern)) } - public init( - _ content: Content - ) where Content.Output == Output { - self = content.regex - } - public var regex: Regex { self } diff --git a/Sources/_StringProcessing/Regex/DSLTree.swift b/Sources/_StringProcessing/Regex/DSLTree.swift index e579828d2..bd3b37a3d 100644 --- a/Sources/_StringProcessing/Regex/DSLTree.swift +++ b/Sources/_StringProcessing/Regex/DSLTree.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser @_spi(RegexBuilder) public struct DSLTree { diff --git a/Sources/_StringProcessing/Regex/Options.swift b/Sources/_StringProcessing/Regex/Options.swift index 7876ae35c..04be79c6e 100644 --- a/Sources/_StringProcessing/Regex/Options.swift +++ b/Sources/_StringProcessing/Regex/Options.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -import _MatchingEngine +import _RegexParser extension RegexComponent { public func caseSensitive(_ isCaseSensitive: Bool) -> Regex { diff --git a/Sources/_StringProcessing/Utility/ASTBuilder.swift b/Sources/_StringProcessing/Utility/ASTBuilder.swift index bbc199d27..8a9af8111 100644 --- a/Sources/_StringProcessing/Utility/ASTBuilder.swift +++ b/Sources/_StringProcessing/Utility/ASTBuilder.swift @@ -25,7 +25,7 @@ AST. */ -import _MatchingEngine +import _RegexParser func alt(_ asts: [AST.Node]) -> AST.Node { return .alternation( diff --git a/Sources/_Unicode/CMakeLists.txt b/Sources/_Unicode/CMakeLists.txt deleted file mode 100644 index 7fdb44628..000000000 --- a/Sources/_Unicode/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ - -add_library(_Unicode - CaseConversion.swift - CharacterProps.swift - Comparison.swift - Decoding.swift - Encodings.swift - Formatting.swift - Graphemes.swift - NecessaryEvils.swift - Normaliation.swift - NumberParsing.swift - ScalarProps.swift - Transcoding.swift - UCD.swift - Validation.swift) diff --git a/Tests/MatchingEngineTests/UtilTests.swift b/Tests/MatchingEngineTests/UtilTests.swift index cb9e22e97..d0b2698a9 100644 --- a/Tests/MatchingEngineTests/UtilTests.swift +++ b/Tests/MatchingEngineTests/UtilTests.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// import XCTest -@testable import _MatchingEngine +@testable import _RegexParser class UtilTests: XCTestCase { func testTupleTypeConstruction() { diff --git a/Tests/PrototypesTests/CombinatorsTests.swift b/Tests/PrototypesTests/CombinatorsTests.swift index e34d0f832..bf82b65a2 100644 --- a/Tests/PrototypesTests/CombinatorsTests.swift +++ b/Tests/PrototypesTests/CombinatorsTests.swift @@ -11,7 +11,7 @@ import XCTest @testable import Combinators -import _MatchingEngine +import _RegexParser class CombinatorTests: XCTestCase { func testAdHoc() { diff --git a/Tests/PrototypesTests/PEGTests.swift b/Tests/PrototypesTests/PEGTests.swift index 0fac674f3..5d7516a50 100644 --- a/Tests/PrototypesTests/PEGTests.swift +++ b/Tests/PrototypesTests/PEGTests.swift @@ -11,7 +11,7 @@ import XCTest @testable import Prototypes -import _MatchingEngine +import _RegexParser // Make examples more sane. Need builder typealias Pattern = PEG.Pattern diff --git a/Tests/PrototypesTests/PTCaRetTests.swift b/Tests/PrototypesTests/PTCaRetTests.swift index 0e05e1231..752f13b39 100644 --- a/Tests/PrototypesTests/PTCaRetTests.swift +++ b/Tests/PrototypesTests/PTCaRetTests.swift @@ -11,7 +11,7 @@ import XCTest @testable import Prototypes -import _MatchingEngine +import _RegexParser enum Event: UInt64, Hashable { case authenticate = 0 diff --git a/Tests/RegexBuilderTests/RegexDSLTests.swift b/Tests/RegexBuilderTests/RegexDSLTests.swift index a7d307b9b..93a1dda65 100644 --- a/Tests/RegexBuilderTests/RegexDSLTests.swift +++ b/Tests/RegexBuilderTests/RegexDSLTests.swift @@ -22,7 +22,7 @@ class RegexDSLTests: XCTestCase { line: UInt = #line, @RegexComponentBuilder _ content: () -> Content ) throws { - let regex = Regex(content()) + let regex = content() for (input, maybeExpectedCaptures) in tests { let maybeMatch = input.match(regex) if let expectedCaptures = maybeExpectedCaptures { @@ -99,12 +99,14 @@ class RegexDSLTests: XCTestCase { do { let regex = Regex { "ab" - Capture { - ChoiceOf { - "c" - "def" + OneOrMore { + Capture { + ChoiceOf { + "c" + "def" + } } - }.+ + } } XCTAssertTrue( try XCTUnwrap("abc".match(regex)?.output) == ("abc", "c")) @@ -149,12 +151,17 @@ class RegexDSLTests: XCTestCase { ("aaaabccccdddkj", ("aaaabccccdddkj", "b", "cccc", "d", "k", nil, "j")), matchType: (Substring, Substring, Substring, Substring?, Substring, Substring?, Substring?).self, ==) { - "a".+ + OneOrMore("a") Capture(OneOrMore(Character("b"))) // Substring Capture(ZeroOrMore("c")) // Substring - Capture(.hexDigit).* // Substring? - "e".? - Capture("t" | "k") // Substring + ZeroOrMore(Capture(.hexDigit)) // Substring? + Optionally("e") + Capture { + ChoiceOf { + "t" + "k" + } + } // Substring ChoiceOf { Capture("k"); Capture("j") } // (Substring?, Substring?) } } @@ -276,7 +283,7 @@ class RegexDSLTests: XCTestCase { matchType: Substring.self, ==) { Anchor.startOfLine - "a".+ + OneOrMore("a") "b" Anchor.endOfLine } @@ -298,9 +305,9 @@ class RegexDSLTests: XCTestCase { ("aaaaab", nil), matchType: Substring.self, ==) { - "a".+ - lookahead(CharacterClass.digit) - lookahead("2", negative: true) + OneOrMore("a") + Lookahead(CharacterClass.digit) + Lookahead("2", negative: true) CharacterClass.word } } @@ -361,7 +368,7 @@ class RegexDSLTests: XCTestCase { ("aaa ", ("aaa ", nil, nil)), matchType: (Substring, Int?, Word?).self, ==) { - "a".+ + OneOrMore("a") OneOrMore(.whitespace) Optionally { Capture(OneOrMore(.digit)) { Int($0)! } @@ -375,43 +382,45 @@ class RegexDSLTests: XCTestCase { func testNestedCaptureTypes() throws { let regex1 = Regex { - "a".+ + OneOrMore("a") Capture { Capture(OneOrMore("b")) - "e".? + Optionally("e") } } let _: (Substring, Substring, Substring).Type = type(of: regex1).Output.self let regex2 = Regex { - "a".+ + OneOrMore("a") Capture { - TryCapture("b") { Int($0) }.* - "e".? + ZeroOrMore { + TryCapture("b") { Int($0) } + } + Optionally("e") } } let _: (Substring, Substring, Int?).Type = type(of: regex2).Output.self let regex3 = Regex { - "a".+ + OneOrMore("a") Capture { TryCapture("b") { Int($0) } ZeroOrMore { TryCapture("c") { Double($0) } } - "e".? + Optionally("e") } } let _: (Substring, Substring, Int, Double?).Type = type(of: regex3).Output.self let regex4 = Regex { - "a".+ + OneOrMore("a") Capture { OneOrMore { Capture(OneOrMore("b")) Capture(ZeroOrMore("c")) - Capture("d").* - "e".? + ZeroOrMore(Capture("d")) + Optionally("e") } } } diff --git a/Tests/RegexTests/CaptureTests.swift b/Tests/RegexTests/CaptureTests.swift index 258aea86d..7d4266071 100644 --- a/Tests/RegexTests/CaptureTests.swift +++ b/Tests/RegexTests/CaptureTests.swift @@ -11,7 +11,7 @@ import XCTest @testable @_spi(RegexBuilder) import _StringProcessing -import _MatchingEngine +import _RegexParser extension StructuredCapture { func formatStringCapture(input: String) -> String { diff --git a/Tests/RegexTests/CompileTests.swift b/Tests/RegexTests/CompileTests.swift index 63e48fa61..bc545d02e 100644 --- a/Tests/RegexTests/CompileTests.swift +++ b/Tests/RegexTests/CompileTests.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// -@testable import _MatchingEngine +@testable import _RegexParser @testable import _StringProcessing import XCTest diff --git a/Tests/RegexTests/DiagnosticTests.swift b/Tests/RegexTests/DiagnosticTests.swift index 3b86363cc..428020b80 100644 --- a/Tests/RegexTests/DiagnosticTests.swift +++ b/Tests/RegexTests/DiagnosticTests.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -@testable import _MatchingEngine +@testable import _RegexParser @testable import _StringProcessing import XCTest diff --git a/Tests/RegexTests/LexTests.swift b/Tests/RegexTests/LexTests.swift index 25ced92c2..c50191d05 100644 --- a/Tests/RegexTests/LexTests.swift +++ b/Tests/RegexTests/LexTests.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -@testable import _MatchingEngine +@testable import _RegexParser import XCTest @testable import _StringProcessing diff --git a/Tests/RegexTests/MatchTests.swift b/Tests/RegexTests/MatchTests.swift index dba72820f..52db17aa7 100644 --- a/Tests/RegexTests/MatchTests.swift +++ b/Tests/RegexTests/MatchTests.swift @@ -10,9 +10,16 @@ //===----------------------------------------------------------------------===// import XCTest -@testable import _MatchingEngine +@testable import _RegexParser @testable import _StringProcessing +struct MatchError: Error { + var message: String + init(_ message: String) { + self.message = message + } +} + extension Executor { func _firstMatch( _ regex: String, input: String, @@ -31,7 +38,7 @@ extension Executor { let caps = result.rawCaptures.slices(from: input) return (input[result.range], caps) } else if start == input.endIndex { - throw "match not found for \(regex) in \(input)" + throw MatchError("match not found for \(regex) in \(input)") } else { input.formIndex(after: &start) } @@ -76,27 +83,29 @@ func flatCaptureTest( if expect == nil { continue } else { - throw "Match failed" + throw MatchError("Match failed") } } guard let expect = expect else { - throw "Match of \(test) succeeded where failure expected in \(regex)" + throw MatchError(""" + Match of \(test) succeeded where failure expected in \(regex) + """) } let capStrs = caps.map { $0 == nil ? nil : String($0!) } guard expect.count == capStrs.count else { - throw """ + throw MatchError(""" Capture count mismatch: \(expect) \(capStrs) - """ + """) } guard expect.elementsEqual(capStrs) else { - throw """ + throw MatchError(""" Capture mismatch: \(expect) \(capStrs) - """ + """) } } catch { if !xfail { diff --git a/Tests/RegexTests/ParseTests.swift b/Tests/RegexTests/ParseTests.swift index ced69bb9d..6e511767a 100644 --- a/Tests/RegexTests/ParseTests.swift +++ b/Tests/RegexTests/ParseTests.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -@testable import _MatchingEngine +@testable import _RegexParser import XCTest @testable import _StringProcessing diff --git a/Tests/RegexTests/SyntaxOptionsTests.swift b/Tests/RegexTests/SyntaxOptionsTests.swift index 881eb0cbc..13618488c 100644 --- a/Tests/RegexTests/SyntaxOptionsTests.swift +++ b/Tests/RegexTests/SyntaxOptionsTests.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -@testable import _MatchingEngine +@testable import _RegexParser @testable import _StringProcessing import XCTest