Skip to content

Commit 0793dd5

Browse files
committed
Change quantifiers in the DSL from structure types to top-level functions. This allows for a lot more flexibility with overloading a quantifier based on the input Match type. The immediate benefit of this is getting rid of void and nested void types (see example below), and as a result eliminate the need for void-filtering within concatenation. A more important benefit is being able to get rid of nominal tuples and switch back to Swift tuples, as Swift tuples enable strongly typed named captures and eliminates the complexity that comes with nominal tuples.
----- Before: ```swift let r0 = OneOrMore(.digit) // => `.Match == Tuple2<Substring, [()]>` let r1 = Optionally(.digit) // => `.Match == Tuple2<Substring, ()?>` let r2 = OneOrMore(Repeat(Optionally(.digit))) // => `.Match == Tuple2<Substring, [[()?]]>` "123".match(r2) // => `RegexMatch<Tuple2<Substring, [[()?]]>>?` ``` After: ```swift let r0 = oneOrMore(.digit) // => `.Match == Substring` let r1 = optionally(.digit) // => `.Match == Substring` let r2 = oneOrMore(many(optionally(.digit))) // => `.Match == Substring` "123".match(r2) // => `RegexMatch<Substring>` ``` ----- Before: ```swift /(?<number>\d+)/ // => `Regex<Tuple2<Substring, Substring>>` ``` After: ```swift /(?<number>\d+)/ // => `Regex<(Substring, number: Substring)>` ```
1 parent 4cb2b1c commit 0793dd5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Sources/_StringProcessing/RegexDSL/DSL.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extension CharacterClass: RegexProtocol {
4141
}
4242
}
4343

44+
4445
// MARK: - Combinators
4546

4647
// MARK: Concatenation

0 commit comments

Comments
 (0)