Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/Cython/Plex/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/Cython/Plex/__pycache__/DFA.cpython-37.opt-1.pyc

B

Z��Z|�@sfddlmZddlmZddlmZddlmZddd�Zd	d
�Zdd�Z	d
d�Z
Gdd�de�ZdS)�)�absolute_import�)�Machines)�LOWEST_PRIORITY)�
TransitionMapNc	Cs�t��}t|�}x0|j��D]"\}}|�t|��}|�||�qWx�|jD]x}t	�}xB|�
|�D]4}x.|j��D] \}}	|rp|	rp|�|t
|	��qpWq`Wx(|��D]\}}
|�|||�|
��q�WqJW|r�|�d�|�|�|S)zg
    Given a nondeterministic Machine, return a new equivalent
    Machine which is deterministic.
    z
===== State Mapping =====
)rZFastMachine�StateMapZinitial_states�items�
old_to_new�epsilon_closureZmake_initial_state�statesr�
new_to_old�transitionsZadd_set�set_epsilon_closureZadd_transitions�write�dump)Zold_machine�debug�new_machineZ	state_map�keyZ	old_state�	new_stater
�eventZold_target_statesZ
old_states�r�B/opt/alt/python37/lib64/python3.7/site-packages/Cython/Plex/DFA.py�
nfa_to_dfas"

rcCs0i}x&|D]}xt|�D]}d||<qWq
W|S)zc
    Given a set of states, return the union of the epsilon
    closures of its member states.
    r)r
)�	state_set�resultZstate1�state2rrrr6s

rcCs&|j}|dkr"i}||_t||�|S)zW
    Return the set of states reachable from the given state
    by epsilon moves.
    N)r
�add_to_epsilon_closure)�staterrrrr
Bs
r
cCs>|�|d�s:d||<|j��}|r:x|D]}t||�q(WdS)zd
    Recursively add to |state_set| states reachable from the given state
    by epsilon moves.
    rrN)�getr
Zget_epsilonr)rrZstate_set_2rrrrrPs

rc@sLeZdZdZdZdZdZdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)rz�
    Helper class used by nfa_to_dfa() to map back and forth between
    sets of states from the old machine and states of the new machine.
    NcCs||_i|_i|_dS)N)r�old_to_new_dict�new_to_old_dict)�selfrrrr�__init__fszStateMap.__init__cCsN|�|�}|j�|d�}|sJ|�|�}|j�|�}||j|<||jt|�<|S)aX
        Return the state of the new machine corresponding to the
        set of old machine states represented by |state_set|. A new
        state will be created if necessary. If any of the old states
        are accepting states, the new state will be an accepting state
        with the highest priority action from the old states.
        N)�make_keyrr�highest_priority_actionrrr �id)r!�
old_state_setrr�actionrrrr	ks


zStateMap.old_to_newcCs2d}t}x$|D]}|j}||kr|j}|}qW|S)N)rZaction_priorityr')r!rZbest_actionZ
best_priorityrZpriorityrrrr$~s
z StateMap.highest_priority_actioncCs|jt|�S)z<Given a new state, return a set of corresponding old states.)r r%)r!rrrrr�szStateMap.new_to_oldcCst|�}|��t|�S)zv
        Convert a set of states into a uniquified
        sorted tuple suitable for use as a dictionary key.
        )�list�sort�tuple)r!rZlstrrrr#�szStateMap.make_keycCsJddlm}x8|jjD],}|jt|�}|�d|d||�f�qWdS)Nr)�
state_set_strz   State %s <-- %s
Znumber)�Transitionsr+rrr r%r)r!�filer+rr&rrrr�s
z
StateMap.dump)
�__name__�
__module__�__qualname__�__doc__rrr r"r	r$rr#rrrrrr]s	r)N)
Z
__future__r�rrr,rrrr
r�objectrrrrr�<module>	s
&