Skip to content

Commit cc91315

Browse files
natecook1000Azoy
authored andcommitted
Eliminate extra public API (swiftlang#256)
These were mostly leftover bits from testing 👋
1 parent 5f31de8 commit cc91315

File tree

13 files changed

+43
-62
lines changed

13 files changed

+43
-62
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ let package = Package(
2222
],
2323
dependencies: [
2424
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
25+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
2526
],
2627
targets: [
2728
// Targets are the basic building blocks of a package. A target can define a module or a test suite.

Sources/Exercises/Participants/RegexParticipant.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ private func graphemeBreakPropertyData<RP: RegexComponent>(
6969
private func graphemeBreakPropertyDataLiteral(
7070
forLine line: String
7171
) -> GraphemeBreakEntry? {
72-
return graphemeBreakPropertyData(
73-
forLine: line,
74-
using: r(#"([0-9A-F]+)(?:\.\.([0-9A-F]+))?\s+;\s+(\w+).*"#,
75-
matching: (Substring, Substring, Substring?, Substring).self))
72+
let regex = try! Regex(
73+
compiling: #"([0-9A-F]+)(?:\.\.([0-9A-F]+))?\s+;\s+(\w+).*"#,
74+
as: (Substring, Substring, Substring?, Substring).self)
75+
return graphemeBreakPropertyData(forLine: line, using: regex)
7676
}
7777

7878
// MARK: - Builder DSL

Sources/PatternConverter/PatternConverter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import ArgumentParser
1515
import _RegexParser
16-
import _StringProcessing
16+
@_spi(PatternConverter) import _StringProcessing
1717

1818
@main
1919
struct PatternConverter: ParsableCommand {

Sources/_StringProcessing/Algorithms/Consumers/PredicateConsumer.swift

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

12-
public struct PredicateConsumer<Consumed: Collection> {
12+
struct PredicateConsumer<Consumed: Collection> {
1313
let predicate: (Consumed.Element) -> Bool
1414
}
1515

@@ -29,7 +29,7 @@ extension PredicateConsumer: CollectionConsumer {
2929
extension PredicateConsumer: BidirectionalCollectionConsumer
3030
where Consumed: BidirectionalCollection
3131
{
32-
public func consumingBack(
32+
func consumingBack(
3333
_ consumed: Consumed,
3434
in range: Range<Consumed.Index>
3535
) -> Consumed.Index? {
@@ -59,9 +59,9 @@ extension PredicateConsumer: BackwardCollectionSearcher,
5959
BackwardStatelessCollectionSearcher
6060
where Searched: BidirectionalCollection
6161
{
62-
public typealias BackwardSearched = Consumed
62+
typealias BackwardSearched = Consumed
6363

64-
public func searchBack(
64+
func searchBack(
6565
_ searched: BackwardSearched,
6666
in range: Range<BackwardSearched.Index>
6767
) -> Range<BackwardSearched.Index>? {

Sources/_StringProcessing/Algorithms/Consumers/RegexConsumer.swift

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

12-
public struct RegexConsumer<
12+
struct RegexConsumer<
1313
R: RegexComponent, Consumed: BidirectionalCollection
1414
> where Consumed.SubSequence == Substring {
1515
// TODO: Should `Regex` itself implement these protocols?
1616
let regex: R
1717

18-
public init(_ regex: R) {
18+
init(_ regex: R) {
1919
self.regex = regex
2020
}
2121
}
@@ -36,9 +36,9 @@ extension RegexConsumer {
3636
// well, taking advantage of the fact that the captures can be ignored
3737

3838
extension RegexConsumer: MatchingCollectionConsumer {
39-
public typealias Match = R.Output
39+
typealias Match = R.Output
4040

41-
public func matchingConsuming(
41+
func matchingConsuming(
4242
_ consumed: Consumed, in range: Range<Consumed.Index>
4343
) -> (upperBound: String.Index, match: Match)? {
4444
_matchingConsuming(consumed[...], in: range)
@@ -47,7 +47,7 @@ extension RegexConsumer: MatchingCollectionConsumer {
4747

4848
// TODO: We'll want to bake backwards into the engine
4949
extension RegexConsumer: BidirectionalMatchingCollectionConsumer {
50-
public func matchingConsumingBack(
50+
func matchingConsumingBack(
5151
_ consumed: Consumed, in range: Range<Consumed.Index>
5252
) -> (lowerBound: String.Index, match: Match)? {
5353
var i = range.lowerBound
@@ -67,12 +67,12 @@ extension RegexConsumer: BidirectionalMatchingCollectionConsumer {
6767
}
6868

6969
extension RegexConsumer: MatchingStatelessCollectionSearcher {
70-
public typealias Searched = Consumed
70+
typealias Searched = Consumed
7171

7272
// TODO: We'll want to bake search into the engine so it can
7373
// take advantage of the structure of the regex itself and
7474
// its own internal state
75-
public func matchingSearch(
75+
func matchingSearch(
7676
_ searched: Searched, in range: Range<Searched.Index>
7777
) -> (range: Range<String.Index>, match: Match)? {
7878
ConsumerSearcher(consumer: self).matchingSearch(searched, in: range)
@@ -81,9 +81,9 @@ extension RegexConsumer: MatchingStatelessCollectionSearcher {
8181

8282
// TODO: Bake in search-back to engine too
8383
extension RegexConsumer: BackwardMatchingStatelessCollectionSearcher {
84-
public typealias BackwardSearched = Consumed
84+
typealias BackwardSearched = Consumed
8585

86-
public func matchingSearchBack(
86+
func matchingSearchBack(
8787
_ searched: BackwardSearched, in range: Range<Searched.Index>
8888
) -> (range: Range<String.Index>, match: Match)? {
8989
ConsumerSearcher(consumer: self).matchingSearchBack(searched, in: range)

Sources/_StringProcessing/Algorithms/Searchers/TwoWaySearcher.swift

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

12-
public struct TwoWaySearcher<Searched: BidirectionalCollection>
12+
struct TwoWaySearcher<Searched: BidirectionalCollection>
1313
where Searched.Element: Comparable
1414
{
1515
// TODO: Be generic over the pattern?
@@ -36,14 +36,14 @@ public struct TwoWaySearcher<Searched: BidirectionalCollection>
3636
}
3737

3838
extension TwoWaySearcher: CollectionSearcher {
39-
public struct State {
39+
struct State {
4040
let end: Searched.Index
4141
var index: Searched.Index
4242
var criticalIndex: Searched.Index
4343
var memory: (offset: Int, index: Searched.Index)?
4444
}
4545

46-
public func state(
46+
func state(
4747
for searched: Searched,
4848
in range: Range<Searched.Index>
4949
) -> State {
@@ -57,7 +57,7 @@ extension TwoWaySearcher: CollectionSearcher {
5757
memory: nil)
5858
}
5959

60-
public func search(
60+
func search(
6161
_ searched: Searched,
6262
_ state: inout State
6363
) -> Range<Searched.Index>? {

Sources/_StringProcessing/Algorithms/Searchers/ZSearcher.swift

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

12-
public struct ZSearcher<Searched: Collection> {
12+
struct ZSearcher<Searched: Collection> {
1313
let pattern: [Searched.Element]
1414
let z: [Int]
1515
let areEquivalent: (Searched.Element, Searched.Element) -> Bool
1616

17-
public init(
17+
init(
1818
pattern: [Searched.Element],
1919
by areEquivalent: @escaping (Searched.Element, Searched.Element
2020
) -> Bool) {
@@ -25,7 +25,7 @@ public struct ZSearcher<Searched: Collection> {
2525
}
2626

2727
extension ZSearcher: StatelessCollectionSearcher {
28-
public func search(
28+
func search(
2929
_ searched: Searched,
3030
in range: Range<Searched.Index>
3131
) -> Range<Searched.Index>? {

Sources/_StringProcessing/MatchingOptions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import _RegexParser
1313

1414
/// A type that represents the current state of regex matching options, with
1515
/// stack-based scoping.
16-
public struct MatchingOptions {
16+
struct MatchingOptions {
1717
fileprivate var stack: [Representation]
1818

1919
fileprivate func _invariantCheck() {

Sources/_StringProcessing/PrintAsPattern.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import _RegexParser
1919

2020
extension AST {
2121
/// Render as a Pattern DSL
22+
@_spi(PatternConverter)
2223
public func renderAsBuilderDSL(
2324
maxTopDownLevels: Int? = nil,
2425
minBottomUpLevels: Int? = nil

Sources/_StringProcessing/Regex/Core.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,3 @@ extension UnicodeScalar: RegexComponent {
129129
.init(node: .atom(.scalar(self)))
130130
}
131131
}
132-
133-
// MARK: - Testing
134-
135-
public struct MockRegexLiteral<Output>: RegexComponent {
136-
public typealias MatchValue = Substring
137-
public let regex: Regex<Output>
138-
139-
public init(
140-
_ string: String,
141-
_ syntax: SyntaxOptions = .traditional,
142-
matching: Output.Type = Output.self
143-
) throws {
144-
regex = Regex(ast: try parse(string, syntax))
145-
}
146-
}
147-
148-
public func r<Output>(
149-
_ s: String, matching matchType: Output.Type = Output.self
150-
) -> MockRegexLiteral<Output> {
151-
try! MockRegexLiteral(s, matching: matchType)
152-
}

0 commit comments

Comments
 (0)