Clone 'isBackreference' and 'referredGroup' NFA fields, because they aren't thread variables
This commit is contained in:
10
regex/nfa.go
10
regex/nfa.go
@@ -45,11 +45,11 @@ type nfaState struct {
|
||||
groupBegin bool // Whether or not the node starts a capturing group
|
||||
groupEnd bool // Whether or not the node ends a capturing group
|
||||
groupNum int // Which capturing group the node starts / ends
|
||||
isBackreference bool // Whether or not current node is backreference
|
||||
referredGroup int // If current node is a backreference, the node that it points to
|
||||
// The following properties depend on the current match - I should think about resetting them for every match.
|
||||
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.
|
||||
isBackreference bool // Whether or not current node is backreference
|
||||
referredGroup int // If current node is a backreference, the node that it points to
|
||||
threadBackref int // If current node is a backreference, how many characters to look forward into the referred group
|
||||
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.
|
||||
threadBackref int // If current node is a backreference, how many characters to look forward into the referred group
|
||||
}
|
||||
|
||||
// Clones the NFA starting from the given state.
|
||||
@@ -86,6 +86,8 @@ func cloneStateHelper(stateToClone *nfaState, cloneMap map[*nfaState]*nfaState)
|
||||
groupEnd: stateToClone.groupEnd,
|
||||
groupBegin: stateToClone.groupBegin,
|
||||
groupNum: stateToClone.groupNum,
|
||||
isBackreference: stateToClone.isBackreference,
|
||||
referredGroup: stateToClone.referredGroup,
|
||||
}
|
||||
cloneMap[stateToClone] = clone
|
||||
for i, s := range stateToClone.output {
|
||||
|
Reference in New Issue
Block a user