Skip to content

Commit 93a894e

Browse files
authored
Merge pull request #225 from rxwei/main-integration-50ec05d
2 parents 46bf9a7 + 50ec05d commit 93a894e

40 files changed

+6783
-3857
lines changed

Documentation/Evolution/RegexBuilderDSL.md

Lines changed: 1446 additions & 0 deletions
Large diffs are not rendered by default.

Documentation/Evolution/RegexTypeOverview.md

Lines changed: 524 additions & 0 deletions
Large diffs are not rendered by default.

Documentation/Evolution/StronglyTypedCaptures.md

Lines changed: 140 additions & 154 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ See [Declarative String Processing Overview][decl-string]
88

99
## Requirements
1010

11-
- [Swift Trunk Development Snapshot](https://www.swift.org/download/#snapshots) DEVELOPMENT-SNAPSHOT-2022-02-03 or later.
11+
- [Swift Trunk Development Snapshot](https://www.swift.org/download/#snapshots) DEVELOPMENT-SNAPSHOT-2022-03-09 or later.
1212

1313
## Integration with Swift
1414

@@ -45,8 +45,9 @@ A pair of corresponding branches are expected to build successfully together and
4545
To integrate the latest changes in apple/swift-experimental-string-processing to apple/swift, carefully follow the workflow:
4646

4747
- Create pull requests.
48-
- Create a pull request in apple/swift-experimental-string-processing from `main` to `swift/main`, e.g. "[Integration] main -> swift/main".
49-
- If apple/swift needs to be modified to work with the latest `main` in apple/swift-experimental-string-processing, create a pull request in apple/swift.
48+
- Create a branch from a commit on `main` that you would like to integrate into `swift/main`.
49+
- Create a pull request in apple/swift-experimental-string-processing from that branch to `swift/main`, e.g. "[Integration] main (<commit>) -> swift/main".
50+
- If apple/swift needs to be modified to work with the latest `main` in apple/swift-experimental-string-processing, create a pull request in apple/swift. **Note:** Since CI in apple/swift-experimental-string-processing has not yet been set up to run full toolchain tests, you should create a PR in apple/swift regardless; if the integartion does not require changing apple/swift, create a dummy PR in apple/swift by changing the README and just not merge it in the end.
5051
- Trigger CI.
5152
- In the apple/swift-experimental-string-processing pull request, trigger CI using the following command (replacing `<PR NUMBER>` with the apple/swift pull request number, if any):
5253
```

Sources/Exercises/Participants/RegexParticipant.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ private func extractFromCaptures(
5858
}
5959

6060
@inline(__always) // get rid of generic please
61-
private func graphemeBreakPropertyData<RP: RegexProtocol>(
61+
private func graphemeBreakPropertyData<RP: RegexComponent>(
6262
forLine line: String,
6363
using regex: RP
64-
) -> GraphemeBreakEntry? where RP.Match == (Substring, Substring, Substring?, Substring) {
65-
line.match(regex).map(\.match).flatMap(extractFromCaptures)
64+
) -> GraphemeBreakEntry? where RP.Output == (Substring, Substring, Substring?, Substring) {
65+
line.match(regex).map(\.output).flatMap(extractFromCaptures)
6666
}
6767

6868
private func graphemeBreakPropertyDataLiteral(
@@ -80,18 +80,18 @@ private func graphemeBreakPropertyData(
8080
forLine line: String
8181
) -> GraphemeBreakEntry? {
8282
line.match {
83-
tryCapture(oneOrMore(.hexDigit)) { Unicode.Scalar(hex: $0) }
84-
optionally {
83+
TryCapture(OneOrMore(.hexDigit)) { Unicode.Scalar(hex: $0) }
84+
Optionally {
8585
".."
86-
tryCapture(oneOrMore(.hexDigit)) { Unicode.Scalar(hex: $0) }
86+
TryCapture(OneOrMore(.hexDigit)) { Unicode.Scalar(hex: $0) }
8787
}
88-
oneOrMore(.whitespace)
88+
OneOrMore(.whitespace)
8989
";"
90-
oneOrMore(.whitespace)
91-
tryCapture(oneOrMore(.word)) { Unicode.GraphemeBreakProperty($0) }
92-
zeroOrMore(.any)
90+
OneOrMore(.whitespace)
91+
TryCapture(OneOrMore(.word)) { Unicode.GraphemeBreakProperty($0) }
92+
ZeroOrMore(.any)
9393
}.map {
94-
let (_, lower, upper, property) = $0.match
94+
let (_, lower, upper, property) = $0.output
9595
return GraphemeBreakEntry(lower...(upper ?? lower), property)
9696
}
9797
}

Sources/Prototypes/TourOfTypes/Literal.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ enum SemanticsLevel {
5555
}
5656

5757
/// Conformers can be ran as a regex / pattern
58-
protocol RegexProtocol {
58+
protocol RegexComponent {
5959
var level: SemanticsLevel? { get }
6060
}
6161

6262
/// Provide the option to encode semantic level statically
6363
protocol RegexLiteralProtocol: ExpressibleByRegexLiteral {
64-
associatedtype ScalarSemanticRegex: RegexProtocol
65-
associatedtype GraphemeSemanticRegex: RegexProtocol
66-
associatedtype POSIXSemanticRegex: RegexProtocol
67-
associatedtype UnspecifiedSemanticRegex: RegexProtocol = RegexLiteral
64+
associatedtype ScalarSemanticRegex: RegexComponent
65+
associatedtype GraphemeSemanticRegex: RegexComponent
66+
associatedtype POSIXSemanticRegex: RegexComponent
67+
associatedtype UnspecifiedSemanticRegex: RegexComponent = RegexLiteral
6868

6969
var scalarSemantic: ScalarSemanticRegex { get }
7070
var graphemeSemantic: GraphemeSemanticRegex { get }
@@ -84,16 +84,16 @@ struct StaticSemanticRegexLiteral: RegexLiteralProtocol {
8484
*/
8585

8686
/// A regex that has statically bound its semantic level
87-
struct ScalarSemanticRegex: RegexProtocol {
87+
struct ScalarSemanticRegex: RegexComponent {
8888
var level: SemanticsLevel? { .scalar }
8989
}
90-
struct GraphemeSemanticRegex: RegexProtocol {
90+
struct GraphemeSemanticRegex: RegexComponent {
9191
var level: SemanticsLevel? { .graphemeCluster }
9292
}
93-
struct POSIXSemanticRegex: RegexProtocol {
93+
struct POSIXSemanticRegex: RegexComponent {
9494
var level: SemanticsLevel? { .posix }
9595
}
96-
struct UnspecifiedSemanticRegex: RegexProtocol {
96+
struct UnspecifiedSemanticRegex: RegexComponent {
9797
var level: SemanticsLevel? { nil }
9898
}
9999

@@ -132,9 +132,9 @@ struct RegexLiteral: ExpressibleByRegexLiteral {
132132
}
133133
}
134134

135-
extension RegexLiteral: RegexProtocol, RegexLiteralProtocol {
135+
extension RegexLiteral: RegexComponent, RegexLiteralProtocol {
136136
/// A regex that has finally bound its semantic level (dynamically)
137-
struct BoundSemantic: RegexProtocol {
137+
struct BoundSemantic: RegexComponent {
138138
var _level: SemanticsLevel // Bound semantic level
139139
var level: SemanticsLevel? { _level }
140140
}

0 commit comments

Comments
 (0)