Ë
    È[;jê/  ã                   ó~   — d Z ddlZ ej                  eeee¬«       ddlmZ ddlmZmZm	Z	  e«       Z
 G d„ d«      Zy)	z3
Python Lexical Analyser

Scanning an input stream
é    N)ÚBOLÚEOLÚEOFÚ	NOT_FOUNDé   )ÚErrors)r   r   r   c                   óŠ   — e Zd ZdZdd„Zd„ Zd„ Zd„ Zd„ Ze	j                  d„ «       Zd	efd
„Zd„ Zd„ Zdd„Zd„ Zed„ «       Zy)ÚScanneraÖ  
    A Scanner is used to read tokens from a stream of characters
    using the token set specified by a Plex.Lexicon.

    Constructor:

      Scanner(lexicon, stream, name = '')

        See the docstring of the __init__ method for details.

    Methods:

      See the docstrings of the individual methods for more
      information.

      read() --> (value, text)
        Reads the next lexical token from the stream.

      position() --> (name, line, col)
        Returns the position of the last token read using the
        read() method.

      begin(state_name)
        Causes scanner to change state.

      produce(value [, text])
        Causes return of a token value to the caller of the
        Scanner.

    Nc                 ó†  — d| _         d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _	        d| _
        || _        || _        || _        g | _        d| _        | j!                  d«       d| _        d| _        d| _        t$        | _        d| _        |�|d   |d    c| _        | _        yy)aƒ  
        Scanner(lexicon, stream, name = '')

          |lexicon| is a Plex.Lexicon instance specifying the lexical tokens
          to be recognised.

          |stream| can be a file object or anything which implements a
          compatible read() method.

          |name| is optional, and may be the name of the file being
          scanned or any other identifying string.
        r   Ú r   )r   r   r   Né   )ÚtraceÚbufferÚbuf_start_posÚnext_posÚcur_posÚcur_lineÚ	start_posÚcurrent_scanner_position_tupleÚlast_token_position_tupleÚtextÚ
state_nameÚlexiconÚstreamÚnameÚqueueÚinitial_stateÚbeginÚcur_line_startr   Úcur_charÚinput_state)Úselfr   r   r   Úinitial_poss        ú]G:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\Cython/Plex/Scanners.pyÚ__init__zScanner.__init__J   sÎ   € ð ˆŒ
àˆŒØˆÔØˆŒØˆŒØˆŒØˆŒØ.8ˆÔ+Ø)3ˆÔ&ØˆŒ	ØˆŒàˆŒØˆŒØˆŒ	ØˆŒ
Ø!ˆÔØ�
‰
�2ŒØˆŒØˆŒØˆÔÜˆŒØˆÔØÐ"Ø1<¸Q±À+ÈaÁ.ÀÐ.ˆDŒM˜4Õ.ð #ó    c                 ó  — | j                   }|sn| j                  «       \  | _        }|€"| j                  d«       | j	                  «        n/|j                  | | j                  «      }|�| j                  |«       |sŒn|d   \  }| _        |d= |S )a"  
        Read the next lexical token from the stream and return a
        tuple (value, text), where |value| is the value associated with
        the token as specified by the Lexicon, and |text| is the actual
        string read from the stream. Returns (None, '') on end of file.
        Nr   )r   Úscan_a_tokenr   ÚproduceÚeofÚperformr   )r"   r   ÚactionÚvalueÚresults        r$   ÚreadzScanner.readr   s‰   € ð —
