³ò
5ÒÇIc        
   @   s×   d  d g Z  d d k l Z l Z d d k Z d d k Z y3 e i d d e  d d k l Z l Z l	 Z	 Wn7 e
 j
 o+ e d  Z e d	  Z	 e d
  Z n Xd e f d     YZ d  e f d     YZ d S(   t   Readert   ReaderErrori˙˙˙˙(   t	   YAMLErrort   MarkNt    t   strict(   t   utf_8_decodet   utf_16_le_decodet   utf_16_be_decodec         C   s=   | o% t  |   d d j o |  d  }  n t i |  |  S(   Ni   i   i˙˙˙˙(   t   lent   codecsR   (   t   datat   errorst   finish(    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR   !   s    c         C   s=   | o% t  |   d d j o |  d  }  n t i |  |  S(   Ni   i   i˙˙˙˙(   R	   R
   R   (   R   R   R   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR   &   s    c         C   sÔ   | p½ d } xV | d j  oH | t  |   j  o5 d |  | d j o
 d j n o | d 8} q W| d j  oM | t  |   j  o: d |  | d j o
 d j n o |  | d  }  qÄ n t i |  |  S(   Ni    i   s   i   s   żs   Às   ŭ(   R	   R
   R   (   R   R   R   t   count(    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR   +   s    #' 'c           B   s   e  Z d    Z d   Z RS(   c         C   s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   namet	   charactert   positiont   encodingt   reason(   t   selfR   R   R   R   R   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyt   __init__=   s
    				c         C   sm   t  |  i t  o0 d |  i t |  i  |  i |  i |  i f Sn' d t |  i  |  i |  i |  i f Sd  S(   Ns>   '%s' codec can't decode byte #x%02x: %s
  in "%s", position %ds8   unacceptable character #x%04x: %s
  in "%s", position %d(   t
   isinstanceR   t   strR   t   ordR   R   R   (   R   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyt   __str__D   s    (   t   __name__t
   __module__R   R   (    (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR   ;   s   	c           B   st   e  Z d    Z d d  Z d d  Z d d  Z d   Z d   Z e i	 d  Z
 d	   Z d
   Z d d  Z RS(   c         C   s  d  |  _ d  |  _ d |  _ t |  _ d |  _ d |  _ d  |  _ d  |  _	 d  |  _
 d |  _ d |  _ d |  _ t | t  o' d |  _ |  i |  | d |  _ nk t | t  o  d |  _ | |  _ |  i   n; | |  _ t | d d  |  _ t |  _ d |  _ |  i   d  S(	   Ni    u    s   <unicode string>u    s   <string>R   s   <file>R   (   t   NoneR   t   streamt   stream_pointert   Truet   eoft   buffert   pointert
   raw_buffert
   raw_decodeR   t   indext   linet   columnR   t   unicodet   check_printableR   t   determine_encodingt   getattrt   False(   R   R   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR   ^   s2    																		i    c         C   sS   y |  i  |  i | SWn6 t j
 o* |  i | d  |  i  |  i | Sn Xd  S(   Ni   (   R!   R"   t
   IndexErrort   update(   R   R%   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyt   peekz   s
    i   c         C   sF   |  i  | t |  i  j o |  i |  n |  i |  i  |  i  | !S(   N(   R"   R	   R!   R.   (   R   t   length(    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyt   prefix   s    c         C   sî   |  i  | d t |  i  j o |  i | d  n xħ | oİ |  i |  i  } |  i  d 7_  |  i d 7_ | d j p$ | d j o3 |  i |  i  d j o |  i d 7_ d |  _ n! | d j o |  i d 7_ n | d 8} q9 Wd  S(   Ni   u	   
Ââ¨âİu   u   
i    u   ïğż(   R"   R	   R!   R.   R%   R&   R'   (   R   R0   t   ch(    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyt   forward   s    !
$c         C   sh   |  i  d  j o/ t |  i |  i |  i |  i |  i |  i  Sn& t |  i |  i |  i |  i d  d   Sd  S(   N(	   R   R   R   R   R%   R&   R'   R!   R"   (   R   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyt   get_mark   s
    c         C   sĊ   x0 |  i  o$ t |  i  d j  o |  i   q Wt |  i t  pn |  i i t i  o t	 |  _
 d |  _ q´ |  i i t i  o t |  _
 d |  _ q´ t |  _
 d |  _ n |  i d  d  S(   Ni   s	   utf-16-les	   utf-16-bes   utf-8i   (   R    R	   R#   t
   update_rawR   R(   t
   startswithR
   t   BOM_UTF16_LER   R$   R   t   BOM_UTF16_BER   R   R.   (   R   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR*      s    $			u   [^	
 -~ÂÂ -íżî-ïż½]c         C   so   |  i  i |  } | oR | i   } |  i t |  i  |  i | i   } t |  i	 | | d d   n d  S(   NR(   s"   special characters are not allowed(
   t   NON_PRINTABLEt   searcht   groupR%   R	   R!   R"   t   startR   R   (   R   R   t   matchR   R   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR)   ­   s    'c         C   s  |  i  d  j o d  Sn |  i |  i |  _ d |  _ xWt |  i  | j  o@|  i p |  i   n |  i d  j	 oĴ y% |  i |  i  d |  i  \ } } Wq6t j
 ot } | i	 | i
 } |  i d  j	 o! |  i t |  i   | i
 } n
 | i
 } t |  i | | | i | i   q6Xn |  i  } t |  } |  i |  |  i | 7_ |  i  | |  _  |  i o |  i d 7_ d  |  _  Pq7 q7 Wd  S(   Ni    R   u    (   R#   R   R!   R"   R	   R    R5   R$   t   UnicodeDecodeErrort   objectR<   R   R   R   R   R   R   R)   (   R   R0   R   t	   convertedt   excR   R   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR.   µ   s6    	
!		
	i   c         C   sN   |  i  i |  } | o( |  i | 7_ |  i t |  7_ n
 t |  _ d  S(   N(   R   t   readR#   R   R	   R   R    (   R   t   sizeR   (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR5   Ô   s
    (   R   R   R   R/   R1   R3   R4   R*   t   ret   compileR9   R)   R.   R5   (    (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pyR    P   s   					(   t   __all__t   errorR   R   R
   RD   R   R,   R   R   t	   TypeErrorR   R?   R    (    (    (    s!   /p/zhu/06/nlp/nltk/yaml/reader.pys   <module>   s    