-
Notifications
You must be signed in to change notification settings - Fork 50
'Regex<Captures>' -> 'Regex<Match>' #68
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
@kylemacomber This paves the way for |
@swift-ci please test linux |
…d regex. - Checkout apple/swift-experimental-string-processing using a tag. - Build `_MatchingEngine` as part of libswift (`ExperimentalRegex`) using sources from the package. - Parse regex literals using the parser from `_MatchingEngine`. - Build both `_MatchingEngine` and `_StringProcessing` as part of core libs using sources from the package. - Use `Regex<DynamicCaptures>` as the default regex type until we finalize swiftlang/swift-experimental-string-processing#68.
…d regex. - Checkout apple/swift-experimental-string-processing using a tag. - Build `_MatchingEngine` as part of libswift (`ExperimentalRegex`) using sources from the package. - Parse regex literals using the parser from `_MatchingEngine`. - Build both `_MatchingEngine` and `_StringProcessing` as part of core libs using sources from the package. - Use `Regex<DynamicCaptures>` as the default regex type until we finalize swiftlang/swift-experimental-string-processing#68.
526b8ca
to
980fbb0
Compare
@swift-ci please test linux |
6faddbf
to
a5109b8
Compare
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.
Overall LGTM.
In general, any switch to a nominal type makes sense to me. Out of curiosity, what necessitated this change? Also, do we need those generic parameters?
} | ||
extension Substring: MatchProtocol { | ||
public typealias Capture = EmptyCapture | ||
} |
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 don't recall whether modern computing tolerates no newline at the end of a file.
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.
Fixed. It's partly because I've been trying to use Windows to develop these days, trying Swift for Windows myself.
public struct OneOrMore<Component: RegexProtocol>: RegexProtocol {
public typealias Match = Tuple2<Substring, [Component.Match.Capture]>
extension Tuple5: EmptyCaptureProtocol where _1: EmptyCaptureProtocol, _2: EmptyCaptureProtocol, _3: EmptyCaptureProtocol, _4: EmptyCaptureProtocol {} |
@swift-ci please test Linux |
This apparently affects regex literal type inference in the compiler, so I'll put up a PR on the compiler side to test against this. |
@swift-ci please test linux |
Changes `Regex` and result builder prototype to use `Match` as the generic parameter to make it consistent with the [Strongly Typed Regex Captures](https://forums.swift.org/t/pitch-strongly-typed-regex-captures/53391) pitch. Introduces `Tuple<n>` structs in order to be able to express constraints on capture types (i.e. `Match` dropped first) while being able to filter out empty captures in concatenation. `Tuple<n>` is also needed to implement a prototype of the [proposed matching semantics](swiftlang#64). As coercion into `Tuple<n>` can no longer use runtime magic like native tuples do, we incorporate child capture type information into RECode's `captureNil` and `captureArray` instructions so that we will always get a concrete type when forming a nil or an empty array capture. The resulting existential tuple capture can then be opened and bitcast to a `Tuple<n>`.
@swift-ci please test Linux |
Changes
Regex
and result builder prototype to useMatch
as the generic parameter to make it consistent with the Strongly Typed Regex Captures pitch.Introduces
Tuple<n>
structs in order to be able to express constraints on capture types (i.e.Match
dropped first) while being able to filter out empty captures in concatenation.Tuple<n>
is also needed to implement a prototype of the proposed matching semantics.As coercion into
Tuple<n>
can no longer use runtime magic like native tuples do, we incorporate child capture type information into RECode'scaptureNil
andcaptureArray
instructions so that we will always get a concrete type when forming a nil or an empty array capture. The resulting existential tuple capture can then be opened and bitcast to aTuple<n>
.