Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
pycparser / __pycache__ / _ast_gen.cpython-35.pyc
Size: Mime:


ö”Xã!ã@s’ddlZddlmZGdd„deƒZGdd„deƒZdZdZed	krŽddl	Z	ed
ƒZ
e
jeddƒƒdS)
éN)ÚTemplatec@s:eZdZddd„Zddd„Zdd„ZdS)	ÚASTCodeGeneratorz
_c_ast.cfgcCs,||_dd„|j|ƒDƒ|_dS)zN Initialize the code generator from a configuration
            file.
        cSs%g|]\}}t||ƒ‘qS©)ÚNodeCfg)Ú.0ÚnameÚcontentsrrúX/tmp/pip-install-0kh_z7y_/pycparser/build/bdist.linux-x86_64/wheel/pycparser/_ast_gen.pyú
<listcomp>s	z-ASTCodeGenerator.__init__.<locals>.<listcomp>N)Úcfg_filenameÚ
parse_cfgfileÚnode_cfg)Úselfrrrr	Ú__init__s		zASTCodeGenerator.__init__NcCs^ttƒjd|jƒ}|t7}x%|jD]}||jƒd7}q/W|j|ƒdS)z< Generates the code into file, an open file buffer.
        rz

N)rÚ_PROLOGUE_COMMENTZ
substituterÚ_PROLOGUE_CODEr
Úgenerate_sourceÚwrite)rÚfileÚsrcr
rrr	Úgenerates
zASTCodeGenerator.generatec
cst|dƒû}xñ|D]é}|jƒ}|s|jdƒrDq|jdƒ}|jdƒ}|jdƒ}|dks•||ks•||kr«td||fƒ‚|d|…}||d|…}|rñd	d
„|jdƒDƒng}	||	fVqWWdQRXdS)ze Parse the configuration file and yield pairs of
            (name, contents) for each node.
        Úrú#ú:ú[ú]ézInvalid line in %s:
%s
NcSsg|]}|jƒ‘qSr)Ústrip)rÚvrrr	r
7s	z2ASTCodeGenerator.parse_cfgfile.<locals>.<listcomp>ú,)ÚopenrÚ
startswithÚfindÚRuntimeErrorÚsplit)
rÚfilenameÚfÚlineZcolon_iZ
lbracket_iZ
rbracket_irÚvalZvallistrrr	r&s
$(zASTCodeGenerator.parse_cfgfile)Ú__name__Ú
__module__Ú__qualname__rrrrrrr	rsrc@sReZdZdZdd„Zdd„Zdd„Zdd	„Zd
d„ZdS)
rzº 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.
    cCsµ||_g|_g|_g|_g|_x|D]y}|jdƒ}|jj|ƒ|jdƒr{|jj|ƒq4|jdƒr|jj|ƒq4|jj|ƒq4WdS)NÚ*z**)rÚall_entriesÚattrÚchildÚ	seq_childÚrstripÚappendÚendswith)rrrÚentryZclean_entryrrr	rBs					
zNodeCfg.__init__cCs8|jƒ}|d|jƒ7}|d|jƒ7}|S)NÚ
)Ú	_gen_initÚ
_gen_childrenÚ_gen_attr_names)rrrrr	rTszNodeCfg.generate_sourcecCs¹d|j}|jr^dj|jƒ}djdd„|jDƒƒ}|d7}d|}nd}d}|d	|7}|d
|7}x,|jdgD]}|d||f7}q—W|S)
Nzclass %s(Node):
z, css|]}dj|ƒVqdS)z'{0}'N)Úformat)rÚerrr	ú	<genexpr>_sz$NodeCfg._gen_init.<locals>.<genexpr>z, 'coord', '__weakref__'z(self, %s, coord=None)z'coord', '__weakref__'z(self, coord=None)z    __slots__ = (%s)
z    def __init__%s:
Zcoordz        self.%s = %s
)rr-Újoin)rrÚargsZslotsZarglistrrrr	r6Zs
	

zNodeCfg._gen_initcCsŽd}|jr€|d7}x,|jD]!}|ddtd|ƒ7}q#Wx(|jD]}|dtd|ƒ7}qRW|d7}n
|d7}|S)	Nz    def children(self):
z        nodelist = []
z&        if self.%(child)s is not None:z0 nodelist.append(("%(child)s", self.%(child)s))
r/zu        for i, child in enumerate(self.%(child)s or []):
            nodelist.append(("%(child)s[%%d]" %% i, child))
z        return tuple(nodelist)
z        return ()
)r-r/Údictr0)rrr/r0rrr	r7ns	


zNodeCfg._gen_childrencCs+ddjdd„|jDƒƒd}|S)Nz    attr_names = (Úcss|]}d|VqdS)z%r, Nr)rZnmrrr	r;‡sz*NodeCfg._gen_attr_names.<locals>.<genexpr>ú))r<r.)rrrrr	r8†s'zNodeCfg._gen_attr_namesN)	r)r*r+Ú__doc__rrr6r7r8rrrr	r;sra¼#-----------------------------------------------------------------
# ** 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 [http://eli.thegreenplace.net]
# License: BSD
#-----------------------------------------------------------------

a×

import sys


class Node(object):
    __slots__ = ()
    """ Abstract base class for AST nodes.
    """
    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)
    """
    def visit(self, node):
        """ Visit a node.
        """
        method = 'visit_' + node.__class__.__name__
        visitor = getattr(self, method, self.generic_visit)
        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_name, c in node.children():
            self.visit(c)


Z__main__z
_c_ast.cfgzc_ast.pyÚw)
ÚpprintZstringrÚobjectrrrrr)ÚsysÚast_genrr rrrr	Ú<module>
s*br