ó
CrX[c           @   sm   d  d l  Z  d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d	 „  Z d
 „  Z d S(   iÿÿÿÿNt   Coordc           B   s)   e  Z d  Z d Z d d „ Z d „  Z RS(	   sž    Coordinates of a syntactic element. Consists of:
            - File name
            - Line number
            - (optional) column number, for the Lexer
    t   filet   linet   columnt   __weakref__c         C   s   | |  _  | |  _ | |  _ d  S(   N(   R   R   R   (   t   selfR   R   R   (    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   __init__   s    		c         C   s7   d |  j  |  j f } |  j r3 | d |  j 7} n  | S(   Ns   %s:%ss   :%s(   R   R   R   (   R   t   str(    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   __str__   s    	 (   R   R   R   R   N(   t   __name__t
   __module__t   __doc__t	   __slots__t   NoneR   R   (    (    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyR       s   t
   ParseErrorc           B   s   e  Z RS(    (   R	   R
   (    (    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyR      s    t	   PLYParserc           B   s/   e  Z d  „  Z d d „ Z d „  Z d „  Z RS(   c         C   sM   | d } d „  } d | | f | _  d | | _ t |  j | j | ƒ d S(   sŽ    Given a rule name, creates an optional ply.yacc rule
            for it. The name of the optional rule is
            <rulename>_opt
        t   _optc         S   s   | d | d <d  S(   Ni   i    (    (   R   t   p(    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   optrule*   s    s   %s : empty
| %ss   p_%sN(   R   R	   t   setattrt	   __class__(   R   t   rulenamet   optnameR   (    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   _create_opt_rule#   s
    
	c         C   s   t  d |  j j d | d | ƒ S(   NR   R   R   (   R    t   clext   filename(   R   t   linenoR   (    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   _coord1   s    c         C   sh   | j  j  j j d d | j | ƒ ƒ } | d k  r< d } n  | j | ƒ | } |  j | j | ƒ | ƒ S(   sÖ    Returns the coordinates for the YaccProduction objet 'p' indexed
            with 'token_idx'. The coordinate includes the 'lineno' and
            'column'. Both follow the lex semantic, starting from 1.
        s   
i    iÿÿÿÿ(   t   lexert   lexdatat   rfindt   lexposR   R   (   R   R   t	   token_idxt   last_crR   (    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   _token_coord7   s
    '	c         C   s   t  d | | f ƒ ‚ d  S(   Ns   %s: %s(   R   (   R   t   msgt   coord(    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   _parse_errorB   s    N(   R	   R
   R   R   R   R"   R%   (    (    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyR   "   s   		c             s   ‡  f d †  } | S(   sÞ   Decorator to create parameterized rules.

    Parameterized rule methods must be named starting with 'p_' and contain
    'xxx', and their docstrings may contain 'xxx' and 'yyy'. These will be
    replaced by the given parameter tuples. For example, ``p_xxx_rule()`` with
    docstring 'xxx_rule  : yyy' when decorated with
    ``@parameterized(('id', 'ID'))`` produces ``p_id_rule()`` with the docstring
    'id_rule  : ID'. Using multiple tuples produces multiple rules.
    c            s   ˆ  |  _  |  S(   N(   t   _params(   t	   rule_func(   t   params(    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   decorateP   s    	(    (   R(   R)   (    (   R(   s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   parameterizedF   s    
c         C   s¥   t  } x˜ t |  ƒ D]Š } | j d ƒ r t |  | ƒ } t | d ƒ r t |  | ƒ | j d k	 rr t |  | ƒ qš | sš t	 j
 d t d d ƒt } qš q q q W|  S(   s    Class decorator to generate rules from parameterized rule templates.

    See `parameterized` for more information on parameterized rules.
    t   p_R&   s@   parsing methods must have __doc__ for pycparser to work properlyt
   stackleveli   N(   t   Falset   dirt
   startswitht   getattrt   hasattrt   delattrR   R   t   _create_param_rulest   warningst   warnt   RuntimeWarningt   True(   t   clst   issued_nodoc_warningt	   attr_namet   method(    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   templateV   s    c            s|   xu ˆ  j  D]j \ } } ‡  f d †  } ˆ  j j d | ƒ j d | ƒ | _ ˆ  j j d | ƒ | _ t |  | j | ƒ q
 Wd S(   s   Create ply.yacc rules based on a parameterized rule function

    Generates new methods (one per each pair of parameters) based on the
    template rule function `func`, and attaches them to `cls`. The rule
    function's parameters must be accessible via its `_params` attribute.
    c            s   ˆ  |  | ƒ d  S(   N(    (   R   R   (   t   func(    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt
   param_rule}   s    t   xxxt   yyyN(   R&   R   t   replaceR	   R   (   R8   R=   R?   R@   R>   (    (   R=   s2   lib/python2.7/site-packages/pycparser/plyparser.pyR3   t   s
    $(	   R4   t   objectR    t	   ExceptionR   R   R*   R<   R3   (    (    (    s2   lib/python2.7/site-packages/pycparser/plyparser.pyt   <module>   s   $		