REFACTOR NEEDED: Added another special case; insert instead of appending into currentStates
This commit is contained in:
@@ -379,17 +379,17 @@ func findAllSubmatchHelper(start *nfaState, str []rune, offset int, numGroups in
|
||||
if currentState.isKleene { // Reverse order of adding things
|
||||
rightState := currentState.splitState
|
||||
copyThread(rightState, currentState)
|
||||
currentStates = append(currentStates, *currentState.splitState)
|
||||
currentStates = slices.Insert(currentStates, currentStateIdx+1, *rightState)
|
||||
leftState := currentState.next
|
||||
copyThread(leftState, currentState)
|
||||
currentStates = append(currentStates, *currentState.next)
|
||||
currentStates = slices.Insert(currentStates, currentStateIdx+2, *leftState)
|
||||
} else {
|
||||
leftState := currentState.next
|
||||
copyThread(leftState, currentState)
|
||||
currentStates = append(currentStates, *currentState.next)
|
||||
currentStates = slices.Insert(currentStates, currentStateIdx+1, *leftState)
|
||||
rightState := currentState.splitState
|
||||
copyThread(rightState, currentState)
|
||||
currentStates = append(currentStates, *currentState.splitState)
|
||||
currentStates = slices.Insert(currentStates, currentStateIdx+2, *rightState)
|
||||
}
|
||||
continue
|
||||
}
|
||||
@@ -417,6 +417,8 @@ func findAllSubmatchHelper(start *nfaState, str []rune, offset int, numGroups in
|
||||
currentStates = slices.Insert(currentStates, currentStateIdx+1, allMatches...)
|
||||
} else if currentState.groupEnd {
|
||||
currentStates = append(currentStates, allMatches...)
|
||||
} else if currentState.assert != noneAssert {
|
||||
currentStates = append(currentStates, allMatches...)
|
||||
} else {
|
||||
nextStates = append(nextStates, allMatches...)
|
||||
}
|
||||
|
Reference in New Issue
Block a user