Store the current string pointer as a 'thread variable' (allows us to simulate backtracking)
This commit is contained in:
@@ -45,6 +45,7 @@ type nfaState struct {
|
||||
// The following properties depend on the current match - I should think about resetting them for every match.
|
||||
zeroMatchFound bool // Whether or not the state has been used for a zero-length match - only relevant for zero states
|
||||
threadGroups []Group // Assuming that a state is part of a 'thread' in the matching process, this array stores the indices of capturing groups in the current thread. As matches are found for this state, its groups will be copied over.
|
||||
threadSP int // The string pointer of the thread - where it is in the input string
|
||||
}
|
||||
|
||||
// Clones the NFA starting from the given state.
|
||||
@@ -120,6 +121,7 @@ func resetThreadsHelper(state *nfaState, visitedMap map[*nfaState]bool) {
|
||||
}
|
||||
// Assuming it hasn't been visited
|
||||
state.threadGroups = nil
|
||||
state.threadSP = 0
|
||||
visitedMap[state] = true
|
||||
for _, v := range state.transitions {
|
||||
for _, nextState := range v {
|
||||
|
Reference in New Issue
Block a user