Reverse order of trying branches if the quantifier is lazy
This commit is contained in:
@@ -234,14 +234,14 @@ func addStateToList(str []rune, idx int, list []nfaState, state nfaState, thread
|
|||||||
}
|
}
|
||||||
visited = append(visited, state)
|
visited = append(visited, state)
|
||||||
|
|
||||||
if state.isKleene || state.isQuestion {
|
if (state.isKleene || state.isQuestion) && (state.isLazy == false) { // Greedy quantifiers
|
||||||
copyThread(state.splitState, state)
|
copyThread(state.splitState, state)
|
||||||
list := addStateToList(str, idx, list, *state.splitState, threadGroups, visited, preferLongest)
|
list := addStateToList(str, idx, list, *state.splitState, threadGroups, visited, preferLongest)
|
||||||
copyThread(state.next, state)
|
copyThread(state.next, state)
|
||||||
list = addStateToList(str, idx, list, *state.next, threadGroups, visited, preferLongest)
|
list = addStateToList(str, idx, list, *state.next, threadGroups, visited, preferLongest)
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
if state.isAlternation {
|
if state.isAlternation || ((state.isKleene || state.isQuestion) && state.isLazy) { // Alternation or lazy quantifier
|
||||||
copyThread(state.next, state)
|
copyThread(state.next, state)
|
||||||
list := addStateToList(str, idx, list, *state.next, threadGroups, visited, preferLongest)
|
list := addStateToList(str, idx, list, *state.next, threadGroups, visited, preferLongest)
|
||||||
copyThread(state.splitState, state)
|
copyThread(state.splitState, state)
|
||||||
|
Reference in New Issue
Block a user