Skip to content

Commit 3a92092

Browse files
authored
Merge pull request #296 from natecook1000/main-integration-293bad4
[Integration] main (293bad4) -> swift/main
2 parents 51d587f + 293bad4 commit 3a92092

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+760
-303
lines changed

Documentation/Evolution/StringProcessingAlgorithms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public protocol CustomMatchingRegexComponent : RegexComponent {
187187
_ input: String,
188188
startingAt index: String.Index,
189189
in bounds: Range<String.Index>
190-
) -> (upperBound: String.Index, match: Match)?
190+
) throws -> (upperBound: String.Index, match: Match)?
191191
}
192192
```
193193

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ let package = Package(
7676
.unsafeFlags(["-Xfrontend", "-enable-experimental-pairwise-build-block"]),
7777
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"])
7878
]),
79-
.target(
79+
.testTarget(
8080
name: "Prototypes",
8181
dependencies: ["_RegexParser", "_StringProcessing"],
8282
swiftSettings: [
@@ -100,7 +100,7 @@ let package = Package(
100100
// MARK: Exercises
101101
.target(
102102
name: "Exercises",
103-
dependencies: ["_RegexParser", "Prototypes", "_StringProcessing", "RegexBuilder"],
103+
dependencies: ["_RegexParser", "_StringProcessing", "RegexBuilder"],
104104
swiftSettings: [
105105
.unsafeFlags(["-Xfrontend", "-enable-experimental-pairwise-build-block"]),
106106
.unsafeFlags(["-Xfrontend", "-disable-availability-checking"])

Sources/Exercises/Exercises.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public enum Exercises {
1616
HandWrittenParticipant.self,
1717
RegexDSLParticipant.self,
1818
RegexLiteralParticipant.self,
19-
PEGParticipant.self,
2019
NSREParticipant.self,
2120
]
2221
}

Sources/Exercises/Participants/PEGParticipant.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
//
1010
//===----------------------------------------------------------------------===//
1111

12+
// Disabled because Prototypes is a test target.
13+
#if false
14+
1215
struct PEGParticipant: Participant {
1316
static var name: String { "PEG" }
1417
}
@@ -51,3 +54,4 @@ private func graphemeBreakPropertyData(forLine line: String) -> GraphemeBreakEnt
5154

5255
}
5356

57+
#endif

Sources/RegexBuilder/DSL.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,29 @@ extension DSLTree.Node {
120120
@available(SwiftStdlib 5.7, *)
121121
static func repeating(
122122
_ range: Range<Int>,
123-
_ behavior: QuantificationBehavior,
123+
_ behavior: QuantificationBehavior?,
124124
_ node: DSLTree.Node
125125
) -> DSLTree.Node {
126126
// TODO: Throw these as errors
127127
assert(range.lowerBound >= 0, "Cannot specify a negative lower bound")
128128
assert(!range.isEmpty, "Cannot specify an empty range")
129+
130+
let kind: DSLTree.QuantificationKind = behavior.map { .explicit($0.astKind) } ?? .default
129131

130132
switch (range.lowerBound, range.upperBound) {
131133
case (0, Int.max): // 0...
132-
return .quantification(.zeroOrMore, behavior.astKind, node)
134+
return .quantification(.zeroOrMore, kind, node)
133135
case (1, Int.max): // 1...
134-
return .quantification(.oneOrMore, behavior.astKind, node)
136+
return .quantification(.oneOrMore, kind, node)
135137
case _ where range.count == 1: // ..<1 or ...0 or any range with count == 1
136138
// Note: `behavior` is ignored in this case
137-
return .quantification(.exactly(.init(faking: range.lowerBound)), .eager, node)
139+
return .quantification(.exactly(.init(faking: range.lowerBound)), .default, node)
138140
case (0, _): // 0..<n or 0...n or ..<n or ...n
139-
return .quantification(.upToN(.init(faking: range.upperBound)), behavior.astKind, node)
141+
return .quantification(.upToN(.init(faking: range.upperBound)), kind, node)
140142
case (_, Int.max): // n...
141-
return .quantification(.nOrMore(.init(faking: range.lowerBound)), behavior.astKind, node)
143+
return .quantification(.nOrMore(.init(faking: range.lowerBound)), kind, node)
142144
default: // any other range
143-
return .quantification(.range(.init(faking: range.lowerBound), .init(faking: range.upperBound)), behavior.astKind, node)
145+
return .quantification(.range(.init(faking: range.lowerBound), .init(faking: range.upperBound)), kind, node)
144146
}
145147
}
146148
}

0 commit comments

Comments
 (0)