-
Notifications
You must be signed in to change notification settings - Fork 49
Switch back to Swift tuples for typed captures #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
12c7e6e
to
3db17b5
Compare
@swift-ci please test linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, if I'm reading the diffs right between this and #126
input[range], DynamicCaptures(captures) | ||
) as! Match | ||
if Match.self == (Substring, DynamicCaptures).self { | ||
convertedMatch = (input[range], DynamicCaptures(captures)) as! Match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering, what is this code path for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See testDynamicCaptures()
. This is used for compiling and running a regex string that's not known at compile time (#36).
…ions. 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)>` ```
@swift-ci please test Linux |
Typed captures no longer use ad-hoc nominal tuples. We use Swift native tuples instead. See swiftlang/swift-experimental-string-processing#127. Update checkout tag to dev/6.
This depends on #114 and #126. Please review 3db17b5.