‘
ˆÙØ $× 1Ñ 1Ó 3ÑˆDŒI�vØˆ~Ø—‘˜TÔ"Ø—‘•
àŸ™ t¨T¯Y©YÓ7�ØÐ$Ø—L‘L Ô'ò ð 27°q±Ñ.ˆ�Ô.Ø�!ˆHØˆr&   c                 óD   — | j                   j                  d||f|f«       y )Nr   )r   Úinsert)r"   Útokenr-   Úpositions       r$   ÚunreadzScanner.unread‡   s   € Ø�
‰
×Ñ˜!˜u e˜n¨hÐ7Õ8r&   c                 ó   — | j                   S ©N)r   ©r"   s    r$   Úget_current_scan_poszScanner.get_current_scan_posŠ   s   € à×2Ñ2Ð2r&   c                 óF  — | j                   | _        | j                  | j                  | j                   | j                  z
  f| _        | j                  «       }|�r| j                  r%t        d|| j                  | j                   fz  «       | j                  | j                  | j                  z
  | j                   | j                  z
   }||fS | j                   | j                  k(  r| j                  �| j                  t        u ryt        j                  | | j                  «      ‚)z–
        Read the next input sequence recognised by the machine
        and return (text, action). Returns ('', None) on end of
        file.
        z"Scanner: read: Performing %s %d:%d©r   N)r   r   r   r   r   r   Úrun_machine_inlinedr   Úprintr   r   r    r   r   ÚUnrecognizedInputr   )r"   r,   r   s      r$   r(   zScanner.scan_a_tokenŽ   sõ   € ð Ÿ™ˆŒà�I‰I�t—}‘} d§l¡l°T×5HÑ5HÑ&Hð/
ˆÔ+ð ×)Ñ)Ó+ˆØÐØ�zŠzÜÐ:Ø˜DŸN™N¨D¯L©Lð>:ñ :ô ;à—;‘;Ø—‘ ×!3Ñ!3Ñ3Ø—‘˜t×1Ñ1Ñ1ð3ˆDð ˜&�>Ð!à�|‰|˜tŸ~™~Ò-Ø—=‘=Ð(¨D¯M©M¼SÑ,@Ø%Ü×*Ñ*¨4°·±ÓAÐAr&   c           	      óž  — | j                   }| j                  }| j                  }| j                  }| j                  }| j
                  }| j                  }| j                  }| j                  }	t        |«      }
d\  }}}}}}}| j                  }	 |rt        d|d   ||t        |«      fz  «       |d   }|�|||||||f\  }}}}}}}|}|j                  |t        «      }|t        u r|xr |j                  d«      }|rí|rt        d|d   z  «       |}|dk(  r¡|}||	z
  }||
k  r||   }|dz  }nn| j                  |	z
  }| j                   j#                  d	«      }| j                  |d |z   }|| _        |	|z  }	|	| _        t        |«      }
||z  }|r||   }|dz  }nd
}|dk(  r	t$        }d}nd|s	t$        }d}nY|}nV|dk(  rd}d}nL|dk(  r|dz  }|x}}t&        }d}n5|dk(  r	t(        }d}n'd
}n$|rt        d«       |�|||||||f\  }}}}}}}nd}n�Œ‚|| _        || _        || _        || _        || _        || _        |r|�t        d|z  «       |S )z;
        Inlined version of run_machine for speed.
        )Nr   r   r   r   r   r   r   zState %d, %d/%d:%s -->Únumberr,   NÚelsezState %di   r   Ú
