/** * Adds all the epsilon transition targets to the specified * queue. * * @param queue the state queue */ public void MatchEmpty(NFAStateQueue queue) { NFATransition trans; NFAState target; for (int i = 0; i < outgoing.Length; i++) { trans = outgoing[i]; if (trans is NFAEpsilonTransition) { target = trans.state; queue.AddLast(target); if (target.epsilonOut) { target.MatchEmpty(queue); } } } }
/** * Attempts a match on each of the transitions leading from * this state. If a match is found, its state will be added * to the queue. If the initial match flag is set, epsilon * transitions will also be matched (and their targets called * recursively). * * @param ch the character to match * @param queue the state queue * @param initial the initial match flag */ public void MatchTransitions(char ch, NFAStateQueue queue, bool initial) { NFATransition trans; NFAState target; for (int i = 0; i < outgoing.Length; i++) { trans = outgoing[i]; target = trans.state; if (initial && trans is NFAEpsilonTransition) { target.MatchTransitions(ch, queue, true); } else if (trans.Match(ch)) { queue.AddLast(target); if (target.epsilonOut) { target.MatchEmpty(queue); } } } }