ó
    G±‰jµ  ã                   ót   • S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SrSr " S S	5      r	 " S
 S5      r
g)z9
Python Lexical Analyser

Lexical Analyser Specification
é   )ÚActions)ÚDFA)ÚErrors)ÚMachines)ÚRegexpsé   c                   ó&   • \ rS rSrSrSrSrS rSrg)ÚStateé   z“
This class is used as part of a Plex.Lexicon specification to
introduce a user-defined state.

Constructor:

   State(name, token_specifications)
Nc                 ó   • Xl         X l        g ©N©ÚnameÚtokens)Úselfr   r   s      Ú¢C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\Cython/Plex/Lexicons.pyÚ__init__ÚState.__init__   s   € ØŒ	Ø�ó    r   )	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   Ú__static_attributes__© r   r   r
   r
      s   † ñð €DØ€Fõr   r
   c                   ó<   • \ rS rSrSrSrSrS	S jrS rS r	S r
Srg)
ÚLexiconé$   aÇ  
Lexicon(specification) builds a lexical analyser from the given
|specification|. The specification consists of a list of
specification items. Each specification item may be either:

   1) A token definition, which is a tuple:

         (pattern, action)

      The |pattern| is a regular axpression built using the
      constructors defined in the Plex module.

      The |action| is the action to be performed when this pattern
      is recognised (see below).

   2) A state definition:

         State(name, tokens)

      where |name| is a character string naming the state,
      and |tokens| is a list of token definitions as
      above. The meaning and usage of states is described
      below.

Actions
-------

The |action| in a token specification may be one of three things:

   1) A function, which is called as follows:

         function(scanner, text)

      where |scanner| is the relevant Scanner instance, and |text|
      is the matched text. If the function returns anything
      other than None, that value is returned as the value of the
      token. If it returns None, scanning continues as if the IGNORE
      action were specified (see below).

    2) One of the following special actions:

       IGNORE means that the recognised characters will be treated as
              white space and ignored. Scanning will continue until
              the next non-ignored token is recognised before returning.

       TEXT   causes the scanned text itself to be returned as the
              value of the token.

    3) Any other value, which is returned as the value of the token.

States
------

At any given time, the scanner is in one of a number of states.
Associated with each state is a set of possible tokens. When scanning,
only tokens associated with the current state are recognised.

There is a default state, whose name is the empty string. Token
definitions which are not inside any State definition belong to
the default state.

The initial state of the scanner is the default state. The state can
be changed in one of two ways:

   1) Using Begin(state_name) as the action of a token.

   2) Calling the begin(state_name) method of the Scanner.

