Skip to content

Commit 3334fa0

Browse files
committed
Record error location in tryEatNonEmpty
1 parent b05f6d6 commit 3334fa0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Sources/_MatchingEngine/Regex/Parse/LexicalAnalysis.swift

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,19 @@ extension Source {
100100
}
101101
}
102102

103-
mutating func tryEatNonEmpty(_ c: Char) throws -> Bool {
104-
guard !isEmpty else { throw ParseError.expected(String(c)) }
105-
return tryEat(c)
106-
}
107-
108103
mutating func tryEatNonEmpty<C: Collection>(sequence c: C) throws -> Bool
109104
where C.Element == Char
110105
{
111-
guard !isEmpty else { throw ParseError.expected(String(c)) }
106+
_ = try recordLoc { src in
107+
guard !src.isEmpty else { throw ParseError.expected(String(c)) }
108+
}
112109
return tryEat(sequence: c)
113110
}
114111

112+
mutating func tryEatNonEmpty(_ c: Char) throws -> Bool {
113+
try tryEatNonEmpty(sequence: String(c))
114+
}
115+
115116
/// Throws an expected ASCII character error if not matched
116117
mutating func expectASCII() throws -> Located<Character> {
117118
try recordLoc { src in

0 commit comments

Comments
 (0)