Fix issue where parser return bad sub parsers if you reach end of text

This commit is contained in:
Adam Fowler
2021-03-18 15:25:00 +00:00
parent b637c4c4a4
commit 4af21bb4cf

View File

@@ -71,6 +71,9 @@ extension HBParser {
/// initialise a parser that parses a section of the buffer attached to this parser
func subParser(_ range: Range<Int>) -> HBParser {
if range.startIndex == range.endIndex {
return HBParser(self, range: self.range.startIndex ..< self.range.startIndex)
}
return HBParser(self, range: range)
}
}
@@ -283,9 +286,6 @@ extension HBParser {
{
unsafeAdvance()
}
if startIndex == index {
return subParser(startIndex ..< startIndex)
}
return subParser(startIndex ..< index)
}