Working on multiple matching

master
Aadhavan Srinivasan 2 months ago
parent 11dd6aeb7c
commit 60b798d904

@ -23,13 +23,15 @@ func match(start *State, str string) (startIdx int, endIdx int, matched bool) {
currentStates := make([]*State, 0) currentStates := make([]*State, 0)
tempStates := make([]*State, 0) // Used to store states that should be used in next loop iteration tempStates := make([]*State, 0) // Used to store states that should be used in next loop iteration
i := 0 // Index in string i := 0 // Index in string
// Increment until we hit a character matching the start state // Increment until we hit a character matching the start state (assuming not 0-state)
if start.isEmpty == false { if start.isEmpty == false {
for i < len(str) && int(str[i]) != start.content { for i < len(str) && int(str[i]) != start.content {
i++ i++
} }
i++ // Advance to next character (if we aren't at a 0-state, which doesn't match anything), so that we can check for transitions. If we advance at a 0-state, we will never get a chance to match the first character i++ // Advance to next character (if we aren't at a 0-state, which doesn't match anything), so that we can check for transitions. If we advance at a 0-state, we will never get a chance to match the first character
} }
// TODO - If start state is kleene star, try to match the next state
currentStates = append(currentStates, start) currentStates = append(currentStates, start)
startIdx = i startIdx = i

Loading…
Cancel
Save