|
|
@ -23,12 +23,12 @@ func takeZeroState(states []*State) (rtv []*State, isZero bool) {
|
|
|
|
return rtv, false
|
|
|
|
return rtv, false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// match tries to match the regex represented by given start-state, with
|
|
|
|
// findAllMatches tries to findAllMatches the regex represented by given start-state, with
|
|
|
|
// the given string
|
|
|
|
// the given string
|
|
|
|
func match(start *State, str string) (indices []matchIndex) {
|
|
|
|
func findAllMatches(start *State, str string) (indices []matchIndex) {
|
|
|
|
return matchHelper(start, str, make([]matchIndex, 0), 0)
|
|
|
|
return findAllMatchesHelper(start, str, make([]matchIndex, 0), 0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func matchHelper(start *State, str string, indices []matchIndex, offset int) []matchIndex {
|
|
|
|
func findAllMatchesHelper(start *State, str string, indices []matchIndex, offset int) []matchIndex {
|
|
|
|
// 'Base case' - exit if string is empty
|
|
|
|
// 'Base case' - exit if string is empty
|
|
|
|
if len(str) == 0 {
|
|
|
|
if len(str) == 0 {
|
|
|
|
return indices
|
|
|
|
return indices
|
|
|
@ -86,7 +86,7 @@ func matchHelper(start *State, str string, indices []matchIndex, offset int) []m
|
|
|
|
if i == startingFrom {
|
|
|
|
if i == startingFrom {
|
|
|
|
i++
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return matchHelper(start, str[i:], indices, offset+i)
|
|
|
|
return findAllMatchesHelper(start, str[i:], indices, offset+i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentStates = make([]*State, len(tempStates))
|
|
|
|
currentStates = make([]*State, len(tempStates))
|
|
|
|
copy(currentStates, tempStates)
|
|
|
|
copy(currentStates, tempStates)
|
|
|
|