|
|
@ -98,12 +98,15 @@ func findAllMatchesHelper(start *State, str string, indices []matchIndex, offset
|
|
|
|
i++
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// End-of-string reached. Go to any 0-states. Then check if any of our states are in the end position.
|
|
|
|
// End-of-string reached. Go to any 0-states, until there are no more 0-states to go to. Then check if any of our states are in the end position.
|
|
|
|
for _, state := range currentStates {
|
|
|
|
// This is the exact same algorithm used inside the loop, so I should probably put it in a function.
|
|
|
|
if len(state.transitions[EPSILON]) > 0 {
|
|
|
|
zeroStates, isZero := takeZeroState(currentStates)
|
|
|
|
tempStates = append(tempStates, state.transitions[EPSILON]...)
|
|
|
|
tempStates = append(tempStates, zeroStates...)
|
|
|
|
}
|
|
|
|
for isZero == true {
|
|
|
|
|
|
|
|
zeroStates, isZero = takeZeroState(tempStates)
|
|
|
|
|
|
|
|
tempStates = append(tempStates, zeroStates...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
currentStates = append(currentStates, tempStates...)
|
|
|
|
currentStates = append(currentStates, tempStates...)
|
|
|
|
tempStates = nil
|
|
|
|
tempStates = nil
|
|
|
|
|
|
|
|
|
|
|
|