r   é   é   é   ÚblockedzDoing %s)r   r   r   r   r    r!   r   r   r   Úlenr   r<   ÚreprÚgetr   r   r   r/   r   r   r   )r"   Ústater   r   r   r    r!   r   r   r   Úbuf_lenÚb_actionÚ	b_cur_posÚ
b_cur_lineÚb_cur_line_startÚ
b_cur_charÚb_input_stateÚ
b_next_posr   r,   ÚcÚ	new_stateÚ	buf_indexÚdiscardÚdatas                            r$   r;   zScanner.run_machine_inlined§   sÿ  € ð
 ×(Ñ(ˆØ%)§\¡\ˆØ&*§m¡mˆØ,0×,?Ñ,?ˆØ—=‘=ˆØ#'×#3Ñ#3ˆØ&*§m¡mˆà—k‘kˆØ+/×+=Ñ+=ˆÜ%(¨£[ˆð
 $ñ 	aˆ�)˜ZÐ)9¸:À}ÐV`ð "ŸZ™ZˆØÙÜÐ.Ø˜(‘O [°'¼4À»>ð2Kñ Kô Lð ˜8‘_ˆFØÐ!à˜G X¨~¸xÈÐV^Ð^ñ i�˜) ZÐ1AÀ:È}Ð^hð ˆAØŸ	™	 !¤YÓ/ˆIØœIÑ%ØÒ3 %§)¡)¨FÓ"3�	áÙÜ˜* y°Ñ':Ñ:Ô;Ø!�à !Ò#Ø&�Gà (¨=Ñ 8�IØ  7Ò*Ø" 9Ñ-˜Ø  A™™à"&§.¡.°=Ñ"@˜Ø#Ÿ{™{×/Ñ/°Ó7˜Ø!%§¡¨W¨XÐ!6¸Ñ!=˜Ø&,˜œØ%¨Ñ0˜Ø-:˜Ô*Ü"% f£+˜Ø! WÑ,˜	ÙØ & yÑ 1˜AØ$¨™M™Hà "˜Aà˜D’yÜ#&˜Ø&'™ÙÜ#&˜Ø&'™à#$™Ø  AÒ%Ø#�HØ"#‘KØ  AÒ%Ø ‘M�HØ/7Ð7�N WÜ"�HØ"#‘KØ  AÒ%Ü"�HØ"#‘Kà!‘Hñ Ü˜)Ô$àÐ'ð " 9¨jÐ:JØ# ]°Jð@ñ6�V˜W h°Ø˜{©Hð "�FØñ[ ð` ˆŒØ ˆŒØ,ˆÔØ ˆŒØ&ˆÔØ ˆŒÙØÐ!Ü�j 6Ñ)Ô*Øˆr&   Úreturnc                 ó   — | j                   S )am  
        Return a tuple (name, line, col) representing the location of
        the last token read using the read() method. |name| is the
        name that was provided to the Scanner constructor; |line|
        is the line number in the stream (1-based); |col| is the
        position within the line of the first character of the token
        (0-based).
        ©r   r7   s    r$   r3   zScanner.position  s   € ð ×-Ñ-Ð-r&   c                 ó"   — | j                  «       S )zX
        Python accessible wrapper around position(), only for error reporting.
        )r3   r7   s    r$   Úget_positionzScanner.get_position$  s   € ð �}‰}‹Ðr&   c                 óR   — | j                   j                  |«      | _        || _        y)z8Set the current state of the scanner to the named state.N)r   Úget_initial_stater   r   )r"   r   s     r$   r   zScanner.begin*  s%   € ð �L‰L×*Ñ*¨:Ó6ð 	Ôà$ˆ�r&   c                 ór   — |€| j                   }| j                  j                  ||f| j                  f«       y)aÐ  
        Called from an action procedure, causes |value| to be returned
        as the token value from read(). If |text| is supplied, it is
        returned in place of the scanned text.

        produce() can be called more than once during a single call to an action
        procedure, in which case the tokens are queued up and returned one
        at a time by subsequent calls to read(), until the queue is empty,
        whereupon scanning resumes.
        N)r   r   Úappendr   )r"   r-   r   s      r$   r)   zScanner.produce0  s3   € ð ˆ<Ø—9‘9ˆDØ�
‰
×Ñ˜E 4˜=¨$×*MÑ*MÐNÕOr&   c                  ó   — y)z_
        Override this method if you want something to be done at
        end of file.
        N© r7   s    r$   r*   zScanner.eof?  s   € ð
 	r&   c                 ó    — | j                   d   S )Nr   rY   r7   s    r$   Ú
start_linezScanner.start_lineF  s   € à×-Ñ-¨aÑ0Ð0r&   r:   r6   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r%   r/   r4   r8   r(   ÚcythonÚfinalr;   Útupler3   r[   r   r)   r*   Úpropertyrc   ra   r&   r$   r
   r
      st   „ ñóp&QòPò*9ò3òBð2 ‡\�\ñoó ðoðb	.˜%ó 	.òò%óPòð ñ1ó ñ1r&   r
   )rg   rh   ÚdeclareÚobjectr   r   ÚRegexpsr   r   r   r   r
   ra   r&   r$   Ú<module>ro      s?   ðñó à €‡��6˜v¨6¸VÕ Då ß "Ñ "á‹H€	÷w1ò w1r&   