Ë
    Ç[;jË  ã                   ó,  — d Z ddlZddlmZ ddlmZ ddlmZ ej                  rddlm	Z	m
Z
 ddlmZ nddlm	Z	m
Z
 ddlmZ dd„Zej                   d	ed
efd„«       Zej                   de	d
efd„«       Zej                   d	ede	fd„«       Z G d„ d«      Zy)z0
Python Lexical Analyser

Converting NFA to DFA
é    Né   )ÚMachines)ÚLOWEST_PRIORITY)ÚTransitionMap)ÚNodeÚFastMachinec           	      ó„  — t        j                  «       }t        |«      }| j                  j	                  «       D ]1  \  }}|j                  t        |«      «      }|j                  ||«       Œ3 |j                  D ]Ÿ  }t        «       }|j                  |«      D ]E  }|j                  j	                  «       D ]&  \  }}	|sŒ	|	sŒ|j                  |t        |	«      «       Œ( ŒG |j	                  «       D ]'  \  }}
|j                  |||j                  |
«      «       Œ) Œ¡ |r"|j                  d«       |j!                  |«       |S )zg
    Given a nondeterministic Machine, return a new equivalent
    Machine which is deterministic.
    z
===== State Mapping =====
)r   r   ÚStateMapÚinitial_statesÚitemsÚ
old_to_newÚepsilon_closureÚmake_initial_stateÚstatesr   Ú
new_to_oldÚtransitionsÚadd_setÚset_epsilon_closureÚadd_transitionsÚwriteÚdump)Úold_machineÚdebugÚnew_machineÚ	state_mapÚkeyÚ	old_stateÚ	new_stater   ÚeventÚold_target_statesÚ
old_statess              úXG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\Cython/Plex/DFA.pyÚ
nfa_to_dfar#      s'  € ô  (×3Ñ3Ó5€KÜ" ;Ó/€Ið
 (×6Ñ6×<Ñ<Ö>ÑˆˆiØ×(Ñ(¬¸Ó)CÓDˆ	Ø×&Ñ& s¨IÕ6ð ?ð !×'Ô'ˆ	Ü#“oˆØ"×-Ñ-¨iÖ8ˆIØ,5×,AÑ,A×,GÑ,GÖ,IÑ(�Ð(ÚÒ.Ø×'Ñ'¨Ô/BÐCTÓ/UÕVñ -Jð 9ð "-×!2Ñ!2Ö!4ÑˆE�:Ø×'Ñ'¨	°5¸)×:NÑ:NÈzÓ:ZÕ[ñ "5ð (ñ Ø�‰Ð3Ô4Ø�‰�uÔØÐó    Ú	state_setÚreturnc                 ój   — t        «       }| D ]#  }t        |«      D ]  }|j                  |«       Œ Œ% |S )zc
    Given a set of states, return the union of the epsilon
    closures of its member states.
    )Úsetr   Úadd)r%   ÚresultÚstate1Ústate2s       r"   r   r   ?   s7   € ô ‹U€FÛˆÜ% fÖ-ˆFØ�J‰J�vÕñ .ð ð €Mr$   Ústatec                 ó\   — | j                   }|€t        «       }|| _         t        || «       |S )zW
    Return the set of states reachable from the given state
    by epsilon moves.
    )r   r(   Úadd_to_epsilon_closure)r-   r*   s     r"   r   r   L   s2   € ð ×"Ñ"€FØ€~Ü“ˆØ &ˆÔÜ˜v uÔ-Ø€Mr$   c                 ó�   — || vrB| j                  |«       |j                  j                  «       }|r|D ]  }t        | |«       Œ yyy)zd
    Recursively add to |state_set| states reachable from the given state
    by epsilon moves.
    N)r)   r   Úget_epsilonr/   )r%   r-   Ústate_set_2r,   s       r"   r/   r/   [   sM   € ð �IÑØ�‰�eÔØ×'Ñ'×3Ñ3Ó5ˆÙÛ%�Ü& y°&Õ9ñ &ð ð r$   c                   óF   — e Zd ZdZd„ Zdefd„Zdefd„Zd„ Zdefd„Z	d	„ Z
