³ò
&¤Kc        	   @   s3  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k i Z g  Z d e f d „  ƒ  YZ	 d e
 f d „  ƒ  YZ d „  Z e i d e i ƒ Z d „  Z d	 „  Z d
 „  Z d e
 f d „  ƒ  YZ d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(   iÿÿÿÿNt
   ParseErrorc           B   s#   e  Z d d e d  „ Z d „  Z RS(   c         C   s°  d | t  | ƒ | f } | os| i d ƒ } t | ƒ d j oÎ d  }	 d }
 x¢ |
 t | d ƒ j  oŠ | d |
 } | d j o |
 d 7}
 nT | |	 j o
 d  }	 n= |	 o n2 | d j p | d j p | d j o
 | }	 n |
 d 7}
 qQ W|	 o | d	 |	 7} qn x€ | D]t } | d | 7} | d  j	 oG | t | ƒ j o  | d d
 | d 7} d  } q| t | ƒ 8} n | o PqqWn | |  _ t i |  | ƒ d  S(   Nu   On line %d of %s: %ss   
i   i    s   \t   `s   't   "s:   
(Perhaps you left out a %s at the end of the first line.)t    t   ^(   t   unicode_filenamet   splitt   lent   Nonet   messaget	   Exceptiont   __init__(   t   selft   filenamet   numbert   msgt   linet   post   firstR	   t   linest   open_stringt   it   ct   l(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR   &   s>    
'
 
	c         C   s   |  i  S(   N(   R	   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   __unicode__R   s    N(   t   __name__t
   __module__R   t   FalseR   R   (    (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR    $   s   ,t   LineNumberHolderc           B   s   e  Z d  Z d „  Z RS(   s)   
    Holds the expected line number.
    c         C   s   d |  _  d  S(   Ni    (   R   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR   [   s    (   R   R   t   __doc__R   (    (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR   V   s   c         C   s[   t  |  t ƒ o |  Sn y |  i d ƒ SWn n Xy |  i d ƒ SWn n X|  i d ƒ S(   s4   
    Converts the supplied filename to unicode.
    t   mbcss   utf-8s   latin-1(   t
   isinstancet   unicodet   decode(   t   fn(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR   ^   s    s   __(\w+)|\w+| +|.c         C   sd   t  i i |  ƒ } t  i i | ƒ d } | i d d ƒ } d „  } t i d | | ƒ } d | d S(   Ni    R   t   _c         S   s   t  t |  i d ƒ ƒ ƒ S(   Ni    (   t   hext   ordt   group(   t   m(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt
   munge_char   s    s   [^a-zA-Z0-9_]t   _m1_t   __(   t   ost   patht   basenamet   splitextt   replacet   ret   sub(   R"   t   rvR(   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   munge_filenamey   s    	c         C   s  t  i |  d d ƒ } | i ƒ  } | i ƒ  | i d d ƒ } | i d d ƒ } d t i j o2 t i d i d ƒ \ } } |  i | | ƒ }  n t |  ƒ } | d 7} g  } d	 } d
 } t	 | ƒ o | d
 d j o | d	 7} n xþ| t	 | ƒ j  oê| }	 d }
 d
 } xÑ| t	 | ƒ j  o½| | } | d j o t
 d |  | f ƒ ‚ n | d j o | d	 7} n | d j oJ | oB t i d |
 ƒ p | i |  |	 |
 f ƒ n | d	 7} d }
 Pn | d j o: | | d	 d j o% | d 7} | d	 7} |
 d 7}
 qn | d! j o | d	 7} n | d" j o | o | d	 8} n | d j o* x  | | d j o | d	 7} qZWqn | d# j oã | } |
 | 7}
 | d	 7} t } x¹ | t	 | ƒ j  o¥ | | } | d j o | d	 7} n | o! t } | d	 7} |
 | 7}
 q±n | | j o | d	 7} |
 | 7}
 Pn | d j o
 t } n |
 | 7}
 | d	 7} q±q±Wqn t i | | ƒ } | i d
 ƒ } | i d	 ƒ } | o d | j o | | } n |
 | 7}
 | i d
 ƒ } qWqè W|
 d j p" t |  |	 d d |
 d  t ƒ‚ n | S($   s±   
    This reads the specified filename, and divides it into logical
    line. The return value of this function is a list of (filename,
    line number, line text) triples.
    t   rs   utf-8s   
s   
s   t   RENPY_PATH_ELIDEt   :s   

i   i    u   ï»¿t    s   	sY   %s contains a tab character on line %d. Tab characters are not allowed in Ren'Py scripts.s   ^\s*$s   \i   s   \
t   (t   [t   {t   }t   ]t   )t   #R   t   'R   R*   sB   is not terminated with a newline. (Check strings and parenthesis.)R   R   (   R8   R9   R:   (   R;   R<   R=   (   R   R?   R   (   t   codecst   opent   readt   closeR/   R+   t   environR   R3   R   R
   R0   t   matcht   appendR   t   Truet   lllwordR&   t   endR    (   R   t   ft   datat   oldt   newt   prefixR2   R   R   t   start_numberR   t
   parendepthR   t   delimt   escapeR'   t   wordt   rest(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   list_logical_lines†   sœ    



"













"c            s/   d „  ‰  ‡ ‡ ‡  f d †  ‰ ˆ d d ƒ d S(   sE  
    This takes as input the list of logical line triples output from
    list_logical_lines, and breaks the lines into blocks. Each block
    is represented as a list of (filename, line number, line text,
    block) triples, where block is a block list (which may be empty if
    no block is associated with this line.)
    c         S   sV   d } d } x9 t  o1 |  | d j o | d 7} | d 7} q n Pq W| |  | f S(   Ni    R   i   (   RG   (   R   t   deptht   index(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   depth_split%  s    


c   
         sÞ   g  } d  } xÅ |  t ˆ ƒ j  o± ˆ |  \ } } } ˆ | ƒ \ } } | | j  o Pn | d  j o
 | } n | | j o t | | d ƒ ‚ n |  d 7}  ˆ  |  | d ƒ \ }	 }  | i | | | |	 f ƒ q W| |  f S(   Ns   indentation mismatch.i   (   R   R   R    RF   (
   R   t	   min_depthR2   RV   R   R   t   textt
   line_depthRT   t   block(   t   gll_coreR   RX   (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR]   :  s    

i    (    (   R   (    (   RX   R]   R   s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   group_logical_lines  s    
	t   Lexerc           B   sg  e  Z d  Z e d d d d d d d d d	 d
 d d d d d d d d d d d g ƒ Z e d „ Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d  „  Z e d! „ Z d" „  Z d# „  Z d$ „  Z d% „  Z d& „  Z d' „  Z d( „  Z d) „  Z d* „  Z d+ „  Z d, „  Z d- „  Z d. „  Z d/ „  Z d3 d0 „ Z! d1 „  Z" d2 „  Z# RS(4   s±   
    The lexer that is used to lex script files. This works on the idea
    that we want to lex each line in a block individually, and use
    sub-lexers to lex sub-blocks.
    t   ast   att   behindt   callt
   expressiont   hidet   ift   imaget   initt   jumpt   menut   onlayert   pythont   returnt   scenet   sett   showt   witht   whilet   zordert	   transformc         C   sp   | |  _  | |  _ t |  _ d |  _ d |  _ d |  _ d |  _ g  |  _ d |  _	 d |  _
 d |  _ d |  _ d  S(   NiÿÿÿÿR7   i    (   Rh   R\   R   t   eobR   R   RZ   R   t   subblockR   t   word_cache_post   word_cache_newpost
   word_cache(   R   R\   Rh   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR   }  s    											c         C   sw   |  i  d 7_  |  i  t |  i ƒ j o t |  _ d Sn |  i |  i  \ |  _ |  _ |  _ |  _ d |  _	 d |  _
 t S(   s'  
        Advances this lexer to the next line in the block. The lexer
        starts off before the first line, so advance must be called
        before any matching can be done. Returns True if we've
        successfully advanced to a line in the block, or False if we
        have advanced beyond all lines in the block. In general, once
        this method has returned False, the lexer is in an undefined
        state, and it doesn't make sense to call any method other than
        advance (which will always return False) on the lexer.
        i   Ni    iÿÿÿÿ(   R   R   R\   RG   Ru   R   R   RZ   Rv   R   Rw   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   advance‘  s    	(		c         C   s…   |  i  o d Sn |  i t |  i ƒ j o d Sn t i | t i ƒ i |  i |  i ƒ } | p d Sn | i	 ƒ  |  _ | i
 d ƒ S(   s  
        Tries to match the given regexp at the current location on the
        current line. If it succeds, it returns the matched text (if
        any), and updates the current position to be after the
        match. Otherwise, returns None and the position is unchanged.
        i    N(   Ru   R   R   R   RZ   R0   t   compilet   DOTALLRE   RI   R&   (   R   t   regexpR'   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   match_regexp©  s    
'c         C   s   |  i  d ƒ d S(   sQ   
        Advances the current position beyond any contiguous whitespace.
        u   (\s+|\\\n)+N(   R~   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   skip_whitespaceÀ  s    c         C   s   |  i  ƒ  |  i | ƒ S(   sÁ   
        Matches something at the current position, skipping past
        whitespace. Even if we can't match, the current position is
        still skipped past the leading whitespace.
        (   R   R~   (   R   R}   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyRE   É  s    
c         C   s1   |  i  } |  i ƒ  | j o | Sn | |  _  d S(   sÓ   
        Matches a keyword at the current position. A keyword is a word
        that is surrounded by things that aren't words, like
        whitespace. (This prevents a keyword from matching a prefix.)
        R7   (   R   RS   (   R   RS   t   oldpos(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   keywordÔ  s
    		c         C   s(   t  |  i |  i | |  i |  i ƒ ‚ d S(   sc   
        Convenience function for reporting a parse error at the current
        location.
        N(   R    R   R   RZ   R   (   R   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   errorã  s    c         C   s    |  i  ƒ  |  i t |  i ƒ j S(   s¤   
        Returns True if, after skipping whitespace, the current
        position is at the end of the end of the current line, or
        False otherwise.
        (   R   R   R   RZ   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   eolë  s    
c         C   s"   |  i  ƒ  p |  i d ƒ n d S(   sG   
        If we are not at the end of the line, raise an error.
        s   end of line expected.N(   Rƒ   R‚   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt
   expect_eolõ  s    c         C   s#   |  i  o |  i d | ƒ n d S(   sz   
        Called to indicate this statement does not expect a block.
        If a block is found, raises an error.
        sT   %s does not expect a block. Please check the indentation of the line after this one.N(   Rv   R‚   (   R   t   stmt(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   expect_noblocký  s    
c         C   s#   |  i  p |  i d | ƒ n d S(   sk   
        Called to indicate that the statement requires that a non-empty
        block is present.
        s   %s expects a non-empty block.N(   Rv   R‚   (   R   R…   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   expect_block  s    
c         C   s#   |  i  p | } t |  i d | ƒS(   sk   
        Returns a new lexer object, equiped to parse the block
        associated with this line.
        Rh   (   Rh   R_   Rv   (   R   Rh   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   subblock_lexer  s    c         C   s#  |  i  d ƒ } | d j o |  i  d ƒ } n | d j o |  i  d ƒ } n | d j o d Sn | d d j o t } | d } n t } | d d !} | p| t i d d	 | ƒ } | i d
 d ƒ } | i d d ƒ } | i d d ƒ } t i d d „  | ƒ } t i d d | ƒ } n | S(   s'  
        Lexes a string, and returns the string to the user, or none if
        no string could be found. This also takes care of expanding
        escapes and collapsing whitespace.

        Be a little careful, as this can return an empty string, which is
        different than None.
        s   r?"([^\\"]|\\.)*"s   r?'([^\\']|\\.)*'s   r?`([^\\`]|\\.)*`i    R4   i   iÿÿÿÿs   \s+R   s   \ns   
s   \{s   {{s   \%s   %%s   \\u([0-9a-fA-F]{1,4})c         S   s   t  t |  i d  ƒ d ƒ ƒ S(   i   i   (   t   unichrt   intR&   (   R'   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   <lambda>A  s    s   \\(.)s   \1N(   RE   R   RG   R   R0   R1   R/   (   R   t   st   raw(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   string  s*    
	c         C   s   |  i  d ƒ S(   sf   
        Tries to parse an integer. Returns a string containing the
        integer, or None.
        s   (\+|\-)?\d+(   RE   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   integerF  s    c         C   s   |  i  d ƒ S(   sk   
        Tries to parse a number (float). Returns a string containing the
        number, or None.
        s(   (\+|\-)?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?(   RE   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   floatN  s    c         C   s^   |  i  |  i j o |  i |  _  |  i Sn |  i  |  _ |  i d ƒ } | |  _ |  i  |  _ | S(   s?   
        Parses a name, which may be a keyword or not.
        u"   [a-zA-Z_Â -ï¿½][0-9a-zA-Z_Â -ï¿½]*(   R   Rw   Rx   Ry   RE   (   R   R2   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyRS   V  s    	c         C   s:   |  i  } |  i ƒ  } | |  i j o | |  _  d Sn | S(   sG   
        This tries to parse a name. Returns the name or None.
        N(   R   RS   t   keywordsR   (   R   R€   R2   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   nameg  s    		c         C   sU  |  i  ƒ  o t Sn |  i |  i } | d j ow |  i d 7_ |  i t |  i ƒ j o |  i d 8_ t Sn |  i |  i } | d j o |  i d 8_ t Sq¾ n | d j o t Sn | } x{ t os |  i d 7_ |  i  ƒ  o |  i d ƒ n |  i |  i } | | j o Pn | d j o |  i d 7_ qÇ qÇ W|  i d 7_ t S(	   sÞ   
        This tries to match a python string at the current
        location. If it matches, it returns True, and the current
        position is updated to the end of the string. Otherwise,
        returns False.
        t   ui   R   R?   s)   end of line reached while parsing string.s   \(   R   R?   (   R   R?   (   Rƒ   R   RZ   R   R   RG   R‚   (   R   R   RQ   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   python_stringu  s4    
c         C   si   |  i  ƒ  } | p d Sn xG |  i d ƒ o6 |  i  ƒ  } | p |  i d ƒ n | d | 7} q W| S(   sY  
        This tries to match a dotted name, which is one or more names,
        separated by dots. Returns the dotted name if it can, or None
        if it cannot.

        Once this sees the first name, it commits to parsing a
        dotted_name. It will report an error if it then sees a dot
        without a name behind it.        
        s   \.s   expecting name.t   .N(   R’   R   RE   R‚   (   R   R2   t   n(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   dotted_name§  s    c         C   sË   |  i  } xª |  i ƒ  pœ |  i |  i  } | | j o- t i i |  i | |  i  !|  i |  i ƒ Sn | d j p | d j o |  i ƒ  q n |  i	 ƒ  o q n |  i  d 7_  q W|  i
 d | ƒ d S(   s#  
        This matches python code up to, but not including, the non-whitespace
        delimiter characters. Returns a string containing the matched code,
        which may be empty if the first thing is the delimiter. Raises an
        error if EOL is reached before the delimiter.
        R   R?   i   s(   reached end of line when expecting '%s'.N(   R   Rƒ   RZ   t   renpyt   astt   PyExprR   R   R”   t   parenthesised_pythonR‚   (   R   RQ   t   startR   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   delimited_pythonÀ  s    	-
c         C   sO   |  i  d ƒ } | p |  i d ƒ n t i i | i ƒ  | i | i ƒ } | S(   sk   
        Returns a python expression, which is arbitrary python code
        extending to a colon.
        R6   s   expected python_expression(   R   R‚   R˜   R™   Rš   t   stripR   t
   linenumber(   R   t   peR2   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   python_expressionÜ  s
    $c         C   sÔ   |  i  |  i } | d j o3 |  i d 7_ |  i d ƒ |  i d 7_ t Sn | d j o3 |  i d 7_ |  i d ƒ |  i d 7_ t Sn | d j o3 |  i d 7_ |  i d ƒ |  i d 7_ t Sn t S(   sË   
        Tries to match a parenthesised python expression. If it can,
        returns true and updates the current position to be after the
        closing parenthesis. Returns False otherewise.
        R8   i   R=   R9   R<   R:   R;   (   RZ   R   R   RG   R   (   R   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR›   ë  s"    c         C   sú   |  i  ƒ  |  i ƒ  o d Sn |  i } |  i ƒ  o2 |  i ƒ  o$ |  i ƒ  o |  i ƒ  o d Sn x~ |  i ƒ  pp |  i  ƒ  |  i ƒ  o Pn |  i d ƒ o+ |  i ƒ  } | p |  i	 d ƒ qk qk n |  i ƒ  o qk n Pqk W|  i
 | |  i !S(   so   
        Tries to parse a simple_expression. Returns the text if it can, or
        None if it cannot.
        s   \.s   expecting name after dot.N(   R   Rƒ   R   R   R”   R’   R   R›   RE   R‚   RZ   (   R   Rœ   R–   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   simple_expression
  s,    
	
c         C   s"   |  i  |  i |  i |  i |  i f S(   s   
        Returns an opaque representation of the lexer state. This can be
        passed to revert to back the lexer up.
        (   R   R   RZ   Rv   R   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt
   checkpoint5  s    c         C   s1   | \ |  _  |  _ |  _ |  _ |  _ d |  _ d S(   s   
        Reverts the lexer to the given state. State must have been returned
        by a previous checkpoint operation on this lexer.
        iÿÿÿÿN(   R   R   RZ   Rv   R   Rw   (   R   t   state(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   revert=  s    $c         C   s   |  i  |  i f S(   s–   
        Returns a (filename, line number) tuple representing the current
        physical location of the start of the current logical line.
        (   R   R   (   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   get_locationF  s    c         C   sr   t  | t ƒ o  | p | } |  i | ƒ } n | p
 | i i } | ƒ  } | d j o |  i d | ƒ n | S(   sþ   
        Tries to parse thing, and reports an error if it cannot be done.

        If thing is a string, tries to parse it using
        self.match(thing). Otherwise, thing must be a method on this lexer
        object, which is called directly.
        s   expected '%s' not found.N(   R   t   strRE   t   im_funct	   func_nameR   R‚   (   R   t   thingR’   R2   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   requireN  s    		c         C   s0   |  i  ƒ  |  i } t |  i ƒ |  _ |  i | S(   s    
        Skips whitespace, then returns the rest of the current
        line, and advances the current position to the end of
        the current line.
        (   R   R   R   RZ   (   R   R   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyRT   c  s    
	c            sM   g  ‰ t  ƒ  ‰ |  i ˆ _ ‡ ‡ ‡  f d †  ‰  ˆ  |  i d ƒ d i ˆ ƒ S(   s¾   
        Returns the subblock of this code, and subblocks of that
        subblock, as indented python code. This tries to insert
        whitespace to ensure line numbers match up.
        c            s±   xª |  D]¢ \ } } } } ˆ i  | j o n x5 ˆ i  | j  o$ ˆ  i | d ƒ ˆ i  d 7_  q0 W| | d } ˆ  i | ƒ ˆ i  | i d ƒ 7_  ˆ | | d ƒ q Wd  S(   Ns   
i   s       (   R   RF   t   count(   R\   t   indentR"   t   lnRZ   Rv   t   linetext(   R2   t   ot   process(    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR±   |  s     R7   (   R   R   R   Rv   t   join(   R   (    (   R±   R2   R°   s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   python_blockp  s    	N($   R   R   R   Ro   R‘   R   R   Rz   R~   R   RE   R   R‚   Rƒ   R„   R†   R‡   Rˆ   RŽ   R   R   RS   R’   R”   R—   R   R¡   R›   R¢   R£   R¥   R¦   R   R«   RT   R³   (    (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyR_   [  sh   								
				

	,					2					+					c         C   sY   |  i  |  i ƒ g } x7 t o/ |  i ƒ  } | p Pn | i | i ƒ  ƒ q Wt | ƒ S(   so   
    This parses an image name, and returns it as a tuple. It requires
    that the image name be present.
    (   R«   R’   RG   R¢   RF   Rž   t   tuple(   R   R2   R–   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   parse_image_name‘  s    
c         C   sb   |  i  |  i ƒ g } xF t o> |  i d ƒ p Pn |  i ƒ  } | p Pn | i | ƒ q W| S(   s¡   
    This parses a comma-separated list of simple_expressions, and
    returns a list of strings. It requires at least one
    simple_expression be present.
    t   ,(   R«   R¢   RG   RE   RF   (   R   R2   t   e(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   parse_simple_expression_list¢  s    
c   	      C   s+  d } d } g  } d } g  } |  i d ƒ p |  i d ƒ o% |  i |  i ƒ } | i ƒ  f } n t |  ƒ } d } xƒt o{|  i d ƒ o1 | o |  i d ƒ qx |  i |  i ƒ } qx n |  i d ƒ o+ | o |  i d ƒ qx t	 |  ƒ } qx n |  i d ƒ o1 | o |  i d ƒ qx |  i |  i ƒ } qx n |  i d	 ƒ o7 | d j	 o |  i d
 ƒ qx |  i |  i ƒ } qx n |  i d ƒ ob | o |  i d ƒ n x@ t o8 |  i |  i ƒ } | i
 | ƒ |  i d ƒ p Pq®q®Wqx n Pqx W| d j o
 d } n | | | | | | | f S(   s*   
    This parses an image specifier. 
    Rd   Rg   Rk   s(   multiple onlayer clauses are prohibited.Ra   s#   multiple at clauses are prohibited.R`   s#   multiple as clauses are prohibited.Rs   s'   multiple zorder clauses are prohibited.Rb   s'   multiple behind clauses are prohibited.R¶   t   masterN(   R   R   R«   R¢   Rž   Rµ   RG   R‚   R’   R¸   RF   RE   (	   R   t   tagt   layert   at_listRs   Rb   Rd   t
   image_namet   bhtag(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   parse_image_specifier¸  sX     



c         C   s^   |  i  ƒ  } |  i d ƒ p | Sn |  i |  i ƒ } t i | d | ƒ | t i | | ƒ g S(   sà   
    Tries to parse the with clause associated with this statement. If
    one exists, then the node is wrapped in a list with the
    appropriate pair of With nodes. Otherwise, just returns the
    statement by itself.
    Rq   R   (   R¦   R   R«   R¢   R™   t   With(   R   t   nodet   loct   expr(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt
   parse_with  s    c         C   s5  |  i  ƒ  } t } t } t } d  } d  } d  } d  }	 g  }
 | i ƒ  x{| i pp| i d ƒ o: | i | i ƒ } | i ƒ  | i	 d ƒ | i ƒ  qI n | i d ƒ o: | i | i ƒ } | i ƒ  | i	 d ƒ | i ƒ  qI n | i
 ƒ  } | i ƒ  } | i ƒ  } | d  j	 ow | d  j	 oj | i ƒ  | i	 d ƒ | o | i d ƒ n | o | i d ƒ n t } | } | }	 | i ƒ  qI n | i | ƒ | i ƒ  } | d  j o | i d ƒ n | i ƒ  od | i	 d	 ƒ | o | o | i d
 ƒ n | o
 t } n |
 i | d d  f ƒ | i ƒ  qI n t } d } | i d ƒ o | i | i ƒ } n | i d ƒ | i ƒ  | i d ƒ t | i  ƒ  ƒ } |
 i | | | f ƒ | i ƒ  qI W| p |  i d ƒ n g  } | o) | i t i | | |	 d  d t ƒƒ n | i t i | |
 | | ƒ ƒ | S(   NRq   s   with clauseRo   s   set menuitems   say menuitems:   Say menuitems and captions may not exist in the same menu.s)   Only one say menuitem may exist per menu.s   expected menuitems   caption menuitems:   Captions and say menuitems may not exist in the same menu.RG   Rf   R6   s   choice menuitems"   Menu does not contain any choices.t   interact(   Rˆ   R   R   Rz   Ru   R   R«   R¢   R„   R†   R£   RŽ   R‚   RG   R¥   Rƒ   RF   R¡   R‡   t   parse_blockR™   t   Sayt   Menu(   t   stmtlRÂ   R   t
   has_choicet   has_sayt   has_captiont   with_Ro   t   say_whot   say_whatt   itemsR¤   t   whot   whatt   labelt	   conditionR\   R2   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt
   parse_menu  sˆ    









)c   	      C   s$  g  } g  } d  } d  } t } t ƒ  } |  i d ƒ p d  Sn xÉt oÁ|  i d ƒ o Pn |  i d ƒ oc | d  j	 o |  i d ƒ n |  i |  i ƒ } | | j o |  i d | ƒ n | i | ƒ n|  i d ƒ on | p |  i d ƒ n t } |  i ƒ  } | d  j	 o3 | | j o |  i d | ƒ n | i | ƒ qän– |  i |  i ƒ } | | j o |  i d | ƒ n | i | ƒ |  i d ƒ o |  i	 d	 ƒ } n d  } | i
 | | f ƒ | o | i
 | ƒ n |  i d ƒ o Pn |  i d
 ƒ qB Wt i i | | | | ƒ S(   Ns   \(s   \)s   \*\*s&   a label may have only one ** parameters   parameter %s appears twice.s   \*s%   a label may have only one * parametert   =s   ),R¶   (   R   RG   Ro   RE   R‚   R«   R’   t   addR   R   RF   R˜   R™   t   ParameterInfo(	   R   t
   parameterst
   positionalt   extrapost   extrakwt   add_positionalt   namesR’   t   default(    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   parse_parameters  sR    	
c         C   sj  g  } d
 } d
 } |  i d ƒ p d
 Sn x't o|  i d ƒ o Pn |  i d ƒ o1 | d
 j	 o |  i d ƒ n |  i d ƒ } n¤ |  i d ƒ o1 | d
 j	 o |  i d ƒ n |  i d ƒ } nc |  i ƒ  } |  i ƒ  } | o |  i d ƒ p |  i | ƒ d
 } n | i | |  i d ƒ f ƒ |  i d ƒ o Pn |  i	 d	 ƒ q- Wt
 i i | | | ƒ S(   s7   
    Parse a list of arguments, if one is present.
    s   \(s   \)s   \*\*s$   a call may have only one ** arguments   ),s   \*s#   a call may have only one * argumentRÖ   R¶   N(   R   RE   RG   R‚   R   R£   R’   R¥   RF   R«   R˜   R™   t   ArgumentInfo(   R   t	   argumentsRÜ   RÛ   R¤   R’   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   parse_arguments×  s4    

