Skip to content

Commit 2047cb0

Browse files
committed
Rename LexError -> DelimiterLexError
To avoid confusion with more general regex lexical analysis.
1 parent 7bdc37d commit 2047cb0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/_MatchingEngine/Regex/Parse/DelimiterLexing.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ enum Delimiter: Hashable, CaseIterable {
3737
}
3838
}
3939

40-
struct LexError: Error, CustomStringConvertible {
40+
struct DelimiterLexError: Error, CustomStringConvertible {
4141
enum Kind: Hashable {
4242
case endOfString
4343
case invalidUTF8 // TODO: better range reporting
@@ -97,14 +97,14 @@ func lexRegex(
9797
guard let delimiter = Delimiter.allCases.first(
9898
where: { tryEat($0.opening.utf8) }
9999
) else {
100-
throw LexError(.unknownDelimiter, resumeAt: current.successor())
100+
throw DelimiterLexError(.unknownDelimiter, resumeAt: current.successor())
101101
}
102102

103103
let contentsStart = current
104104
while true {
105105
switch load() {
106106
case nil, ascii("\n"), ascii("\r"):
107-
throw LexError(.endOfString, resumeAt: current)
107+
throw DelimiterLexError(.endOfString, resumeAt: current)
108108

109109
case ascii("\\"):
110110
// Skip next byte.
@@ -125,7 +125,7 @@ func lexRegex(
125125
let s = String(decoding: contents, as: UTF8.self)
126126

127127
guard s.utf8.elementsEqual(contents) else {
128-
throw LexError(.invalidUTF8, resumeAt: current)
128+
throw DelimiterLexError(.invalidUTF8, resumeAt: current)
129129
}
130130
return (contents: s, delimiter, end: current)
131131
}

Sources/_MatchingEngine/Regex/Parse/Mocking.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func libswiftLexRegexLiteral(
5252
let (_, _, endPtr) = try lexRegex(start: inputPtr, end: bufferEndPtr)
5353
curPtrPtr.pointee = endPtr.assumingMemoryBound(to: CChar.self)
5454
return false
55-
} catch let error as LexError {
55+
} catch let error as DelimiterLexError {
5656
if error.kind == .unknownDelimiter {
5757
// An unknown delimiter should be recovered from, as we may want to try
5858
// lex something else.
@@ -66,7 +66,7 @@ func libswiftLexRegexLiteral(
6666
// closing delimiters, which would help with code completion.
6767
return true
6868
} catch {
69-
fatalError("Should be a LexError")
69+
fatalError("Should be a DelimiterLexError")
7070
}
7171
}
7272

0 commit comments

Comments
 (0)