y
)r
   z�
    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.
    c                 ó.   — || _         i | _        i | _        y ©N)r   Úold_to_new_dictÚnew_to_old_dict)Úselfr   s     r"   Ú__init__zStateMap.__init__r   s   € Ø&ˆÔØ!ˆÔØ!ˆÕr$   Úold_state_setc                 ó
  — | j                  |«      }| j                  j                  |d«      }|sS| j                  |«      }| j                  j                  |«      }|| j                  |<   || j                  t        |«      <   |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_keyr6   ÚgetÚhighest_priority_actionr   r   r7   Úid)r8   r:   r   r   Úactions        r"   r   zStateMap.old_to_neww   s}   € ð �m‰m˜MÓ*ˆØ×(Ñ(×,Ñ,¨S°$Ó7ˆ	ÙØ×1Ñ1°-Ó@ˆFØ×(Ñ(×2Ñ2°6Ó:ˆIØ(1ˆD× Ñ  Ñ%Ø2?ˆD× Ñ ¤ I£Ñ/ØÐr$   r%   c                 ód   — d }t         }|D ]"  }|j                  }||kD  sŒ|j                  }|}Œ$ |S r5   )r   Úaction_priorityr@   )r8   r%   Úbest_actionÚbest_priorityr-   Úprioritys         r"   r>   z StateMap.highest_priority_actionˆ   s?   € ØˆÜ'ˆãˆEØ×,Ñ,ˆHØ˜-Ó'Ø#Ÿl™l�Ø (‘ð	 ð
 Ðr$   c                 ó2   — | j                   t        |«         S )z<Given a new state, return a set of corresponding old states.)r7   r?   )r8   r   s     r"   r   zStateMap.new_to_old“   s   € à×#Ñ#¤B y£MÑ2Ð2r$   c                 ó*   — t        t        |«      «      S )zv
        Convert a set of states into a uniquified
        sorted tuple suitable for use as a dictionary key.
        )ÚtupleÚsorted)r8   r%   s     r"   r<   zStateMap.make_key—   s   € ô
 ”V˜IÓ&Ó'Ð'r$   c           	      ó¸   — ddl m} | j                  j                  D ];  }| j                  t        |«         }|j                  d|d   ›d ||«      ›d�«       Œ= y )Nr   )Ústate_set_strz	   State Únumberz <-- Ú
)ÚTransitionsrK   r   r   r7   r?   r   )r8   ÚfilerK   r   r:   s        r"   r   zStateMap.dumpž   sQ   € Ý.à×)Ñ)×0Ô0ˆIØ ×0Ñ0´°I³Ñ?ˆMØ�JŠJØ˜(Ó#¡]°=Õ%AðCõ Dñ 1r$   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r9   r(   r   r>   r   r<   r   © r$   r"   r
   r
   l   s;   „ ñò
"ð
¨ó ð"	°ó 	ò3ð( #ó (óDr$   r
   r5   )rS   ÚcythonÚ r   r   rN   r   ÚcompiledÚ$cython.cimports.Cython.Plex.Machinesr   r   Ú'cython.cimports.Cython.Plex.TransitionsÚtype_TransitionMapÚCython.Plex.MachinesÚCython.Plex.Transitionsr#   Úcfuncr(   r   r   r/   r
   rT   r$   r"   Ú<module>r^      s¯   ðñó Ý Ý %Ý &à	‡?‚?ßFÞ[ç6ÝKó'ðT ‡�ð	 3ð 	¨3ò 	ó ð	ð ‡�ð˜4ð  Cò ó ðð ‡�ð: cð :°$ò :ó ð:÷ 8Dò 8Dr$   