1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-06-01 01:34:07 +02:00

allow for a state to have multiple assertitions

This commit is contained in:
Emanuel Gestosa 2023-08-22 16:47:07 +01:00 committed by lippfi
parent b9b8d30f3b
commit c78a5d3cab
2 changed files with 9 additions and 9 deletions
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/regexp/nfa

View File

@ -158,13 +158,13 @@ internal class NFA private constructor(
val newStart = NFAState()
val newEnd = NFAState()
newStart.assertion = NFAAssertion(
newStart.assertions.add(NFAAssertion(
shouldConsume,
isPositive,
startState,
acceptState,
newEnd
)
))
acceptState = newEnd
startState = newStart
@ -229,10 +229,10 @@ internal class NFA private constructor(
epsilonVisited: Set<NFAState> = HashSet()
): NFASimulationResult {
updateCaptureGroups(editor, currentIndex, currentState)
currentState.assertion?.let {
val assertionResult = handleAssertion(editor, currentIndex, isCaseInsensitive, it)
if (!assertionResult.simulationResult) return NFASimulationResult(false, currentIndex)
else return simulate(editor, assertionResult.index, currentState.assertion!!.jumpTo, targetState, isCaseInsensitive)
for (assertion in currentState.assertions) {
val assertionResult = handleAssertion(editor, currentIndex, isCaseInsensitive, assertion)
return if (!assertionResult.simulationResult) NFASimulationResult(false, currentIndex)
else simulate(editor, assertionResult.index, assertion.jumpTo, targetState, isCaseInsensitive)
}
if (currentState === targetState) return NFASimulationResult(true, currentIndex)

View File

@ -21,10 +21,10 @@ internal class NFAState {
internal val transitions: ArrayList<NFATransition> = ArrayList()
/**
* If this is not null, then when simulation reaches this state,
* it has to check if this assertion is successful to continue.
* When a state has assertions, they have to be asserted
* in order to continue with the simulation.
*/
internal var assertion: NFAAssertion? = null
internal var assertions: ArrayList<NFAAssertion> = ArrayList()
/**
* Stores the numbers of the capture groups that start