Skip to content
Merged
Changes from 1 commit
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
18 changes: 11 additions & 7 deletions Sources/_StringProcessing/Engine/Processor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,15 @@ extension Processor {
return true
}

mutating func advance(to nextIndex: Input.Index) {
assert(nextIndex >= bounds.lowerBound)
assert(nextIndex <= bounds.upperBound)
assert(nextIndex >= currentPosition)
currentPosition = nextIndex
/// Continue matching at the specified index.
///
/// - Precondition: `bounds.contains(index) || index == bounds.upperBound`
/// - Precondition: `index >= currentPosition`
mutating func resume(at index: Input.Index) {
assert(index >= bounds.lowerBound)
assert(index <= bounds.upperBound)
assert(index >= currentPosition)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this assertion here?

currentPosition = index
}

func doPrint(_ s: String) {
Expand Down Expand Up @@ -358,7 +362,7 @@ extension Processor {
signalFailure()
return
}
advance(to: nextIndex)
resume(at: nextIndex)
controller.step()

case .assertBy:
Expand Down Expand Up @@ -386,7 +390,7 @@ extension Processor {
return
}
registers[valReg] = val
advance(to: nextIdx)
resume(at: nextIdx)
controller.step()
} catch {
abort(error)
Expand Down