ó
CrX[c           @   sX   d  d l  Z  d  d l m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d Z d Z d S(	   iÿÿÿÿN(   t   Templatet   ASTCodeGeneratorc           B   s)   e  Z d  d „ Z d d „ Z d „  Z RS(   s
   _c_ast.cfgc         C   sA   | |  _  g  |  j | ƒ D] \ } } t | | ƒ ^ q |  _ d S(   sN    Initialize the code generator from a configuration
            file.
        N(   t   cfg_filenamet   parse_cfgfilet   NodeCfgt   node_cfg(   t   selfR   t   namet   contents(    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyt   __init__   s    	c         C   s^   t  t ƒ j d |  j ƒ } | t 7} x% |  j D] } | | j ƒ  d 7} q/ W| j | ƒ d S(   s<    Generates the code into file, an open file buffer.
        R   s   

N(   R    t   _PROLOGUE_COMMENTt
   substituteR   t   _PROLOGUE_CODER   t   generate_sourcet   write(   R   t   filet   srcR   (    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyt   generate   s    
c      	   c   s  t  | d ƒ } xú | D]ò } | j ƒ  } | s | j d ƒ rG q n  | j d ƒ } | j d ƒ } | j d ƒ } | d k  s˜ | | k s˜ | | k r± t d | | f ƒ ‚ n  | |  } | | d | !} | rú g  | j d ƒ D] }	 |	 j ƒ  ^ qâ n g  }
 | |
 f Vq WWd	 QXd	 S(
   se    Parse the configuration file and yield pairs of
            (name, contents) for each node.
        t   rt   #t   :t   [t   ]i   s   Invalid line in %s:
%s
t   ,N(   t   opent   stript
   startswitht   findt   RuntimeErrort   split(   R   t   filenamet   ft   linet   colon_it
   lbracket_it
   rbracket_iR   t   valt   vt   vallist(    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyR   &   s    $
4N(   t   __name__t
   __module__R	   t   NoneR   R   (    (    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyR      s   R   c           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sº    Node configuration.

        name: node name
        contents: a list of contents - attributes and child nodes
        See comment at the top of the configuration file for details.
    c         C   sµ   | |  _  g  |  _ g  |  _ g  |  _ g  |  _ x | D]y } | j d ƒ } |  j j | ƒ | j d ƒ r{ |  j j | ƒ q4 | j d ƒ r |  j j | ƒ q4 |  j j | ƒ q4 Wd  S(   Nt   *s   **(   R   t   all_entriest   attrt   childt	   seq_childt   rstript   appendt   endswith(   R   R   R   t   entryt   clean_entry(    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyR	   C   s    					c         C   sL   |  j  ƒ  } | d |  j ƒ  7} | d |  j ƒ  7} | d |  j ƒ  7} | S(   Ns   
(   t	   _gen_initt   _gen_childrent	   _gen_itert   _gen_attr_names(   R   R   (    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyR   U   s
    c         C   s¶   d |  j  } |  j r[ d j |  j ƒ } d j d „  |  j Dƒ ƒ } | d 7} d | } n d } d } | d | 7} | d	 | 7} x, |  j d
 g D] } | d | | f 7} q” W| S(   Ns   class %s(Node):
s   , c         s   s   |  ] } d  j  | ƒ Vq d S(   s   '{0}'N(   t   format(   t   .0t   e(    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pys	   <genexpr>b   s    s   , 'coord', '__weakref__'s   (self, %s, coord=None)s   'coord', '__weakref__'s   (self, coord=None)s       __slots__ = (%s)
s       def __init__%s:
t   coords           self.%s = %s
(   R   R+   t   join(   R   R   t   argst   slotst   arglistR   (    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyR4   ]   s    	
c         C   sŽ   d } |  j  r€ | d 7} x, |  j D]! } | d d t d | ƒ 7} q# Wx( |  j D] } | d t d | ƒ 7} qR W| d 7} n
 | d 7} | S(	   Ns       def children(self):
s           nodelist = []
s&           if self.%(child)s is not None:s0    nodelist.append(("%(child)s", self.%(child)s))
R-   su           for i, child in enumerate(self.%(child)s or []):
            nodelist.append(("%(child)s[%%d]" %% i, child))
s           return tuple(nodelist)
s           return ()
(   R+   R-   t   dictR.   (   R   R   R-   R.   (    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyR5   q   s    	

c         C   s¡   d } |  j  r x, |  j D]! } | d d t d | ƒ 7} q Wx( |  j D] } | d t d | ƒ 7} qH W|  j px |  j s | d d 7} q n | d d 7} | S(   Ns       def __iter__(self):
s'           if self.%(child)s is not None:
s!               yield self.%(child)s
R-   sE           for child in (self.%(child)s or []):
            yield child
s           return
s           yield
(   R+   R-   R@   R.   (   R   R   R-   R.   (    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyR6   ‰   s$    	c         C   s(   d d j  d „  |  j Dƒ ƒ d } | S(   Ns       attr_names = (t    c         s   s   |  ] } d  | Vq d S(   s   %r, N(    (   R9   t   nm(    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pys	   <genexpr>¥   s    t   )(   R<   R,   (   R   R   (    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyR7   ¤   s    $(	   R'   R(   t   __doc__R	   R   R4   R5   R6   R7   (    (    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyR   ;   s   					s¾  #-----------------------------------------------------------------
# ** ATTENTION **
# This code was automatically generated from the file:
# $cfg_filename
#
# Do not modify it directly. Modify the configuration file and
# run the generator again.
# ** ** *** ** **
#
# pycparser: c_ast.py
#
# AST Node classes.
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------

sX  
import sys

def _repr(obj):
    """
    Get the representation of an object, with dedicated pprint-like format for lists.
    """
    if isinstance(obj, list):
        return '[' + (',\n '.join((_repr(e).replace('\n', '\n ') for e in obj))) + '\n]'
    else:
        return repr(obj) 

class Node(object):
    __slots__ = ()
    """ Abstract base class for AST nodes.
    """
    def __repr__(self):
        """ Generates a python representation of the current node
        """
        result = self.__class__.__name__ + '('
        
        indent = ''
        separator = ''
        for name in self.__slots__[:-2]:
            result += separator
            result += indent
            result += name + '=' + (_repr(getattr(self, name)).replace('\n', '\n  ' + (' ' * (len(name) + len(self.__class__.__name__)))))
            
            separator = ','
            indent = '\n ' + (' ' * len(self.__class__.__name__))
        
        result += indent + ')'
        
        return result

    def children(self):
        """ A sequence of all children that are Nodes
        """
        pass

    def show(self, buf=sys.stdout, offset=0, attrnames=False, nodenames=False, showcoord=False, _my_node_name=None):
        """ Pretty print the Node and all its attributes and
            children (recursively) to a buffer.

            buf:
                Open IO buffer into which the Node is printed.

            offset:
                Initial offset (amount of leading spaces)

            attrnames:
                True if you want to see the attribute names in
                name=value pairs. False to only see the values.

            nodenames:
                True if you want to see the actual node names
                within their parents.

            showcoord:
                Do you want the coordinates of each Node to be
                displayed.
        """
        lead = ' ' * offset
        if nodenames and _my_node_name is not None:
            buf.write(lead + self.__class__.__name__+ ' <' + _my_node_name + '>: ')
        else:
            buf.write(lead + self.__class__.__name__+ ': ')

        if self.attr_names:
            if attrnames:
                nvlist = [(n, getattr(self,n)) for n in self.attr_names]
                attrstr = ', '.join('%s=%s' % nv for nv in nvlist)
            else:
                vlist = [getattr(self, n) for n in self.attr_names]
                attrstr = ', '.join('%s' % v for v in vlist)
            buf.write(attrstr)

        if showcoord:
            buf.write(' (at %s)' % self.coord)
        buf.write('\n')

        for (child_name, child) in self.children():
            child.show(
                buf,
                offset=offset + 2,
                attrnames=attrnames,
                nodenames=nodenames,
                showcoord=showcoord,
                _my_node_name=child_name)


class NodeVisitor(object):
    """ A base NodeVisitor class for visiting c_ast nodes.
        Subclass it and define your own visit_XXX methods, where
        XXX is the class name you want to visit with these
        methods.

        For example:

        class ConstantVisitor(NodeVisitor):
            def __init__(self):
                self.values = []

            def visit_Constant(self, node):
                self.values.append(node.value)

        Creates a list of values of all the constant nodes
        encountered below the given node. To use it:

        cv = ConstantVisitor()
        cv.visit(node)

        Notes:

        *   generic_visit() will be called for AST nodes for which
            no visit_XXX method was defined.
        *   The children of nodes for which a visit_XXX was
            defined will not be visited - if you need this, call
            generic_visit() on the node.
            You can use:
                NodeVisitor.generic_visit(self, node)
        *   Modeled after Python's own AST visiting facilities
            (the ast module of Python 3.0)
    """

    _method_cache = None

    def visit(self, node):
        """ Visit a node.
        """

        if self._method_cache is None:
            self._method_cache = {}

        visitor = self._method_cache.get(node.__class__.__name__, None)
        if visitor is None:
            method = 'visit_' + node.__class__.__name__
            visitor = getattr(self, method, self.generic_visit)
            self._method_cache[node.__class__.__name__] = visitor

        return visitor(node)

    def generic_visit(self, node):
        """ Called if no explicit visitor function exists for a
            node. Implements preorder visiting of the node.
        """
        for c in node:
            self.visit(c)

(   t   pprintt   stringR    t   objectR   R   R
   R   (    (    (    s1   lib/python2.7/site-packages/pycparser/_ast_gen.pyt   <module>   s
   *€—