Clone 'isBackreference' and 'referredGroup' NFA fields, because they aren't thread variables

master
Aadhavan Srinivasan 2 weeks ago
parent 7b31031553
commit a631fc289c

@ -45,11 +45,11 @@ type nfaState struct {
groupBegin bool // Whether or not the node starts a capturing group groupBegin bool // Whether or not the node starts a capturing group
groupEnd bool // Whether or not the node ends a capturing group groupEnd bool // Whether or not the node ends a capturing group
groupNum int // Which capturing group the node starts / ends 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. // 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. 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 threadBackref int // If current node is a backreference, how many characters to look forward into the referred group
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
} }
// Clones the NFA starting from the given state. // Clones the NFA starting from the given state.
@ -86,6 +86,8 @@ func cloneStateHelper(stateToClone *nfaState, cloneMap map[*nfaState]*nfaState)
groupEnd: stateToClone.groupEnd, groupEnd: stateToClone.groupEnd,
groupBegin: stateToClone.groupBegin, groupBegin: stateToClone.groupBegin,
groupNum: stateToClone.groupNum, groupNum: stateToClone.groupNum,
isBackreference: stateToClone.isBackreference,
referredGroup: stateToClone.referredGroup,
} }
cloneMap[stateToClone] = clone cloneMap[stateToClone] = clone
for i, s := range stateToClone.output { for i, s := range stateToClone.output {

Loading…
Cancel
Save