ķ
Ąŧ\c           @   s0   d  e  f d     YZ d e  f d     YZ d S(   t   Statec           B   s&   e  Z d  Z d d d  Z d   Z RS(   s-  
    A representation of a state managed by a ``StateMachine``.

    Attributes:
        name (instance of FreeGroupElement or string) -- State name which is also assigned to the Machine.
        transisitons (OrderedDict) -- Represents all the transitions of the state object.
        state_type (string) -- Denotes the type (accept/start/dead) of the state.
        rh_rule (instance of FreeGroupElement) -- right hand rule for dead state.
        state_machine (instance of StateMachine object) -- The finite state machine that the state belongs to.
    c         C   s5   | |  _  i  |  _ | |  _ | d |  _ | |  _ d  S(   Ni    (   t   namet   transitionst   state_machinet
   state_typet   rh_rule(   t   selfR   R   R   R   (    (    sF   lib/python2.7/site-packages/sympy/combinatorics/rewritingsystem_fsm.pyt   __init__   s
    			c         C   s   | |  j  | <d S(   sZ  
        Add a transition from the current state to a new state.

        Keyword Arguments:
            letter -- The alphabet element the current state reads to make the state transition.
            state -- This will be an instance of the State object which represents a new state after in the transition after the alphabet is read.

        N(   R   (   R   t   lettert   state(    (    sF   lib/python2.7/site-packages/sympy/combinatorics/rewritingsystem_fsm.pyt   add_transition   s    	N(   t   __name__t
   __module__t   __doc__t   NoneR   R
   (    (    (    sF   lib/python2.7/site-packages/sympy/combinatorics/rewritingsystem_fsm.pyR       s   
t   StateMachinec           B   s/   e  Z d  Z d   Z d d d  Z d   Z RS(   sū   
    Representation of a finite state machine the manages the states and the transitions of the automaton.

    Attributes:
        states (dictionary) -- Collection of all registered `State` objects.
        name (str) -- Name of the state machine.
    c         C   s2   | |  _  | |  _ i  |  _ |  j d d d d  S(   Nt   startR   t   s(   R   t   automaton_alphabett   statest	   add_state(   R   R   R   (    (    sF   lib/python2.7/site-packages/sympy/combinatorics/rewritingsystem_fsm.pyR   (   s    			c         C   s&   t  | |  | |  } | |  j | <d S(   sx  
        Instantiate a state object and stores it in the 'states' dictionary.

        Arguments:
            state_name (instance of FreeGroupElement or string) -- name of the new states.
            state_type (string) -- Denotes the type (accept/start/dead) of the state added.
            rh_rule (instance of FreeGroupElement) -- right hand rule for dead state.

        N(   R    R   (   R   t
   state_nameR   R   t	   new_state(    (    sF   lib/python2.7/site-packages/sympy/combinatorics/rewritingsystem_fsm.pyR   .   s    
c         C   s   d |  j  S(   Ns   %s(   R   (   R   (    (    sF   lib/python2.7/site-packages/sympy/combinatorics/rewritingsystem_fsm.pyt   __repr__;   s    N(   R   R   R   R   R   R   R   (    (    (    sF   lib/python2.7/site-packages/sympy/combinatorics/rewritingsystem_fsm.pyR      s   	N(   t   objectR    R   (    (    (    sF   lib/python2.7/site-packages/sympy/combinatorics/rewritingsystem_fsm.pyt   <module>   s   