Example #1
0
        /**
         * Finds a unique character transition if one exists. The
         * transition must be the only matching single character
         * transition and no other transitions may reach the same
         * state.
         *
         * @param ch             the character to search for
         *
         * @return the unique transition state found, or
         *         null if not found
         */
        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 == null) ? null : res.state);
        }
Example #2
0
 /**
  * Adds a new outgoing transition.
  *
  * @param trans          the transition to add
  *
  * @return the transition target state
  */
 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);
 }
Example #3
0
 /**
  * Adds a new outgoing transition.
  *
  * @param trans          the transition to add
  *
  * @return the transition target state
  */
 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;
 }
Example #4
0
 /**
  * Adds a new incoming transition.
  *
  * @param trans          the transition to add
  */
 public void AddIn(NFATransition trans)
 {
     Array.Resize(ref incoming, incoming.Length + 1);
     incoming[incoming.Length - 1] = trans;
 }
Example #5
0
 /**
  * Adds a new incoming transition.
  *
  * @param trans          the transition to add
  */
 public void AddIn(NFATransition trans)
 {
     Array.Resize(ref incoming, incoming.Length + 1);
     incoming[incoming.Length - 1] = trans;
 }