// Increment until we hit a character matching the start state
ifstart.isEmpty==false{
forint(str[i])!=start.content{
fori<len(str)&&int(str[i])!=start.content{
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
}
currentStates=append(currentStates,start)
startIdx=i
i++// Advance to next character so that we can check for transitions
isEmptybool// If it is empty - Union operator states will be empty
isEmptybool// If it is empty - Union operator and Kleene star states will be empty
isLastbool// If it is the last state (acept state)
output[]*State// The outputs of the current state ie. the 'outward arrows'. A union operator state will have more than one of these.
transitionsmap[int][]*State// Transitions to different states (maps a character (int representation) to a _list of states. This is useful if one character can lead multiple states eg. ab|aa)
isKleenebool// Identifies whether current node is a 0-state representing Kleene star
iflen(state.transitions)==1&&state.isKleene{// A State representing a Kleene Star has a transition going out, which loops back to it. If that is the only transition (and it contains only one state), then it must be a last-state
for_,v:=rangestate.transitions{// Should only loop once