Ñò
$8Zc           @   s‡   d  d k  l Z l Z l Z d e i f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d	 „  ƒ  YZ	 d
 d „ Z
 d S(   i   (   t   grammart   tokent   tokenizet   PgenGrammarc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR      s   t   ParserGeneratorc           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 d d „ Z d „  Z d „  Z RS(   c         C   s¤   d  } | d  j o t | ƒ } | i } n | |  _ | |  _ t i | i ƒ |  _ |  i	 ƒ  |  i
 ƒ  \ |  _ |  _ | d  j	 o | ƒ  n h  |  _ |  i ƒ  d  S(   N(   t   Nonet   opent   closet   filenamet   streamR   t   generate_tokenst   readlinet	   generatort   gettokent   parset   dfast   startsymbolt   firstt   addfirstsets(   t   selfR
   R   t   close_stream(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyt   __init__   s    		
	c      
   C   sŠ  t  ƒ  } |  i i ƒ  } | i ƒ  | i |  i ƒ | i d |  i ƒ x; | D]3 } d t | i ƒ } | | i | <| | i	 | <qL Wxí | D]å } |  i | } g  } x“ | D]‹ } g  } xE | i
 i ƒ  D]4 \ }	 }
 | i |  i | |	 ƒ | i |
 ƒ f ƒ qÆ W| i o  | i d | i | ƒ f ƒ n | i | ƒ qª W| i i | ƒ | |  i | | ƒ f | i | i | <qŠ W| i |  i | _ | S(   Ni    i   (   R   R   t   keyst   sortt   removeR   t   insertt   lent   symbol2numbert   number2symbolt   arcst	   iteritemst   appendt
   make_labelt   indext   isfinalt   statest
   make_firstt   start(   R   t   ct   namest   namet   it   dfaR%   t   stateR   t   labelt   next(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyt   make_grammar   s6    	
    ,
 *c         C   sD   |  i  | } h  } x* | D]" } |  i | | ƒ } d | | <q W| S(   Ni   (   R   R"   (   R   R(   R*   t   rawfirstR   R.   t   ilabel(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR&   4   s     c         C   sá  t  | i ƒ } | d i ƒ  oë | | i j oN | | i j o | i | S| i i | i | d  f ƒ | | i | <| SqÝt t | d  ƒ } t	 | t
 ƒ p
 t | ‚ | t i j p
 t | ‚ | | i j o | i | S| i i | d  f ƒ | | i | <| SnÓ | d d j p
 t | ‚ t | ƒ } | d i ƒ  oJ | | i j o | i | S| i i t i | f ƒ | | i | <| SnQ t i | } | | i j o | i | S| i i | d  f ƒ | | i | <| Sd  S(   Ni    t   "t   '(   R3   R4   (   R   t   labelst   isalphaR   t   symbol2labelR!   R   t   getattrR   t
   isinstancet   intt   AssertionErrort   tok_namet   tokenst   evalt   keywordst   NAMER    t   opmap(   R   R(   R.   R2   t   itokent   value(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR"   =   s<    c         C   sO   |  i  i ƒ  } | i ƒ  x/ | D]' } | |  i j o |  i | ƒ q  q  Wd  S(   N(   R   R   R   R   t	   calcfirst(   R   R)   R*   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR   k   s    
 c         C   sr  |  i  | } d  |  i | <| d } h  } h  } x¿ | i i ƒ  D]® \ } } | |  i  j ow | |  i j o2 |  i | } | d  j o t d | ƒ ‚ q¸ n |  i | ƒ |  i | } | i | ƒ | | | <q@ d | | <h d | 6| | <q@ Wh  }	 xf | i ƒ  D]X \ } }
 xI |
 D]A } | |	 j o$ t d | | | |	 | f ƒ ‚ n | |	 | <qWqW| |  i | <d  S(   Ni    s   recursion for rule %ri   sA   rule %s is ambiguous; %s is in the first sets of %s as well as %s(   R   R   R   R   R    t
   ValueErrorRD   t   update(   R   R*   R,   R-   t   totalsett   overlapcheckR.   R/   t   fsett   inverset   itsfirstt   symbol(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRD   s   s8    
 
  c   	      C   sõ   h  } d  } xÜ |  i t i j oÈ x" |  i t i j o |  i ƒ  q% W|  i t i ƒ } |  i t i d ƒ |  i	 ƒ  \ } } |  i t i ƒ |  i
 | | ƒ } t | ƒ } |  i | ƒ t | ƒ } | | | <| d  j o
 | } q q W| | f S(   Nt   :(   R   t   typeR   t	   ENDMARKERt   NEWLINER   t   expectR@   t   OPt	   parse_rhst   make_dfaR   t   simplify_dfa(	   R   R   R   R*   t   at   zR,   t   oldlent   newlen(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR   ‘   s&      
c            sF  t  | t ƒ p t ‚ t  | t ƒ p t ‚ ‡  f d †  } ‡  f d †  ‰  t | | ƒ | ƒ g } xÛ | D]Ó } h  } xU | i D]J } xA | i D]6 \ } }	 | d  j	 o ˆ  |	 | i | h  ƒ ƒ q‘ q‘ Wq Wxl | i ƒ  D]^ \ } }
 x? | D] } | i |
 j o Pqï qï Wt |
 | ƒ } | i	 | ƒ | i
 | | ƒ qÜ Wqk W| S(   Nc            s   h  } ˆ  |  | ƒ | S(   N(    (   R-   t   base(   t
   addclosure(    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyt   closure°   s    c            so   t  |  t ƒ p t ‚ |  | j o d  Sd | |  <x5 |  i D]* \ } } | d  j o ˆ  | | ƒ q= q= Wd  S(   Ni   (   R9   t   NFAStateR;   R   R   (   R-   RZ   R.   R/   (   R[   (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR[   ´   s    

 (   R9   R]   R;   t   DFAStatet   nfasetR   R   t
   setdefaultR    R!   t   addarc(   R   R'   t   finishR\   R%   R-   R   t   nfastateR.   R/   R_   t   st(    (   R[   s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRT   ©   s0     
 
 %  	c   
      C   sÐ   d G| GH| g } x· t  | ƒ D]© \ } } d G| G| | j o d p d GHxy | i D]n \ } } | | j o | i | ƒ }	 n t | ƒ }	 | i | ƒ | d  j o d |	 GHqV d | |	 f GHqV Wq Wd  S(   Ns   Dump of NFA fors     States   (final)t    s	       -> %ds       %s -> %d(   t	   enumerateR   R#   R   R!   R   (
   R   R*   R'   Rb   t   todoR+   R-   R.   R/   t   j(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyt   dump_nfaÍ   s    		 !
 c         C   s€   d G| GHxp t  | ƒ D]b \ } } d G| G| i o d p d GHx5 | i i ƒ  D]$ \ } } d | | i | ƒ f GHqP Wq Wd  S(   Ns   Dump of DFA fors     States   (final)Re   s       %s -> %d(   Rf   R$   R   R    R#   (   R   R*   R,   R+   R-   R.   R/   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyt   dump_dfaÝ   s    	  c         C   sª   t  } x | o• t } xˆ t | ƒ D]z \ } } xk t | d t | ƒ ƒ D]P } | | } | | j o3 | | =x | D] } | i | | ƒ qt Wt  } PqI qI Wq# Wq	 Wd  S(   Ni   (   t   Truet   FalseRf   t   rangeR   t
   unifystate(   R   R,   t   changesR+   t   state_iRh   t   state_jR-   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRU   ä   s        
 c         C   sµ   |  i  ƒ  \ } } |  i d j o | | f St ƒ  } t ƒ  } | i | ƒ | i | ƒ xK |  i d j o: |  i ƒ  |  i  ƒ  \ } } | i | ƒ | i | ƒ q\ W| | f Sd  S(   Nt   |(   t	   parse_altRC   R]   Ra   R   (   R   RV   RW   t   aat   zz(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRS   ù   s    		 
c         C   su   |  i  ƒ  \ } } xV |  i d j p |  i t i t i f j o) |  i  ƒ  \ } } | i | ƒ | } q W| | f S(   Nt   (t   [(   Rv   Rw   (   t
   parse_itemRC   RN   R   R@   t   STRINGRa   (   R   RV   t   bR(   t   d(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRs   
  s     c         C   sÇ   |  i  d j oG |  i ƒ  |  i ƒ  \ } } |  i t i d ƒ | i | ƒ | | f S|  i ƒ  \ } } |  i  } | d j o | | f S|  i ƒ  | i | ƒ | d j o | | f S| | f Sd  S(   NRw   t   ]t   +t   *(   R}   R~   (   RC   R   RS   RQ   R   RR   Ra   t
   parse_atom(   R   RV   RW   RC   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRx     s    
	
c         C   s½   |  i  d j o: |  i ƒ  |  i ƒ  \ } } |  i t i d ƒ | | f S|  i t i t i f j o: t	 ƒ  } t	 ƒ  } | i
 | |  i  ƒ |  i ƒ  | | f S|  i d |  i |  i  ƒ d  S(   NRv   t   )s+   expected (...) or NAME or STRING, got %s/%s(   RC   R   RS   RQ   R   RR   RN   R@   Ry   R]   Ra   t   raise_error(   R   RV   RW   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR   (  s    
		
	c         C   sg   |  i  | j p | d  j	 o3 |  i | j o# |  i d | | |  i  |  i ƒ n |  i } |  i ƒ  | S(   Ns   expected %s/%s, got %s/%s(   RN   R   RC   R   R   (   R   RN   RC   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRQ   9  s    -		
c         C   sk   |  i  i ƒ  } x1 | d t i t i f j o |  i  i ƒ  } q W| \ |  _ |  _ |  _ |  _ |  _	 d  S(   Ni    (
   R   R/   R   t   COMMENTt   NLRN   RC   t   begint   endt   line(   R   t   tup(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR   A  s
     c      	   G   su   | o; y | | } WqB d i  | g t t | ƒ ƒ } qB Xn t | |  i |  i d |  i d |  i f ƒ ‚ d  S(   Nt    i    i   (   t   joint   mapt   strt   SyntaxErrorR
   R…   R†   (   R   t   msgt   args(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR   H  s    'N(   R   R   R   R   R0   R&   R"   R   RD   R   RT   Ri   Rj   RU   RS   Rs   Rx   R   RQ   R   R   (    (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR   
   s$   				.				$					
			R]   c           B   s   e  Z d  „  Z d d „ Z RS(   c         C   s   g  |  _  d  S(   N(   R   (   R   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR   S  s    c         C   sU   | d  j p t | t ƒ p t ‚ t | t ƒ p t ‚ |  i i | | f ƒ d  S(   N(   R   R9   R‹   R;   R]   R   R!   (   R   R/   R.   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRa   V  s    $N(   R   R   R   R   Ra   (    (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR]   Q  s   	R^   c           B   s2   e  Z d  „  Z d „  Z d „  Z d „  Z d Z RS(   c         C   sv   t  | t ƒ p t ‚ t  t | ƒ i ƒ  t ƒ p t ‚ t  | t ƒ p t ‚ | |  _ | | j |  _ h  |  _ d  S(   N(	   R9   t   dictR;   t   iterR/   R]   R_   R$   R   (   R   R_   t   final(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR   ]  s    #	c         C   sV   t  | t ƒ p t ‚ | |  i j p t ‚ t  | t ƒ p t ‚ | |  i | <d  S(   N(   R9   R‹   R;   R   R^   (   R   R/   R.   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRa   e  s    c         C   sB   x; |  i  i ƒ  D]* \ } } | | j o | |  i  | <q q Wd  S(   N(   R   R    (   R   t   oldt   newR.   R/   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyRn   k  s     c         C   s•   t  | t ƒ p t ‚ |  i | i j o t St |  i ƒ t | i ƒ j o t Sx; |  i i ƒ  D]* \ } } | | i i | ƒ j	 o t Sqc Wt	 S(   N(
   R9   R^   R;   R$   Rl   R   R   R    t   getRk   (   R   t   otherR.   R/   (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyt   __eq__p  s     	N(   R   R   R   Ra   Rn   R–   R   t   __hash__(    (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyR^   [  s
   				s   Grammar.txtc         C   s   t  |  ƒ } | i ƒ  S(   N(   R   R0   (   R
   t   p(    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyt   generate_grammar€  s    N(   Re   R    R   R   t   GrammarR   t   objectR   R]   R^   R™   (    (    (    s(   /usr/lib/python2.6/lib2to3/pgen2/pgen.pyt   <module>   s   ÿ H
%