c         C   sº  |  i  ƒ  } |  i d ƒ ocg  } |  i |  i ƒ } |  i d ƒ |  i ƒ  |  i d ƒ t |  i ƒ  ƒ } | i | | f ƒ |  i	 ƒ  xz |  i d ƒ oi |  i |  i ƒ } |  i d ƒ |  i ƒ  |  i d ƒ t |  i ƒ  ƒ } | i | | f ƒ |  i	 ƒ  qŠ W|  i d ƒ oW |  i d ƒ |  i ƒ  |  i d ƒ t |  i ƒ  ƒ } | i d | f ƒ |  i	 ƒ  n t
 i | | ƒ Sn |  i d ƒ o |  i d	 ƒ n |  i d ƒ o |  i d
 ƒ n |  i d ƒ oi |  i |  i ƒ } |  i d ƒ |  i ƒ  |  i d ƒ t |  i ƒ  ƒ } |  i	 ƒ  t
 i | | | ƒ Sn |  i d ƒ o2 |  i d ƒ |  i ƒ  |  i	 ƒ  t
 i | ƒ Sn |  i d ƒ oŽ |  i d ƒ |  i ƒ  } |  i d ƒ |  i ƒ  t |  | ƒ } |  i	 ƒ  g  } | o# | i t
 i | | g  d6 ƒ ƒ n | i | ƒ | Sn |  i d ƒ oR |  i d ƒ |  i ƒ  } | p
 d6 } n |  i ƒ  |  i	 ƒ  t
 i | | ƒ Sn |  i d ƒ o| |  i d ƒ |  i d ƒ o t }	 |  i |  i ƒ }
 n t }	 |  i |  i ƒ }
 |  i ƒ  |  i	 ƒ  t
 i | |
 |	 ƒ Sn |  i d ƒ oü |  i d ƒ |  i d ƒ o t }	 |  i |  i ƒ }
 n t }	 |  i |  i ƒ }
 |  i d ƒ t |  ƒ } t
 i | |
 |	 | ƒ g } |  i d ƒ o5 |  i |  i ƒ } | i t
 i | | g  d6 ƒ ƒ n | i t
 i | ƒ ƒ |  i ƒ  |  i	 ƒ  | Sn |  i d ƒ oæ |  i d ƒ o |  i |  i ƒ } n d } |  i ƒ  o! |  i	 ƒ  t
 i | d6 | ƒ Sn t |  ƒ } t
 i | | | d ƒ } t  |  | ƒ } |  i! d ƒ o t" i# i$ |  i ƒ  ƒ | _# n |  i d ƒ |  i ƒ  |  i	 ƒ  | Sn |  i d ƒ o… t |  ƒ } t
 i% | | ƒ } t  |  | ƒ } |  i! d ƒ o t" i# i$ |  i ƒ  ƒ | _# n |  i d ƒ |  i ƒ  |  i	 ƒ  | Sn |  i d  ƒ oP t |  ƒ } t  |  t
 i& | | ƒ ƒ } |  i ƒ  |  i d! ƒ |  i	 ƒ  | Sn |  i d" ƒ oG |  i |  i ƒ } |  i ƒ  |  i d# ƒ |  i	 ƒ  t
 i' | | ƒ Sn |  i d$ ƒ oÄ t( |  ƒ } |  i! d ƒ o, |  i ƒ  d6 } t" i# i$ |  i ƒ  ƒ } n- |  i d% ƒ |  i ƒ  } d6 } |  i d& ƒ t
 i) | | | | ƒ } |  i* p t
 i+ | | g d' ƒ } n |  i	 ƒ  | Sn |  i d( ƒ o® |  i, ƒ  } | o t- | ƒ } n d) } |  i |  i ƒ } |  i d% ƒ |  i ƒ  } |  i d* ƒ t
 i. | | | ƒ } |  i* p t
 i+ | | g | ƒ } n |  i	 ƒ  | Sn |  i d+ ƒ oò |  i, ƒ  } | o t- | ƒ } n d) } |  i |  i ƒ } t/ |  ƒ } | o% | i0 p
 | i1 o |  i d, ƒ n |  i d ƒ |  i ƒ  t" i# i$ |  i ƒ  ƒ } t
 i2 | | | | ƒ } |  i* p t
 i+ | | g | ƒ } n |  i	 ƒ  | Sn |  i! d- ƒ o7 |  i ƒ  } |  i d. ƒ |  i	 ƒ  t
 i3 | | ƒ Sn |  i d/ ƒ o¥ t } t } |  i d0 ƒ o
 t } n |  i d  ƒ o
 t } n |  i d ƒ |  i d1 ƒ |  i4 ƒ  } |  i	 ƒ  | o t
 i5 | | | ƒ Sqæ
