Skip to content

Rename RegexMatch to MatchResult. #205

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

Merged
merged 1 commit into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Sources/_StringProcessing/Executor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct Executor {
_ input: String,
in inputRange: Range<String.Index>,
_ mode: MatchMode
) throws -> RegexMatch<Match>? {
) throws -> MatchResult<Match>? {
var cpu = engine.makeProcessor(
input: input, bounds: inputRange, matchMode: mode)

Expand Down Expand Up @@ -53,7 +53,7 @@ struct Executor {
value = nil
}

return RegexMatch(
return MatchResult(
input: input,
range: range,
rawCaptures: caps,
Expand All @@ -65,7 +65,7 @@ struct Executor {
_ input: String,
in inputRange: Range<String.Index>,
_ mode: MatchMode
) throws -> RegexMatch<(Substring, DynamicCaptures)>? {
) throws -> MatchResult<(Substring, DynamicCaptures)>? {
try match(input, in: inputRange, mode)
}
}
16 changes: 8 additions & 8 deletions Sources/_StringProcessing/RegexDSL/Match.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//===----------------------------------------------------------------------===//

@dynamicMemberLookup
public struct RegexMatch<Match> {
public struct MatchResult<Match> {
let input: String
public let range: Range<String.Index>
let rawCaptures: [StructuredCapture]
Expand Down Expand Up @@ -64,11 +64,11 @@ public struct RegexMatch<Match> {
}

extension RegexComponent {
public func match(in input: String) -> RegexMatch<Match>? {
public func match(in input: String) -> MatchResult<Match>? {
_match(
input, in: input.startIndex..<input.endIndex)
}
public func match(in input: Substring) -> RegexMatch<Match>? {
public func match(in input: Substring) -> MatchResult<Match>? {
_match(
input.base, in: input.startIndex..<input.endIndex)
}
Expand All @@ -77,7 +77,7 @@ extension RegexComponent {
_ input: String,
in inputRange: Range<String.Index>,
mode: MatchMode = .wholeString
) -> RegexMatch<Match>? {
) -> MatchResult<Match>? {
let executor = Executor(program: regex.program.loweredProgram)
do {
return try executor.match(input, in: inputRange, mode)
Expand All @@ -88,24 +88,24 @@ extension RegexComponent {
}

extension String {
public func match<R: RegexComponent>(_ regex: R) -> RegexMatch<R.Match>? {
public func match<R: RegexComponent>(_ regex: R) -> MatchResult<R.Match>? {
regex.match(in: self)
}

public func match<R: RegexComponent>(
@RegexComponentBuilder _ content: () -> R
) -> RegexMatch<R.Match>? {
) -> MatchResult<R.Match>? {
match(content())
}
}
extension Substring {
public func match<R: RegexComponent>(_ regex: R) -> RegexMatch<R.Match>? {
public func match<R: RegexComponent>(_ regex: R) -> MatchResult<R.Match>? {
regex.match(in: self)
}

public func match<R: RegexComponent>(
@RegexComponentBuilder _ content: () -> R
) -> RegexMatch<R.Match>? {
) -> MatchResult<R.Match>? {
match(content())
}
}