コード例 #1
0
        /// <summary>
        /// Adds all the epsilon transition targets to the specified
        /// queue.
        /// </summary>
        /// <param name="queue">The state queue</param>
        public void MatchEmpty(NFAStateQueue queue)
        {
            NFAState target;

            foreach (var trans in this.outgoing)
            {
                if (trans is NFAEpsilonTransition)
                {
                    target = trans.State;
                    queue.AddLast(target);
                    if (target.epsilonOut)
                    {
                        target.MatchEmpty(queue);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 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).
        /// </summary>
        /// <param name="ch">The character to match</param>
        /// <param name="queue">The state queue</param>
        /// <param name="initial">The initial match flag</param>
        public void MatchTransitions(char ch, NFAStateQueue queue, bool initial)
        {
            NFAState target;

            foreach (var trans in this.outgoing)
            {
                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);
                    }
                }
            }
        }