To change back to the default state, use '' as the state name.
Nc                 ó  • [        U[        5      (       d  [        R                  " S5      e[        R
                  " 5       nUR                  S5      nSnU H¢  n[        U[        5      (       aG  UR                  UR                  5      nUR                   H  n	U R                  XHX–5        US-  nM     M_  [        U[        5      (       a  U R                  XEXv5        US-  nM�  [        R                  " US5      e   U(       a,  US-  (       a"  UR                  S5        UR                  U5        [        R                   " XCS-  S:H  =(       a    US9n
U(       a,  US-  (       a"  UR                  S	5        U
R                  U5        X l        g )
Nz Scanner definition is not a listÚ r   z5Expected a token definition (tuple) or State instancez
============= NFA ===========
é   )Údebugr   z
============= DFA ===========
)Ú
isinstanceÚlistr   ÚInvalidScannerr   ÚMachineÚnew_initial_stater
   r   r   Úadd_token_to_machineÚtupleÚInvalidTokenÚwriteÚdumpr   Ú
nfa_to_dfaÚmachine)r   Úspecificationsr#   Údebug_flagsÚnfaÚdefault_initial_stateÚtoken_numberÚspecÚuser_initial_stateÚtokenÚdfas              r   r   ÚLexicon.__init__o   sJ  € Ü˜.¬$×/Ñ/Ü×'Ò'Ð(JÓKÐKä×ÒÓ ˆØ #× 5Ñ 5°bÓ 9ÐØˆã"ˆDÜ˜$¤×&Ñ&Ø%(×%:Ñ%:¸4¿9¹9Ó%EÐ"Ø!Ÿ[œ[�EØ×-Ñ-Ø°ôFà  AÑ%’Ló )ô ˜D¤%×(Ñ(Ø×)Ñ)Ø°ôDà Ñ!’ä×)Ò)Ø ØKóMð Mñ #ö  �k A—oØ�K‰KÐ;Ô<Ø�H‰H�UŒOä�nŠn˜S°q©¸QÑ(>×(HÀ5ÑIˆæ�k A—oØ�K‰KÐ;Ô<Ø�H‰H�UŒOà�r   c                 óÈ  •  U R                  U5      u  pV[        U[        R                  5      (       a  UnO# UR                    [        R
                  " U5      nUR                  5       nUR                  XUSSS9  UR                  Xt* S9  g ! [         a    [        R                  " U5      n NUf = f! [        R                   a  n	U	R                  SXI4-  5      eS n	A	ff = f)Nr   é    )Ú	match_bolÚnocase)ÚpriorityzToken number %d: %s)Úparse_token_definitionr$   r   ÚActionÚ__call__ÚCallÚAttributeErrorÚReturnÚ	new_stateÚbuild_machineÚ
set_actionr   Ú	PlexErrorÚ	__class__)
r   r/   Úinitial_stateÚ
token_specr4   ÚreÚaction_specÚactionÚfinal_stateÚes
             r   r)   ÚLexicon.add_token_to_machine“   sÜ   € ð	IØ $× ;Ñ ;¸JÓ GÑˆRÜ˜+¤w§~¡~×6Ñ6Ø$‘ð7Ø×(Ò(ô %Ÿ\š\¨+Ó6�FØ!×+Ñ+Ó-ˆKØ×Ñ˜W°[Ø'(°ð ñ 4à×"Ñ" 6°MÐ"ÒBøô &ó 9Ü$Ÿ^š^¨KÓ8’Fð9ûô ×Ñó 	IØ—+‘+Ð3°|Ð6GÑGÓHÐHûð	Iús;   ‚5B3 ¸B ÁAB3 Â B0Â-B3 Â/B0Â0B3 Â3C!ÃCÃC!c                 ó  • [        U[        5      (       d  [        R                  " S5      e[	        U5      S:w  a  [        R                  " S5      eUu  p#[        U[
        R                  5      (       d  [        R                  " S5      eX#4$ )NzToken definition is not a tupler   z)Wrong number of items in token definitionzPattern is not an RE instance)r$   r*   r   r+   Úlenr   ÚRE)r   rK   ÚpatternrN   s       r   r?   ÚLexicon.parse_token_definition¦   sr   € Ü˜*¤e×,Ñ,Ü×%Ò%Ð&GÓHÐHÜˆz‹?˜aÓÜ×%Ò%Ð&QÓRÐRà$‰ˆÜ˜'¤7§:¡:×.Ñ.Ü×%Ò%Ð&EÓFÐFØÐ Ð r   c                 ó8   • U R                   R                  U5      $ r   )r/   Úget_initial_state)r   r   s     r   rX   ÚLexicon.get_initial_state±   s   € Ø�|‰|×-Ñ-¨dÓ3Ð3r   )r/   )Né   )r   r   r   r   r   r/   Útablesr   r)   r?   rX   r   r   r   r   r   r   $   s+   † ñEðN €GØ€Fô"òHIò&	!õ4r   r   N)r   r!   r   r   r   r   r   ÚDUMP_NFAÚDUMP_DFAr
   r   r   r   r   Ú<module>r^      s=   ðñõ Ý Ý Ý Ý ð €Ø€÷ñ ÷$N4ò N4r   