
^Yc           @   s  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d Z d Z	 e
 Z d Z d Z d Z d Z e Z d Z d Z e j d d k  r e Z n e Z e j Z d	 e f d
     YZ d e f d     YZ d e f d     YZ d   Z d   Z  e! a" e! a# e! a$ d Z% d   Z& d   Z' d   Z( d   Z) d f  d     YZ* d f  d     YZ+ d f  d     YZ, e  j- d  Z. d e f d     YZ/ d e f d      YZ0 d! e f d"     YZ1 d#   Z2 d$ e f d%     YZ3 d& e f d'     YZ4 d( e f d)     YZ5 d* e f d+     YZ6 d,   Z7 d-   Z8 d. e f d/     YZ9 d0 e6 f d1     YZ: d2   Z; d3   Z< d4 e f d5     YZ= d e e! e e! e
 e e
 e e! e! e! e! d6  Z> d S(7   iNs   3.10s
   parser.outt   parsetabt   LALRi   i(   i    t	   PlyLoggerc           B   s8   e  Z d    Z d   Z e Z d   Z d   Z e Z RS(   c         C   s   | |  _  d  S(   N(   t   f(   t   selfR   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __init__n   s    c         O   s   |  j  j | | d  d  S(   Ns   
(   R   t   write(   R   t   msgt   argst   kwargs(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   debugq   s    c         O   s    |  j  j d | | d  d  S(   Ns	   WARNING: s   
(   R   R   (   R   R   R   R	   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   warningv   s    c         O   s    |  j  j d | | d  d  S(   Ns   ERROR: s   
(   R   R   (   R   R   R   R	   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   errory   s    (   t   __name__t
   __module__R   R
   t   infoR   R   t   critical(    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR   m   s   				t
   NullLoggerc           B   s   e  Z d    Z d   Z RS(   c         C   s   |  S(   N(    (   R   t   name(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __getattribute__   s    c         O   s   |  S(   N(    (   R   R   R	   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __call__   s    (   R   R   R   R   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR      s   	t	   YaccErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR      s   c         C   sp   t  |   } d | k r' t  |  } n  t |  t k rJ | t  d } n  d t |   j t |   | f } | S(   Ns   
s    ...s   <%s @ 0x%x> (%s)(   t   reprt   lent   resultlimitt   typeR   t   id(   t   rt   repr_strt   result(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   format_result   s    "c         C   s^   t  |   } d | k r' t  |  } n  t |  d k  r= | Sd t |   j t |   f Sd  S(   Ns   
i   s   <%s @ 0x%x>(   R   R   R   R   R   (   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   format_stack_entry   s    s  PLY: Don't use global functions errok(), token(), and restart() in p_error().
Instead, invoke the methods on the associated parser instance:

    def p_error(p):
        ...
        # Use parser.errok(), parser.token(), parser.restart()
        ...

    parser = yacc.yacc()
c           C   s   t  j t  t   S(   N(   t   warningst   warnt   _warnmsgt   _errok(    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   errok   s    c           C   s   t  j t  t   S(   N(   R    R!   R"   t   _restart(    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   restart   s    c           C   s   t  j t  t   S(   N(   R    R!   R"   t   _token(    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   token   s    c         C   sL   | j  a | j a | j a |  |  } y b b b Wn t k
 rG n X| S(   N(   R$   R#   R(   R'   R&   R%   t	   NameError(   t	   errorfuncR(   t   parserR   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   call_errorfunc   s    			t
   YaccSymbolc           B   s   e  Z d    Z d   Z RS(   c         C   s   |  j  S(   N(   R   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __str__   s    c         C   s
   t  |   S(   N(   t   str(   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __repr__   s    (   R   R   R.   R0   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR-      s   	t   YaccProductionc           B   sn   e  Z d d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z RS(   c         C   s(   | |  _  | |  _ d  |  _ d  |  _ d  S(   N(   t   slicet   stackt   Nonet   lexerR+   (   R   t   sR3   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR      s    			c         C   s\   t  | t  r0 g  |  j | D] } | j ^ q S| d k rJ |  j | j S|  j | j Sd  S(   Ni    (   t
   isinstanceR2   t   valueR3   (   R   t   nR6   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __getitem__   s
    !c         C   s   | |  j  | _ d  S(   N(   R2   R8   (   R   R9   t   v(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __setitem__   s    c         C   s$   g  |  j  | | !D] } | j ^ q S(   N(   R2   R8   (   R   t   it   jR6   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __getslice__   s    c         C   s   t  |  j  S(   N(   R   R2   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __len__   s    c         C   s   t  |  j | d d  S(   Nt   linenoi    (   t   getattrR2   (   R   R9   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRA     s    c         C   s   | |  j  | _ d  S(   N(   R2   RA   (   R   R9   RA   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt
   set_lineno  s    c         C   s<   t  |  j | d d  } t  |  j | d |  } | | f S(   NRA   i    t	   endlineno(   RB   R2   (   R   R9   t	   startlinet   endline(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   linespan  s    c         C   s   t  |  j | d d  S(   Nt   lexposi    (   RB   R2   (   R   R9   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRH     s    c         C   s<   t  |  j | d d  } t  |  j | d |  } | | f S(   NRH   i    t	   endlexpos(   RB   R2   (   R   R9   t   startpost   endpos(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   lexspan  s    c         C   s
   t   d  S(   N(   t   SyntaxError(   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s    N(   R   R   R4   R   R:   R<   R?   R@   RA   RC   RG   RH   RL   R   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR1      s   									t   LRParserc           B   s   e  Z d    Z d   Z d   Z d   Z d   Z e e e e e d  Z	 e e e e e d  Z
 e e e e e d  Z e e e e e d  Z RS(	   c         C   sD   | j  |  _ | j |  _ | j |  _ | |  _ |  j   t |  _	 d  S(   N(
   t   lr_productionst   productionst	   lr_actiont   actiont   lr_gotot   gotoR*   t   set_defaulted_statest   Truet   errorok(   R   t   lrtabt   errorf(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s    	
c         C   s   t  |  _ d  S(   N(   RV   RW   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR$   &  s    c         C   sD   |  j  2|  j 2t   } d | _ |  j j |  |  j  j d  d  S(   Ns   $endi    (   t
   statestackt   symstackR-   R   t   append(   R   t   sym(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR&   )  s    		c         C   su   i  |  _  xe |  j j   D]T \ } } t | j    } t |  d k r | d d k  r | d |  j  | <q q Wd  S(   Ni   i    (   t   defaulted_statesRR   t   itemst   listt   valuesR   (   R   t   statet   actionst   rules(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRU   9  s
    	"c         C   s   i  |  _  d  S(   N(   R^   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   disable_defaulted_states@  s    c         C   s   | s t  rF t | t  r- t t j  } n  |  j | | | | |  S| re |  j | | | | |  S|  j | | | | |  Sd  S(   N(	   t	   yaccdevelR7   t   intR   t   syst   stderrt
   parsedebugt   parseoptt   parseopt_notrack(   R   t   inputR5   R
   t   trackingt	   tokenfunc(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   parseC  s    c   "   	   C   s"	  d  } g  } |  j } |  j }	 |  j }
 |  j } t d   } d } | j d  | sq d d l m } | j	 } n  | | _	 |  | _
 | d  k	 r | j |  n  | d  k r | j } n | } | |  _ g  } | |  _ g  } | |  _ | | _ d  } | j d  t   } d | _ | j |  d } xt r	| j d  | j d |  | | k r| s| so|   } n | j   } | st   } d | _ qn  | j } | | j |  } n | | } | j d | |  | j d	 d
 d j g  | D] } | j ^ qd  t |  f j    | d  k	 r| d k r| j |  | } | j d |  | j |  d  } | r(| d 8} q(q(n  | d k  r|
 | } | j } | j } t   } | | _ d  | _ | r.| j d | j d d j g  | | D] } t | j  ^ q d |	 | d | |  n% | j d | j g  |	 | d |  | r| | d } | | d <| r| d } | j | _ | j | _ | d } t  | d | j  | _! t  | d | j  | _" n  | | _# yp | | 3| |  _$ | j% |  | | 3| j d t& | d   | j |  |	 | d | } | j |  Wq(t' k
 r| j |  | j( | d d ! | j   | d } d | _ d | _ | } t) } t* |  _+ q(Xq(q| r| j | _ | j | _ n  | g } | | _# y` | |  _$ | j% |  | j d t& | d   | j |  |	 | d | } | j |  Wq(t' k
 r| j |  | j   | d } d | _ d | _ | } t) } t* |  _+ q(Xq(n  | d k r| d } t  | d d   } | j d t& |   | j d  | Sn  | d  k r	| j, d d
 d j g  | D] } | j ^ q2d  t |  f j    | d k sw|  j+ rt) } t* |  _+ | } | j d k rd  } n  |  j- r| rt. | d  r| | _	 n  | |  _$ t/ |  j- | |   }  |  j+ r|  } d  } q(qq| rrt. | d  r,| j }! n d }! |! rXt0 j1 j2 d |! | j f  qt0 j1 j2 d | j  qt0 j1 j2 d  d  Sn t) } t |  d k r| j d k rd  } d  } d } | 2q(n  | j d k rd  S| j d k r| d } | j d k rL| r@t  | d | j  | _! t  | d | j  | _" n  d  } q(n  t   } d | _ t. | d  r| j | _ | _! n  t. | d  r| j | _ | _" n  | | _ | j |  | } q(| j   } | r| j | _ | j | _ n  | j   | d } q(n  t3 d    q(Wd  S(!   Ni    s   PLY: PARSE DEBUG STARTi   (   t   lexs   $endt    s   State  : %ss#   Defaulted state %s: Reduce using %ds   Stack  : %ss   %s . %st    s    Action : Shift and goto state %ss3   Action : Reduce rule [%s] with %s and goto state %dt   [t   ,t   ]iRD   RI   s   Result : %sR   R8   s   Done   : Returning %ss   PLY: PARSE DEBUG ENDs   Error  : %sR5   RA   s(   yacc: Syntax error at line %d, token=%s
s   yacc: Syntax error, token=%ss    yacc: Parse error in input. EOF
RH   s   yacc: internal parser error!!!
(4   R4   RR   RT   RP   R^   R1   R   Rr   Rq   R5   R+   Rm   R(   RZ   R[   R3   R\   R-   R   RV   R
   t   popt   gett   joinR/   t   lstripR   R   R8   R   RA   RH   RB   RD   RI   R2   Rb   t   callableR   RM   t   extendt   error_countt   FalseRW   R   R*   t   hasattrR,   Rh   Ri   R   t   RuntimeError("   R   Rm   R5   R
   Rn   Ro   t	   lookaheadt   lookaheadstackRc   RT   t   prodR^   t   pslicet
   errorcountRq   t	   get_tokenRZ   R[   t   errtokenR]   Rb   t   ltypet   tt   xxt   pt   pnamet   plent   _vt   targt   t1R9   R   t   tokRA   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRj   \  s~   															
	@					5


		

					

		
	@						 !
				

c          C   sb  d  } g  } |  j } |  j }	 |  j }
 |  j } t d   } d } | sd d d l m } | j } n  | | _ |  | _	 | d  k	 r | j
 |  n  | d  k r | j } n | } | |  _ g  } | |  _ g  } | |  _ | | _ d  } | j d  t   } d | _ | j |  d } xCt r]| | k r| so| sE|   } n | j   } | sot   } d | _ qon  | j } | | j |  } n
 | | } | d  k	 r| d k r| j |  | } | j |  d  } | r| d 8} qqn  | d k  rg|
 | } | j } | j } t   } | | _ d  | _ | r| | d } | | d <| r| d } | j | _ | j | _ | d } t | d | j  | _ t | d | j  | _ n  | | _ yV | | 3| |  _ | j |  | | 3| j |  |	 | d | } | j |  Wqt  k
 r| j |  | j! | d d ! | j   | d } d | _ d | _ | } t" } t# |  _$ qXqqg| r| j | _ | j | _ n  | g } | | _ yF | |  _ | j |  | j |  |	 | d | } | j |  Wqt  k
 r`| j |  | j   | d } d | _ d | _ | } t" } t# |  _$ qXqn  | d k r| d } t | d	 d   } | Sn  | d  k rN| d k s|  j$ rt" } t# |  _$ | } | j d k rd  } n  |  j% rK| rt& | d
  r| | _ n  | |  _ t' |  j% | |   } |  j$ r| } d  } qqq| rt& | d  rl| j } n d } | rt( j) j* d | | j f  qt( j) j* d | j  qt( j) j* d  d  Sn t" } t |  d k r| j d k rd  } d  } d } | 2qn  | j d k rd  S| j d k r| d } | j d k r| rt | d | j  | _ t | d | j  | _ n  d  } qn  t   } d | _ t& | d  r| j | _ | _ n  t& | d  r| j | _ | _ n  | | _ | j |  | } q| j   } | r4| j | _ | j | _ n  | j   | d } qn  t+ d   qWd  S(   Ni    i   (   Rq   s   $endiRD   RI   R   R8   R5   RA   s(   yacc: Syntax error at line %d, token=%s
s   yacc: Syntax error, token=%ss    yacc: Parse error in input. EOF
RH   s   yacc: internal parser error!!!
(,   R4   RR   RT   RP   R^   R1   Rr   Rq   R5   R+   Rm   R(   RZ   R[   R3   R\   R-   R   RV   Rw   Rx   R   R   R8   RA   RH   RB   RD   RI   R2   Rb   R{   RM   R|   R}   R~   RW   R*   R   R,   Rh   Ri   R   R   (    R   Rm   R5   R
   Rn   Ro   R   R   Rc   RT   R   R^   R   R   Rq   R   RZ   R[   R   R]   Rb   R   R   R   R   R   R   R   R9   R   R   RA   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRk     sX   															
					


		

					

		
						 !
				

c         C   s  d  } g  } |  j } |  j }	 |  j }
 |  j } t d   } d } | sd d d l m } | j } n  | | _ |  | _	 | d  k	 r | j
 |  n  | d  k r | j } n | } | |  _ g  } | |  _ g  } | |  _ | | _ d  } | j d  t   } d | _ | j |  d } xct r}| | k r| so| sE|   } n | j   } | sot   } d | _ qon  | j } | | j |  } n
 | | } | d  k	 r| d k r| j |  | } | j |  d  } | r| d 8} qqn  | d k  r|
 | } | j } | j } t   } | | _ d  | _ | r'| | d } | | d <| | _ yV | | 3| |  _ | j |  | | 3| j |  |	 | d | } | j |  Wqt k
 r | j |  | j | d d ! | j   | d } d | _ d | _ | } t } t |  _ qXqq| g } | | _ yF | |  _ | j |  | j |  |	 | d | } | j |  Wqt k
 r| j |  | j   | d } d | _ d | _ | } t } t |  _ qXqn  | d k r| d } t  | d d   } | Sn  | d  k rn| d k s1|  j rCt } t |  _ | } | j d k r^d  } n  |  j! r| rt" | d  r| | _ n  | |  _ t# |  j! | |   } |  j r@| } d  } qq@qI| r,t" | d	  r| j$ } n d } | rt% j& j' d
 | | j f  q@t% j& j' d | j  qIt% j& j' d  d  Sn t } t |  d k r| j d k rd  } d  } d } | 2qn  | j d k rd  S| j d k rH| d } | j d k rd  } qn  t   } d | _ t" | d	  r| j$ | _$ | _( n  t" | d  r)| j) | _) | _* n  | | _ | j |  | } q| j   } | j   | d } qn  t+ d   qWd  S(   Ni    i   (   Rq   s   $endiR   R8   R5   RA   s(   yacc: Syntax error at line %d, token=%s
s   yacc: Syntax error, token=%ss    yacc: Parse error in input. EOF
RH   s   yacc: internal parser error!!!
(,   R4   RR   RT   RP   R^   R1   Rr   Rq   R5   R+   Rm   R(   RZ   R[   R3   R\   R-   R   RV   Rw   Rx   R   R   R8   R2   Rb   R{   RM   R|   R}   R~   RW   RB   R*   R   R,   RA   Rh   Ri   R   RD   RH   RI   R   (   R   Rm   R5   R
   Rn   Ro   R   R   Rc   RT   R   R^   R   R   Rq   R   RZ   R[   R   R]   Rb   R   R   R   R   R   R   R9   R   R   RA   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRl     s8   															
					
		

					

		
						 !
				

(   R   R   R   R$   R&   RU   Re   R4   R~   Rp   Rj   Rk   Rl   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRN     s   					 \ 3s   ^[a-zA-Z0-9_-]+$t
   Productionc           B   sb   e  Z d  Z d d d d  d  Z d   Z d   Z d   Z d   Z d   Z	 d	   Z
 d
   Z RS(   i    t   rightRr   c   	      C   s   | |  _  t |  |  _ | |  _ | |  _ d  |  _ | |  _ | |  _ | |  _	 t
 |  j  |  _
 g  |  _ x3 |  j D]( } | |  j k rs |  j j |  qs qs Wg  |  _ d  |  _ |  j r d |  j  d j |  j  f |  _ n d |  j  |  _ d  S(   Ns   %s -> %sRs   s   %s -> <empty>(   R   t   tupleR   t   numbert   funcR4   R{   t   filet   linet   precR   t   usymsR\   t   lr_itemst   lr_nextRy   R/   (	   R   R   R   R   t
   precedenceR   R   R   R6   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s$    											%c         C   s   |  j  S(   N(   R/   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR.   =  s    c         C   s   d t  |   d S(   Ns   Production(t   )(   R/   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR0   @  s    c         C   s   t  |  j  S(   N(   R   R   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR@   C  s    c         C   s   d S(   Ni   (    (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   __nonzero__F  s    c         C   s   |  j  | S(   N(   R   (   R   t   index(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR:   I  s    c         C   s   | t  |  j  k r d  St |  |  } y t | j | d | _ Wn  t t f k
 rf g  | _ n Xy | j | d | _ Wn t k
 r d  | _ n X| S(   Ni   (	   R   R   R4   t   LRItemt	   Prodnamest   lr_aftert
   IndexErrort   KeyErrort	   lr_before(   R   R9   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   lr_itemM  s    c         C   s    |  j  r | |  j  |  _ n  d  S(   N(   R   R{   (   R   t   pdict(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   bind]  s    	(   s   righti    N(   R   R   t   reducedR4   R   R.   R0   R@   R   R:   R   R   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s   						t   MiniProductionc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   sC   | |  _  | |  _ | |  _ d  |  _ | |  _ | |  _ | |  _ d  S(   N(   R   R   R   R4   R{   R   R   R/   (   R   R/   R   R   R   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR   f  s    						c         C   s   |  j  S(   N(   R/   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR.   o  s    c         C   s   d |  j  S(   Ns   MiniProduction(%s)(   R/   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR0   r  s    c         C   s    |  j  r | |  j  |  _ n  d  S(   N(   R   R{   (   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR   v  s    	(   R   R   R   R.   R0   R   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR   e  s   				R   c           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   | j  |  _  t | j  |  _ | j |  _ | |  _ i  |  _ |  j j | d  t |  j  |  _ t |  j  |  _ | j	 |  _	 d  S(   Nt   .(
   R   R`   R   R   t   lr_indext
   lookaheadst   insertR   R   R   (   R   R   R9   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s    		c         C   s<   |  j  r+ d |  j d j |  j   f } n d |  j } | S(   Ns   %s -> %sRs   s   %s -> <empty>(   R   R   Ry   (   R   R6   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR.     s    	"c         C   s   d t  |   d S(   Ns   LRItem(R   (   R/   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR0     s    (   R   R   R   R.   R0   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s   		c         C   sI   t  |   d } x2 | d k rD |  | | k r7 |  | S| d 8} q Wd  S(   Ni   i    (   R   R4   (   t   symbolst	   terminalsR=   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   rightmost_terminal  s    t   GrammarErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s   t   Grammarc           B   s   e  Z d    Z d   Z d   Z d   Z d d d d  Z d d  Z d   Z	 d	   Z
 d
   Z d   Z d   Z d   Z d   Z d   Z d d  Z d   Z RS(   c         C   s   d  g |  _ i  |  _ i  |  _ i  |  _ x | D] } g  |  j | <q. Wg  |  j d <i  |  _ i  |  _ i  |  _ i  |  _ t	   |  _
 d  |  _ d  S(   NR   (   R4   t   ProductionsR   t   Prodmapt	   Terminalst   Nonterminalst   Firstt   Followt
   Precedencet   sett   UsedPrecedencet   Start(   R   R   t   term(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s    							c         C   s   t  |  j  S(   N(   R   R   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR@     s    c         C   s   |  j  | S(   N(   R   (   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR:     s    c         C   sr   |  j  d  g k s t d   | |  j k r@ t d |   n  | d k r[ t d   n  | | f |  j | <d  S(   Ns2   Must call set_precedence() before add_production()s,   Precedence already specified for terminal %rt   leftR   t   nonassocs:   Associativity must be one of 'left','right', or 'nonassoc'(   s   lefts   rightR   (   R   R4   t   AssertionErrorR   R   (   R   R   t   assoct   level(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   set_precedence  s    Rr   i    c         C   s  | |  j  k r+ t d | | | f   n  | d k rS t d | | | f   n  t j |  s~ t d | | | f   n  x t |  D] \ } } | d d k r+ym t |  } t |  d k r t d | | | | f   n  | |  j  k rg  |  j  | <n  | | | <w Wq+t k
 r'q+Xn  t j |  r | d	 k r t d
 | | | | f   q q Wd	 | k r | d d	 k rt d | | f   n  | d d	 k rt d | | f   n  | d }	 |  j j	 |	  }
 |
 st d | | |	 f   n |  j
 j |	  | d 3n' t | |  j   }	 |  j j	 |	 d  }
 d | | f } | |  j k r|  j | } t d | | | f d | j | j f   n  t |  j  } | |  j k rg  |  j | <n  xg | D]_ } | |  j  k r|  j  | j |  q| |  j k r#g  |  j | <n  |  j | j |  qWt | | | |
 | | |  } |  j j |  | |  j | <y |  j | j |  Wn! t k
 r| g |  j | <n Xd  S(   Ns7   %s:%d: Illegal rule name %r. Already defined as a tokenR   s5   %s:%d: Illegal rule name %r. error is a reserved words   %s:%d: Illegal rule name %ri    s   '"i   sA   %s:%d: Literal token %s in rule %r may only be a single characters   %precs!   %s:%d: Illegal name %r in rule %ris+   %s:%d: Syntax error. Nothing follows %%precisH   %s:%d: Syntax error. %%prec can only appear at the end of a grammar rules/   %s:%d: Nothing known about the precedence of %rR   s   %s -> %ss   %s:%d: Duplicate rule %s. s   Previous definition at %s:%d(   s   righti    (   R   R   t   _is_identifiert   matcht	   enumeratet   evalR   RM   R   Rx   R   t   addR   R   R   R   R   R   R\   R   R   R   (   R   t   prodnamet   symsR   R   R   R9   R6   t   ct   precnamet   prodprect   mapt   mt   pnumberR   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   add_production  sp    
#

c         C   sx   | s |  j  d j } n  | |  j k r; t d |   n  t d d | g  |  j  d <|  j | j d  | |  _ d  S(   Ni   s   start symbol %s undefinedi    s   S'(   R   R   R   R   R   R\   R   (   R   t   start(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt	   set_starta  s    c            s\       f d     t        j d j d  g   j D] } |  k r@ | ^ q@ S(   Nc            s_   |   k r d  S j  |   x;  j j |  g   D]$ } x | j D] }   |  qC Wq3 Wd  S(   N(   R   R   Rx   R   (   R6   R   R   (   t   mark_reachable_fromt	   reachableR   (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR   t  s    i    (   R   R   R   R   (   R   R6   (    (   R   R   R   s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   find_unreachableq  s    	c         C   sY  i  } x |  j  D] } t | | <q Wt | d <x |  j D] } t | | <q8 Wx t r t } x |  j j   D]r \ } } xc | D][ } x+ | j D] } | | s t } Pq q Wt } | r~ | | s t | | <t } n  Pq~ q~ Wqk W| sO PqO qO Wg  }	 x] | j   D]O \ } }
 |
 s| |  j k rA| |  j  k rA| d k rAqQ|	 j |  qqW|	 S(   Ns   $endR   (   R   RV   R   R~   R   R_   R   R\   (   R   t
   terminatesR   R9   t   some_changet   plR   R6   t   p_terminatest   infiniteR   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   infinite_cycles  s:    
	


	*c         C   s~   g  } xq |  j  D]f } | s" q n  xQ | j D]F } | |  j k r, | |  j k r, | d k r, | j | | f  q, q, Wq W| S(   NR   (   R   R   R   R   R\   (   R   R   R   R6   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   undefined_symbols  s    *c         C   sM   g  } x@ |  j  j   D]/ \ } } | d k r | r | j |  q q W| S(   NR   (   R   R_   R\   (   R   t
   unused_tokR6   R;   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   unused_terminals  s
    c         C   sQ   g  } xD |  j  j   D]3 \ } } | s |  j | d } | j |  q q W| S(   Ni    (   R   R_   R   R\   (   R   t   unused_prodR6   R;   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   unused_rules  s    c         C   s]   g  } xP |  j  D]E } | |  j k p1 | |  j k s | j | |  j  | d f  q q W| S(   Ni    (   R   R   R   R\   (   R   t   unusedt   termname(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   unused_precedence  s
    %c         C   s   g  } xt | D]_ } t  } xF |  j | D]7 } | d k rB t } q' | | k r' | j |  q' q' W| rk q Pq W| j d  | S(   Ns   <empty>(   R~   R   RV   R\   (   R   t   betaR   t   xt   x_produces_emptyR   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   _first	  s    	c         C   s  |  j  r |  j  Sx! |  j D] } | g |  j  | <q Wd g |  j  d <x |  j D] } g  |  j  | <qN Wx t r t } xv |  j D]k } xb |  j | D]S } xJ |  j | j  D]6 } | |  j  | k r |  j  | j |  t } q q Wq Wq~ W| sh Pqh qh W|  j  S(   Ns   $end(	   R   R   R   RV   R~   R   R   R   R\   (   R   R   R9   R   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   compute_first,  s$    		c   
      C   s  |  j  r |  j  S|  j s& |  j   n  x |  j D] } g  |  j  | <q0 W| s` |  j d j } n  d g |  j  | <xSt rt } x6|  j d D]'} xt | j	  D]\ } } | |  j k r |  j
 | j	 | d  } t } x_ | D]W }	 |	 d k r'|	 |  j  | k r'|  j  | j |	  t } n  |	 d k r t } q q W| s_| t | j	  d k rxK |  j  | j D]6 }	 |	 |  j  | k rp|  j  | j |	  t } qpqpWqq q Wq W| ss Pqs qs W|  j  S(   Ni   s   $ends   <empty>(   R   R   R   R   R   R   RV   R~   R   R   R   R\   R   (
   R   R   t   kt   didaddR   R=   t   Bt   fstt   hasemptyR   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   compute_followQ  s<    				c         C   s  x
|  j  D] } | } d } g  } x t r | t |  k rF d  } n t | |  } y |  j | j | d | _ Wn  t t	 f k
 r g  | _ n Xy | j | d | _
 Wn t k
 r d  | _
 n X| | _ | s Pn  | j |  | } | d 7} q% W| | _ q
 Wd  S(   Ni    i   (   R   RV   R   R4   R   R   R   R   R   R   R   R   R\   R   (   R   R   t   lastlriR=   R   t   lri(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   build_lritems  s.    			N(   R   R   R   R@   R:   R   R4   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s    	$			T		@					#	%;t   VersionErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s   t   LRTablec           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s(   d  |  _ d  |  _ d  |  _ d  |  _ d  S(   N(   R4   RQ   RS   RO   t	   lr_method(   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s    			c         B   s   e  | e j  r | } n d | d  Ue j | } | j e k rR e d   n  | j |  _	 | j
 |  _ g  |  _ x' | j D] } |  j j e |    q} W| j |  _ | j S(   Ns	   import %ss&   yacc table file version is out of date(   R7   t   typest
   ModuleTypeRh   t   modulest   _tabversiont   __tabversion__R   t
   _lr_actionRQ   t   _lr_gotoRS   RO   t   _lr_productionsR\   R   t
   _lr_methodR   t   _lr_signature(   R   t   moduleR    R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt
   read_table  s    		c         C   s  y d d  l  } Wn t k
 r/ d d  l } n Xt j j |  sK t  n  t | d  } | j |  } | t k r t	 d   n  | j |  |  _
 | j |  } | j |  |  _ | j |  |  _ | j |  } g  |  _ x$ | D] } |  j j t |    q W| j   | S(   Nit   rbs&   yacc table file version is out of date(   t   cPicklet   ImportErrort   picklet   ost   patht   existst   opent   loadR   R   R   RQ   RS   RO   R\   R   t   close(   R   t   filenameR  t   in_ft
   tabversiont	   signatureRP   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   read_pickle  s(    		
c         C   s%   x |  j  D] } | j |  q
 Wd  S(   N(   RO   R   (   R   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   bind_callables  s    (   R   R   R   R  R  R  (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR     s   			c      	   C   sq   i  } x |  D] } d | | <q Wg  } i  } x= |  D]5 } | | d k r4 t  | | | | |  | |  q4 q4 W| S(   Ni    (   t   traverse(   t   Xt   Rt   FPt   NR   R3   t   F(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   digraph  s    #c      	   C   s]  | j  |   t |  } | | |  <| |   | |  <| |   } x | D] }	 | |	 d k r{ t |	 | | | | | |  n  t | |  | |	  | |  <x> | j |	 g   D]* }
 |
 | |  k r | |  j  |
  q q WqF W| |  | k rYt | | d <| |  | | d <| j   } x? | |  k rUt | | d <| |  | | d <| j   } qWn  d  S(   Ni    i(   R\   R   R  t   minRx   t   MAXINTRw   (   R   R  R3   R  R  R  R  t   dt   relt   yt   at   element(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s(    
t	   LALRErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR"  )  s   t   LRGeneratedTablec           B   s   e  Z d  d 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 d d  Z d d  Z RS(   R   c         C   s   | d k r t  d |   n  | |  _ | |  _ | sC t   } n  | |  _ i  |  _ i  |  _ | j |  _ i  |  _	 i  |  _
 d |  _ d |  _ d |  _ g  |  _ g  |  _ g  |  _ |  j j   |  j j   |  j j   |  j   d  S(   Nt   SLRR   s   Unsupported method %si    (   R$  R   (   R"  t   grammarR   R   t   logRQ   RS   R   RO   t   lr_goto_cachet   lr0_cidhasht
   _add_countt   sr_conflictt   rr_conflictt	   conflictst   sr_conflictst   rr_conflictsR   R   R   t   lr_parse_table(   R   R%  t   methodR&  (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR   4  s,    													c         C   s   |  j  d 7_  | } t } xx | r t } xe | D]] } xT | j D]I } t | d d  |  j  k ri qB n  | j | j  |  j  | _ t } qB Wq2 Wq W| S(   Ni   t	   lr0_addedi    (   R)  RV   R~   R   RB   R\   R   R1  (   R   t   It   JR   R>   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   lr0_closureY  s    	c   	      C   s6  |  j  j t |  | f  } | r( | S|  j  j |  } | sV i  } | |  j  | <n  g  } xv | D]n } | j } | rc | j | k rc | j t |   } | s i  } | | t |  <n  | j |  | } qc qc W| j d  } | s| r|  j |  } | | d <q| | d <n  | |  j  t |  | f <| S(   Ns   $end(   R'  Rx   R   R   R   R\   R4  (	   R   R2  R   t   gR6   t   gsR   R9   t   s1(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   lr0_gotos  s2    	c   	      C   s-  |  j  |  j j d j g  g } d } x+ | D]# } | |  j t |  <| d 7} q/ Wd } x | t |  k  r(| | } | d 7} i  } x, | D]$ } x | j D] } d  | | <q Wq Wxh | D]` } |  j	 | |  } | s t |  |  j k r q n  t |  |  j t |  <| j
 |  q Wq_ W| S(   Ni    i   (   R4  R%  R   R   R(  R   R   R   R4   R8  R\   (	   R   t   CR=   R2  t   asymst   iiR6   R   R5  (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt	   lr0_items  s(    "

c         C   s   t    } d } x t r xq |  j j d D]_ } | j d k rT | j | j  q) n  x1 | j D] } | | k r^ Pq^ q^ W| j | j  q) Wt |  | k r Pn  t |  } q W| S(   Ni    i   (   R   RV   R%  R   R   R   R   R   (   R   t   nullablet   num_nullableR   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   compute_nullable_nonterminals  s    		c         C   s   g  } x t  |  D] \ } } xv | D]n } | j | j d k  r& | | j | j d f } | d |  j j k r | | k r | j |  q q q& q& Wq W| S(   Ni   (   R   R   R   R   R%  R   R\   (   R   R9  t   transt   statenoRb   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   find_nonterminal_transitions  s    c         C   s   i  } | \ } } g  } |  j  | | |  } xl | D]d }	 |	 j |	 j d k  r5 |	 j |	 j d }
 |
 |  j j k r |
 | k r | j |
  q q q5 q5 W| d k r | |  j j d j d k r | j d  n  | S(   Ni   i    s   $end(   R8  R   R   R   R%  R   R\   R   (   R   R9  R@  R=  t   dr_setRb   R  t   termsR5  R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   dr_relation  s    )c         C   s   g  } | \ } } |  j  | | |  } |  j j t |  d  } x] | D]U }	 |	 j |	 j d k  rJ |	 j |	 j d }
 |
 | k r | j | |
 f  q qJ qJ W| S(   Nii   (   R8  R(  Rx   R   R   R   R   R\   (   R   R9  R@  t   emptyR  Rb   R  R5  R>   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   reads_relation	  s    c         C   sl  i  } i  } i  } x | D] } d | | <q Wx2| D]*\ } }	 g  }
 g  } x| | D]} | j  |	 k rr qW n  | j } | } x | | j d k  rh| d } | j | } | | f | k r4| d } xg | | j k  r| j | |  j j k r Pn  | j | | k rPn  | d } q W| j | | f  n  |  j | | |  } |  j j	 t
 |  d  } q Wx | | D] } | j  | j  k rqtn  | j | j k rqtn  d } xR | | j k  r| j | | j | d k rPn  | d } qW|
 j | | f  qtWqW Wx> | D]6 } | | k r3g  | | <n  | | j | |	 f  qW|
 | | |	 f <q4 W| | f S(   Ni   ii    (   R   R   R   R   R%  R   R\   R8  R(  Rx   R   (   R   R9  R@  R=  t   lookdictt   includedictt   dtransR   Rb   R  t   lookbt   includesR   R   R>   t   liR5  R   R=   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   compute_lookback_includesC	  sX    	

c            s@       f d   }     f d   } t  | | |  } | S(   Nc            s    j    |    S(   N(   RE  (   R   (   R9  R=  R   (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   <lambda>	  s    c            s    j    |    S(   N(   RG  (   R   (   R9  R=  R   (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRO  	  s    (   R  (   R   R9  t   ntransR=  R  R  R  (    (   R9  R=  R   s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   compute_read_sets	  s    c            s4    f d   }   f d   } t  | | |  } | S(   Nc            s     |  S(   N(    (   R   (   t   readsets(    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRO  	  s    c            s     j  |  g   S(   N(   Rx   (   R   (   t   inclsets(    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRO  	  s    (   R  (   R   RP  RR  RS  R  R  R  (    (   RS  RR  s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   compute_follow_sets	  s    c   	      C   s   x | j    D] \ } } x | D]x \ } } | | j k rK g  | j | <n  | j | g   } x8 | D]0 } | | j | k rd | j | j |  qd qd Wq  Wq Wd  S(   N(   R_   R   Rx   R\   (	   R   t	   lookbackst	   followsetR@  t   lbRb   R   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   add_lookaheads	  s    c         C   st   |  j    } |  j |  } |  j | | |  } |  j | | |  \ } } |  j | | |  } |  j | |  d  S(   N(   R?  RB  RQ  RN  RT  RX  (   R   R9  R=  R@  RR  t   lookdt   includedt
   followsets(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   add_lalr_lookaheads	  s    c   $   	   C   s  |  j  j } |  j  j } |  j } |  j } |  j } i  } | j d |  j  |  j   } |  j d k rw |  j	 |  n  d } x| D]}	 g  }
 i  } i  } i  } | j d  | j d |  | j d  x$ |	 D] } | j d | j
 |  q W| j d  x"|	 D]} | j | j d k r| j d k rId | d	 <| | d	 <q!|  j d k rh| j | } n |  j  j | j } x| D]|} |
 j | | d
 | j
 | f f  | j |  } | d  k	 r| d k r| j | d  \ } } | | j
 j \ } } | | k  s$| | k r| d k r| j
 | | <| | | <| rv| rv| j d |  |  j j | | d f  n  | | j
 j d 7_ q| | k r| d k rd  | | <q| s| j d |  |  j j | | d f  qq| d k  r| | } | | j
 } | j | j k rs| j
 | | <| | | <| | } } | | j
 j d 7_ | | j
 j d 8_ n | | } } |  j j | | | f  | j d | | | j
 | |  qt d |   q| j
 | | <| | | <| | j
 j d 7_ qWq| j } | j | d } | |  j  j k r|  j |	 |  } |  j j t |  d  } | d k r!|
 j | | d | f  | j |  } | d  k	 r| d k r| | k rt d |   qq| d k  r| j | d  \ } } | | | j
 j \ } } | | k s/| | k r| d k r| | | j
 j d 8_ | | | <| | | <| s| j d |  |  j j | | d f  qq| | k r| d k rd  | | <q| r| r| j d |  |  j j | | d f  qqt d |   q| | | <| | | <q!qqWi  } x\ |
 D]T \ } } } | | k r2| | | k r| j d | |  d | | | f <qq2q2W| j d  d } xw |
 D]o \ } } } | | k r| | | k	 r| | f | k r| j d | |  d } d | | | f <qqqqW| r-| j d  n  i  }  xA |	 D]9 }! x0 |! j D]% }" |" |  j  j  k rJd  |  |" <qJqJWq:Wxg |  D]_ }# |  j |	 |#  } |  j j t |  d  } | d k r~| | |# <| j d |# |  q~q~W| | | <| | | <| | | <| d 7} q Wd  S(   Ns   Parsing method: %sR   i    Rr   s   state %ds       (%d) %si   s   S's   $ends   reduce using rule %d (%s)R   R   s3     ! shift/reduce conflict for %s resolved as reducet   reduceR   s2     ! shift/reduce conflict for %s resolved as shiftt   shifts=     ! reduce/reduce conflict for %s resolved using rule %d (%s)s   Unknown conflict in state %dis   shift and go to state %ds    Shift/shift conflict in state %ds       %-15s %ss     ! %-15s [ %s ]s"       %-30s shift and go to state %d(   s   righti    (   s   righti    (!   R%  R   R   RS   RQ   R&  R   R   R<  R\  R   R   R   R   R   R   R\   Rx   R4   R   R-  R   R   R.  R"  R   R   R8  R(  R   R
   R   R   ($   R   R   R   RT   RR   R&  t   actionpR9  t   stR2  t   actlistt	   st_actiont
   st_actionpt   st_gotoR   t   laheadsR   R   t   sprect   slevelt   rprect   rlevelt   oldpt   ppt   chosenpt   rejectpR=   R5  R>   t	   _actprintR   t   not_usedt   nkeysR;  R6   R9   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR/  	  s    			
#$

	
	$






Rr   c      	   C   s  t  | t j  r! t d   n  | j d  d } t j j | |  d } yVt | d  } | j	 d t j j
 |  t |  j | f  d } | ri  } x |  j j   D]y \ }	 }
 xj |
 j   D]\ \ } } | j |  } | s g  g  f } | | | <n  | d j |	  | d j |  q Wq W| j	 d	  x | j   D] \ } } | j	 d
 |  x# | d D] } | j	 d |  qlW| j	 d  x# | d D] } | j	 d |  qW| j	 d  qDW| j	 d  | j	 d  n\ | j	 d  x? |  j j   D]. \ } } | j	 d | d | d | f  qW| j	 d  | ri  } x |  j j   D]y \ }	 }
 xj |
 j   D]\ \ } } | j |  } | sg  g  f } | | | <n  | d j |	  | d j |  qyWq`W| j	 d  x | j   D] \ } } | j	 d
 |  x# | d D] } | j	 d |  qW| j	 d  x# | d D] } | j	 d |  qRW| j	 d  qW| j	 d  | j	 d  n\ | j	 d  x? |  j j   D]. \ } } | j	 d | d | d | f  qW| j	 d  | j	 d  x |  j D]y } | j ra| j	 d | j | j | j | j t j j
 | j  | j f  q| j	 d t |  | j | j f  qW| j	 d  | j   Wn t k
 r}   n Xd  S(   Ns"   Won't overwrite existing tabmoduleR   is   .pyt   wsu   
# %s
# This file is automatically generated. Do not edit.
_tabversion = %r

_lr_method = %r

_lr_signature = %r
    i   i    s   
_lr_action_items = {s   %r:([s   %r,s   ],[s   ]),s   }
s   
_lr_action = {}
for _k, _v in _lr_action_items.items():
   for _x,_y in zip(_v[0],_v[1]):
      if not _x in _lr_action:  _lr_action[_x] = {}
      _lr_action[_x][_k] = _y
del _lr_action_items
s   
_lr_action = { s   (%r,%r):%r,s   
_lr_goto_items = {s   
_lr_goto = {}
for _k, _v in _lr_goto_items.items():
   for _x, _y in zip(_v[0], _v[1]):
       if not _x in _lr_goto: _lr_goto[_x] = {}
       _lr_goto[_x][_k] = _y
del _lr_goto_items
s   
_lr_goto = { s   _lr_productions = [
s     (%r,%r,%d,%r,%r,%d),
s     (%r,%r,%d,None,None,None),
s   ]
(   R7   R   R   t   IOErrort   splitR  R	  Ry   R  R   t   basenameR   R   RQ   R_   Rx   R\   RS   RO   R   R/   R   R   R   R   R  (   R   t	   tabmodulet	   outputdirR  t   basemodulenameR  R   t   smallerR_   R6   t   ndR   R;   R=   R   R   t   e(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   write_table
  s    &
&
&	)*c         C   sU  y d d  l  } Wn t k
 r/ d d  l } n Xt | d  } | j t | t  | j |  j | t  | j | | t  | j |  j | t  | j |  j	 | t  g  } x |  j
 D]z } | j r	| j | j | j | j | j t j j | j  | j f  q | j t |  | j | j d  d  d  f  q W| j | | t  Wd  QXd  S(   Nit   wb(   R  R  R  R  t   dumpR   t   pickle_protocolR   RQ   RS   RO   R   R\   R/   R   R   R  R	  Rt  R   R   R4   (   R   R  R  R  t   outft   outpR   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   pickle_table   s     	@/N(   R   R   R4   R   R4  R8  R<  R?  RB  RE  RG  RN  RQ  RT  RX  R\  R/  R{  R  (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR#  3  s    %		#	8				+	P					zc         C   sG   t  j |   } | j j   } | j | j k rC | j | j  n  | S(   N(   Rh   t	   _getframet	   f_globalst   copyt   f_localst   update(   t   levelsR   t   ldict(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   get_caller_module_dictC  s
    c         C   sO  g  } |  j    } d  } | } x*| D]"} | d 7} | j   } | sM q% n  y | d d k r | s t d | | f   n  | }	 | d }
 nU | d }	 |	 } | d }
 | d } | d k r | d k r t d | | f   n  | j | | |	 |
 f  Wq% t k
 r  q% t k
 rFt d	 | | | j   f   q% Xq% W| S(
   Ni   i    t   |s   %s:%d: Misplaced '|'i   t   :s   ::=s!   %s:%d: Syntax error. Expected ':'s   %s:%d: Syntax error in rule %r(   t
   splitlinesR4   Rs  RM   R\   t	   Exceptiont   strip(   t   docR   R   R%  t   pstringst   lastpt   dlinet   psR   R   R   t   assign(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   parse_grammarO  s6    



't   ParserReflectc           B   s   e  Z d 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 RS(   c         C   sp   | |  _  d  |  _ d  |  _ d  |  _ t   |  _ g  |  _ t |  _	 | d  k rc t
 t j  |  _ n	 | |  _ d  S(   N(   R   R4   R   t
   error_funct   tokensR   R   R%  R~   R   R   Rh   Ri   R&  (   R   R   R&  (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR   y  s    						c         C   s6   |  j    |  j   |  j   |  j   |  j   d  S(   N(   t	   get_startt   get_error_funct
   get_tokenst   get_precedencet   get_pfunctions(   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   get_all  s
    



c         C   sC   |  j    |  j   |  j   |  j   |  j   |  j   |  j S(   N(   t   validate_startt   validate_error_funct   validate_tokenst   validate_precedencet   validate_pfunctionst   validate_modulesR   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   validate_all  s    





c         C   s   g  } y |  j  r% | j |  j   n  |  j rf | j d j g  |  j D] } d j |  ^ qD   n  |  j r | j d j |  j   n  x/ |  j D]$ } | d r | j | d  q q WWn t t f k
 r n Xd j |  S(   NRr   Rs   i   (   R   R\   R   Ry   R  t   pfuncst	   TypeErrort
   ValueError(   R   t   partsR   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s    		8	
c         C   s   t  j d  } x |  j D] } y t j |  \ } } Wn t k
 rN q n Xi  } x t |  D] \ } } | d 7} | j |  } | rb | j d  } | j	 |  }	 |	 s | | | <q t j
 |  }
 |  j j d |
 | | |	  qb qb Wq Wd  S(   Ns   \s*def\s+(p_[a-zA-Z_0-9]*)\(i   s;   %s:%d: Function %s redefined. Previously defined on line %d(   t   ret   compileR   t   inspectt   getsourcelinesRr  R   R   t   groupRx   t   getsourcefileR&  R   (   R   t   freR  t   linest   linent	   counthashR   R   R   t   prevR  (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s$    
c         C   s   |  j  j d  |  _ d  S(   NR   (   R   Rx   R   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s    c         C   s;   |  j  d  k	 r7 t |  j  t  s7 |  j j d  q7 n  d  S(   Ns   'start' must be a string(   R   R4   R7   t   string_typesR&  R   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s    c         C   s   |  j  j d  |  _ d  S(   Nt   p_error(   R   Rx   R  (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s    c         C   s   |  j  r t |  j  t j  r' d } n; t |  j  t j  rE d } n |  j j d  t |  _ d  S|  j  j j	 } |  j  j j
 } t j |  j   } |  j j |  |  j  j j | } | d k r |  j j d | |  t |  _ q n  d  S(   Ni    i   s2   'p_error' defined, but is not a function or methods$   %s:%d: p_error() requires 1 argument(   R  R7   R   t   FunctionTypet
   MethodTypeR&  R   RV   t   __code__t   co_firstlinenot   co_filenameR  t	   getmoduleR   R   t   co_argcount(   R   t   ismethodt   elinet   efileR  t   argcount(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s     				c         C   s   |  j  j d  } | s5 |  j j d  t |  _ d  St | t t f  sg |  j j d  t |  _ d  S| s |  j j d  t |  _ d  S| |  _ d  S(   NR  s   No token list is defineds   tokens must be a list or tuples   tokens is empty(	   R   Rx   R&  R   RV   R7   R`   R   R  (   R   R  (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s    			c         C   s|   d |  j  k r, |  j j d  t |  _ d  St   } x@ |  j  D]5 } | | k rg |  j j d |  n  | j |  q? Wd  S(   NR   s.   Illegal token name 'error'. Is a reserved words   Token %r multiply defined(   R  R&  R   RV   R   R   R   (   R   R   R9   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s    		c         C   s   |  j  j d  |  _ d  S(   NR   (   R   Rx   R   (   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s    c         C   si  g  } |  j  r\t |  j  t t f  sD |  j j d  t |  _ d  Sxt |  j   D]\ } } t | t t f  s |  j j d  t |  _ d  St |  d k  r |  j j d |  t |  _ d  S| d } t | t	  s |  j j d  t |  _ d  SxX | d D]L } t | t	  s7|  j j d  t |  _ d  S| j
 | | | d f  qWqT Wn  | |  _ d  S(	   Ns"   precedence must be a list or tuples   Bad precedence tablei   s?   Malformed precedence entry %s. Must be (assoc, term, ..., term)i    s)   precedence associativity must be a stringi   s    precedence items must be strings(   R   R7   R`   R   R&  R   RV   R   R   R  R\   t   preclist(   R   R  R   R   R   R   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR    s6    				
		%c         C   s   g  } x |  j  j   D] \ } } | j d  s | d k rD q n  t | t j t j f  r t | d | j j	  } t
 j |  } | j | | | | j f  q q W| j d d    | |  _ d  S(   Nt   p_R  R  t   keyc         S   s&   |  d t  |  d  |  d |  d f S(   Ni    i   i   i   (   R/   (   t
   p_function(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyRO  D  s    (   R   R_   t
   startswithR7   R   R  R  RB   R  R  R  R  R\   t   __doc__t   sortR  (   R   t   p_functionsR   t   itemR   R  (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR  7  s    #c         C   s  g  } t  |  j  d k r8 |  j j d  t |  _ d  Sxu|  j D]j\ } } } } t j |  } |  j | } t | t	 j
  r d } n d } | j j | k r |  j j d | | | j  t |  _ qB | j j | k  r|  j j d | | | j  t |  _ qB | j s-|  j j d | | | j  qB y: t | | |  }	 x! |	 D] }
 | j | |
 f  qIWWn2 t k
 r} |  j j t |   t |  _ n X|  j j |  qB WxO|  j j   D]>\ } } | j d  rt | t	 j t	 j
 f  rqn  | j d	  rqn  | j d  rB| d
 k rB|  j j d |  n  t | t	 j  rf| j j d k st | t	 j
  r| j j j d k r| j ryN | j j d  } | d d k r|  j j d | j j | j j |  n  Wqt k
 rqXqqqW| |  _ d  S(   Ni    s+   no rules of the form p_rulename are definedi   i   s%   %s:%d: Rule %r has too many argumentss#   %s:%d: Rule %r requires an argumentsA   %s:%d: No documentation string specified in function %r (ignored)R  t   t_R  s   %r not defined as a functionRs   R  s9   %s:%d: Possible grammar rule %r defined without p_ prefix(   R   R  R&  R   RV   R  R  R   R7   R   R  R  R  R   R  R   R  R\   RM   R/   R   R   R_   R  R  t   __func__Rs  R  R  R   R%  (   R   R%  R   R  R   R  R   R   t   reqargst   parsed_gR5  Rz  R9   R;   (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR  L  s\    			*$'	 N(   R   R   R4   R   R  R  R  R  R  R  R  R  R  R  R  R  R  R  (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyR  x  s   		
											c   >   	   B   s  | d  k r e } n  | r$ d } n  | d  k rB e e j  } n  | r g  e |  D] } | e | |  f ^ qU } e |  } d | k r e j | d j	 | d <q n e
 d  } |	 d  k rWe | e j  r | j	 } n` d | k r | d } nG | j d  } d j | d   } d | d  Ue e j | d d  } e j j |  }	 n  | j d	  } | re | e  rd | k r| d | } qn  | d  k	 r| | d
 <n  e | d | } | j   | j re d   n  | j   } y e   } | r| j |  } n | j |  } | s9| | k ry3 | j | j  e | | j   } | j! a! | SWqe" k
 r} | j# d |  qXn  Wn6 e$ k
 r} | j# e |   n e% k
 rn X|
 d  k rN| rBy( e e& e j j |	 |  d   }
 WqKe' k
 r>} | j# d | | f  e(   }
 qKXqNe(   }
 n  |
 j) d e*  e+ } | j,   re d   n  | j  s| j# d  n  e- | j.  } xW | j/ D]L \ } } } y | j0 | | |  Wqe1 k
 r} | j# d |  qXqWxr | j2 D]g \ } }  |  \ }! }" }# }$ y | j3 |# |$ | |! |"  Wqe1 k
 rq} | j d |  e4 } qXqWy0 | d  k r| j5 | j6  n | j5 |  Wn, e1 k
 r} | j e |   e4 } n X| re d   n  | j7   }% x6 |% D]. \ }& }' | j d |' j8 |' j9 |&  e4 } qW| j:   }( |( r|
 j) d  |
 j) d  |
 j) d  x1 |( D]& } | j# d |  |
 j) d |  qoWn  | r|
 j) d  |
 j) d  |
 j) d  x3 e; | j<  D] \ }) }* |
 j) d |) |*  qWn  | j=   }+ x- |+ D]% }' | j# d |' j8 |' j9 |' j>  qWe? |(  d k r]| j# d  n  e? |(  d k r| j# d e? |(   n  e? |+  d k r| j# d  n  e? |+  d k r| j# d e? |+   n  | r|
 j) d  |
 j) d  |
 j) d  e@ | jA  }, |, jB   xJ |, D]B } |
 j) d  | d! j g  | jA | D] }- e |-  ^ qH  q"W|
 j) d  |
 j) d"  |
 j) d  e@ | jC  }. |. jB   xJ |. D]B }/ |
 j) d  |/ d! j g  | jC |/ D] }- e |-  ^ q  qW|
 j) d  n  | rn| jD   }0 x |0 D] }1 | j# d# |1  qW| jE   }2 x' |2 D] }3 | j d$ |3  e4 } qKWn  | jF   }4 x- |4 D]% \ } } | j d% | |  e4 } qW| re d   n  | r| jG d& |   n  eH | |  |
  } | r	e? | jI  }5 |5 d k r	| j# d'  n |5 d k r:	| j# d( |5  n  e? | jJ  }6 |6 d k re	| j# d)  q	|6 d k r	| j# d* |6  q	n  | r | jI s	| jJ r |
 j# d  |
 j# d+  |
 j# d  x0 | jI D]% \ }7 }8 }9 |
 j# d, |8 |7 |9  q	WeK   }: x | jJ D] \ }7 }; }< |7 eL |;  eL |<  f |: k rB
q
n  |
 j# d- |7 |;  |
 j# d. |< |7  | j# d- |7 |;  | j# d. |< |7  |: jM |7 eL |;  eL |<  f  q
Wg  }= xc | jJ D]U \ }7 }; }< |< jN r
|< |= k r
|
 j# d/ |<  | j# d/ |<  |= jO |<  q
q
Wn  | rmy | jP | |	 |  Wqme' k
 ri} | j# d0 | | f  qmXn  | ry | jQ | |  Wqe' k
 r} | j# d0 | | f  qXn  | j | j  e | | j   } | j! a! | S(1   Ni    t   __file__R   i   R   is	   import %sRr   t   __package__R   R&  s   Unable to build parsers.   There was a problem loading the table file: %rRq  s   Couldn't open %r. %ss5   Created by PLY version %s (http://www.dabeaz.com/ply)s    no p_error() function is defineds   %ss;   %s:%d: Symbol %r used, but not defined as a token or a rules   Unused terminals:s   Token %r defined, but not useds       %sR   s   Rule %-5d %ss$   %s:%d: Rule %r defined, but not usedi   s   There is 1 unused tokens   There are %d unused tokenss   There is 1 unused rules   There are %d unused ruless'   Terminals, with rules where they appears
   %-20s : %sRs   s*   Nonterminals, with rules where they appears   Symbol %r is unreachables)   Infinite recursion detected for symbol %rs0   Precedence rule %r defined for unknown symbol %rs   Generating %s tabless   1 shift/reduce conflicts   %d shift/reduce conflictss   1 reduce/reduce conflicts   %d reduce/reduce conflictss
   Conflicts:s7   shift/reduce conflict for %s in state %d resolved as %ss;   reduce/reduce conflict in state %d resolved using rule (%s)s   rejected rule (%s) in state %ds   Rule (%s) is never reduceds   Couldn't create %r. %s(R   R4   t
   tab_moduleR   Rh   Ri   t   dirRB   t   dictR   R  R  R7   R   R   Rs  Ry   R  R	  t   dirnameRx   R/   R  R  R   R   R  R   R  R  R  R   RN   R  Rp   R  R   R   R  R  Rr  R   R   t   __version__R~   R  R   R  R  R   R   R%  R   RV   R   R   R   R   R   R   R   R   R   R   R   R`   R   R  R   R   R   R   R
   R#  R-  R.  R   R   R   R   R\   R{  R  (>   R0  R
   R  Ru  R   t   check_recursiont   optimizet   write_tablest	   debugfileRv  t   debuglogt   errorlogt
   picklefileR   t   _itemsR   t   srcfileR  t   pkgnamet   pkgt   pinfoR  t   lrt   read_signatureR+   Rz  t   errorsR%  R   R   R   t   funcnamet   gramR   R   R   R   R   R]   R   R   R9   R   R   RD  R6   t   nontermst   nontermt   unreachablet   uR   t   inft   unused_prect   num_srt   num_rrRb   R   t
   resolutiont   already_reportedt   rulet   rejectedt   warned_never(    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   yacc  s   		.
			(	

#
@
@
	!&	(?   R  R   Rh   t   os.pathR  R  t   base64R    R  R   RV   t	   yaccdebugt
   debug_fileR  t
   default_lrR}   R~   Rf   R   R~  t   version_infot
   basestringR  R/   t   maxsizeR  t   objectR   R   R  R   R   R   R4   R#   R'   R%   R"   R$   R&   R(   R,   R-   R1   RN   R  R   R   R   R   R   R   R   R   R   R  R  R"  R#  R  R  R  R  (    (    (    s%   /tmp/pip-build-kpPAdC/ply/ply/yacc.pyt   <module>>   s~   			
	
				4   H.	 T		
   		) 