t
 i3 | | | ƒ Sn |  i d2 ƒ ok |  i |  i ƒ } t/ |  ƒ } |  i d ƒ |  i ƒ  t |  i ƒ  ƒ } |  i	 ƒ  t
 i | | | | ƒ Sn |  i d3 ƒ oÿ |  i, ƒ  } | o t- | ƒ } n d) } |  i d/ ƒ ol t } |  i d  ƒ o
 t } n |  i d ƒ |  i d1 ƒ |  i4 ƒ  } |  i	 ƒ  t
 i3 | | | ƒ g } nD |  i d ƒ |  i ƒ  |  i d4 ƒ t |  i t ƒ ƒ } |  i	 ƒ  t
 i+ | | | ƒ Sn |  i6 ƒ  } |  i7 ƒ  } | f t" i8 i9 j of |  i: } |  i | d5 ƒ |  i	 ƒ  t" i; i< |  i ƒ z t
 i= | | ƒ } Wd6 t" i; i> ƒ  X| Sn |  i? | ƒ d: t" i8 i9 j ob |  i: } |  i d7 ƒ |  i	 ƒ  t" i; i< |  i ƒ z t
 i= | | ƒ } Wd6 t" i; i> ƒ  X| Sn |  i@ ƒ  } |  i d" ƒ o |  i |  i ƒ } n d6 } | d6 j	 o> |  i ƒ  o1 |  i d8 ƒ |  i	 ƒ  t
 iA | d6 | | ƒ Sn |  i? | ƒ |  i ƒ  } |  i@ ƒ  } |  i d" ƒ o |  i |  i ƒ } n d6 } | oH | d6 j	 o; |  i ƒ  |  i d8 ƒ |  i	 ƒ  t
 iA | | | | ƒ Sn |  i d9 ƒ d6 S(;   sR  
    This parses a Ren'Py statement. l is expected to be a Ren'Py lexer
    that has been advanced to a logical line. This function will
    advance l beyond the last logical line making up the current
    statement, and will return an AST object representing this
    statement, or a list of AST objects representing this statement.
    Rf   R6   s   if statementt   elifs   elif clauset   elses   else clauseRG   s4   elif clause must be associated with an if statement.s4   else clause must be associated with an if statement.Rr   s   while statementt   passs   pass statementRj   s   menu statementRm   s   return statementRi   s   jump statementRd   Rc   s   call statmentt   fromRn   Rk   R¹   i   s   scene statementRp   s   show statementRe   s   hide statementRq   s   with statementRg   RÖ   s   image statementiÞ  t   definei    s   define statementRt   sA   transform statement does not take a variable number of parameterss   \$s   one-line python statementRl   t   earlys   python blockRÓ   Rh   s   init statements
    statementNs   default statements   say statements   expected statement.(    (B   R¦   R   R«   R¡   R„   R‡   RÆ   Rˆ   RF   Rz   R™   t   IfR‚   t   WhileR†   t   PassR’   RÕ   t   LabelR   t   extendRT   t   ReturnRG   R¢   R   t   JumpRã   t   CallRƒ   t   SceneR¿   RÄ   RE   R˜   t   atlt	   parse_atlt   Showt   HideRÀ   Rµ   t   ImageRh   t   InitR   RŠ   t   DefineRà   RÜ   RÛ   t	   Transformt   PythonR³   t   EarlyPythonR£   RS   t
   statementst   registryRZ   t   exportst   push_error_handlert   UserStatementt   pop_error_handlerR¥   RŽ   RÇ   (   R   RÂ   t   entriesRÔ   R\   RÓ   Rj   R2   RT   Rd   t   targetRâ   R’   R»   t   imspecR…   RÃ   Ró   t   priorityRÙ   t   python_codeRe   Ré   t   pR¤   RS   RZ   RÒ   RÍ   RÑ   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   parse_statement  s   










#




#




























	
	



c         C   s–   |  i  ƒ  g  } x |  i pt y> t |  ƒ } t | t ƒ o | i | ƒ n | i | ƒ Wq t j
 o# } t i | i	 ƒ |  i  ƒ  q Xq W| S(   s¤   
    This parses a block of Ren'Py statements. It returns a list of the
    statements contained within the block. l is a new Lexer object, for
    this block.
    (
   Rz   Ru   R	  R   t   listRî   RF   R    t   parse_errorsR	   (   R   R2   R…   R·   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyRÆ   ×  s    
c         C   s‡   d |  d t  i _ y t |  ƒ } t | ƒ } Wn) t j
 o } t i | i ƒ d Sn Xt
 | ƒ } t | ƒ } t o d Sn | S(   sÃ   
    Parses a Ren'Py script contained within the file with the given
    filename. Returns a list of AST objects representing the
    statements that were found at the top level of the file.
    s   While parsing R•   N(   R˜   t   gamet   exception_infoRU   R^   R    R  RF   R	   R   R_   RÆ   (   R"   R   t   nestedR·   R   R2   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   parseð  s    	c       
   C   s  t  p t Sn d }  t |  d ƒ } t i i |  ƒ } | i t i ƒ | d IJ| d IJ| Jx? t  D]7 } y | i	 d ƒ } Wn n XH| J| GH| | IJqe W| J| d It
 i IJ| i ƒ  y> t
 i i o  t
 i i | g d d d ƒn t i |  ƒ Wn n Xt S(	   Ns
   errors.txtt   wsF   I'm sorry, but errors were detected in your script. Please correct thes#   errors listed below, and try again.s   utf-8s   Ren'Py Version:i   t	   transient(   R  R   t   fileR+   R,   t   realpatht   writeR@   t   BOM_UTF8t   encodeR˜   t   versionRC   t   configt   editorRÿ   t   launch_editort	   startfileRG   (   t   erfileRJ   t   opat_errR   (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pyt   report_parse_errors	  s:    

 
 (   R@   R0   R+   t   os.pathR˜   t	   renpy.astR™   R  R
   R    t   objectR   R   R{   t   SRH   R3   RU   R^   R_   Rµ   R¸   R¿   RÄ   RÕ   Rà   Rã   R	  RÆ   R  R  (    (    (    s4   D:\Version 1-0-7\Games\Katawa Shoujo\renpy\parser.pys   <module>   s8   2			•	@ÿ ÿ 8			M		s	J	4	ÿ Í		