Пример #1
0
        private NFAState FindUniqueCharTransition(char ch)
        {
            NFATransition res = null;
            NFATransition trans;

            for (int i = 0; i < Outgoing.Length; i++)
            {
                trans = Outgoing[i];
                if (trans.Match(ch) && trans is NFACharTransition)
                {
                    if (res != null)
                    {
                        return(null);
                    }

                    res = trans;
                }
            }

            for (int i = 0; res != null && i < Outgoing.Length; i++)
            {
                trans = Outgoing[i];
                if (trans != res && trans.State == res.State)
                {
                    return(null);
                }
            }

            return(res?.State);
        }
Пример #2
0
        public NFAState AddOut(NFATransition trans)
        {
            Array.Resize(ref Outgoing, Outgoing.Length + 1);
            Outgoing[Outgoing.Length - 1] = trans;
            if (trans is NFAEpsilonTransition)
            {
                EpsilonOut = true;
            }

            return(trans.State);
        }
Пример #3
0
 public void AddIn(NFATransition trans)
 {
     Array.Resize(ref Incoming, Incoming.Length + 1);
     Incoming[Incoming.Length - 1] = trans;
 }