private bool HasEmits(ACState currentState) { var emits = currentState.GetEmits(); if (emits != null && emits.MoveNext()) { return(true); } return(false); }
private void StoreEmits(int pos, ACState currentState, List <ACEmit> collectedEmits) { var emits = currentState.GetEmits(); if (emits != null) { while (emits.MoveNext()) { collectedEmits.Add(new ACEmit(pos - emits.Current.Length + 1, pos, emits.Current)); } } }
public void ConstructFailingStates() { if (m_FialingStatesConstructed) { return; } m_FialingStatesConstructed = true; Queue <ACState> queue = new Queue <ACState>(); var childStates = m_RootState.GetStates(); if (childStates != null) { foreach (var depthOneState in childStates) { depthOneState.SetFailingState(m_RootState); queue.Enqueue(depthOneState); } } while (queue.Count > 0) { ACState currentState = queue.Dequeue(); var transitions = currentState.GetTransitions(); if (transitions != null) { foreach (var transition in transitions) { ACState targetState = currentState.NextState(transition); queue.Enqueue(targetState); ACState traceFailureState = currentState.GetFailingState(); while (traceFailureState.NextState(transition) == null) { traceFailureState = traceFailureState.GetFailingState(); } ACState newFailureState = traceFailureState.NextState(transition); targetState.SetFailingState(newFailureState); targetState.AddEmits(newFailureState.GetEmits()); } } } }