Implement PCRE Matching (prefer left-branch) #2

Merged
Rockingcool merged 48 commits from implementPCREMatchingRules into master 2025-02-09 15:24:29 -06:00
3 changed files with 20 additions and 5 deletions
Showing only changes of commit 1fd48ae614 - Show all commits

View File

@@ -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 {