
    Yh;)                     D    d dl mZ  G d de      Z G d de      ZdZdZy)	    )Templatec                   "    e Zd ZddZddZd Zy)ASTCodeGeneratorc                     || _         | j                  |      D cg c]  \  }}t        ||       c}}| _        yc c}}w )zN Initialize the code generator from a configuration
            file.
        N)cfg_filenameparse_cfgfileNodeCfgnode_cfg)selfr   namecontentss       c/var/www/django-portfolio.reubendavern.link/venv/lib/python3.12/site-packages/pycparser/_ast_gen.py__init__zASTCodeGenerator.__init__   sD     )$($6$6|$DF x !x0 F Fs   <Nc                     t        t              j                  | j                        }|t        z  }| j
                  D ]  }||j                         dz   z  } |j                  |       y)z< Generates the code into file, an open file buffer.
        )r   z

N)r   _PROLOGUE_COMMENT
substituter   _PROLOGUE_CODEr
   generate_sourcewrite)r   filesrcr
   s       r   generatezASTCodeGenerator.generate   sl     ()44** 5 , 	~ 	7H8++-66C	7 	

3    c           	   #     K   t        |d      5 }|D ]  }|j                         }|r|j                  d      r'|j                  d      }|j                  d      }|j                  d      }|dk  s
||k  s||k  rt	        d|d|d	      |d
| }||dz   | }|r-|j                  d      D 	cg c]  }	|	j                          c}	ng }
||
f  	 d
d
d
       y
c c}	w # 1 sw Y   y
xY ww)ze Parse the configuration file and yield pairs of
            (name, contents) for each node.
        r#:[]   zInvalid line in z:

N,)openstrip
startswithfindRuntimeErrorsplit)r   filenameflinecolon_i
lbracket_i
rbracket_ir   valvvallists              r   r   zASTCodeGenerator.parse_cfgfile%   s      (C  	$A $zz|ts3))C.!YYs^
!YYs^
Q;*"7:;S&hPT'UVVHW~:>*5ADciin=1779="Gm#$	$ 	$ >	$ 	$s/   C.B C"/CC"	C.C""C+'C.)z
_c_ast.cfg)N)__name__
__module____qualname__r   r   r    r   r   r   r      s    F
$r   r   c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	r	   z 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                    || _         g | _        g | _        g | _        g | _        |D ]  }|j                  d      }| j                  j                  |       |j                  d      r| j                  j                  |       \|j                  d      r| j                  j                  |       | j                  j                  |        y )N*z**)r   all_entriesattrchild	seq_childrstripappendendswith)r   r   r   entryclean_entrys        r   r   zNodeCfg.__init__B   s    		
 		(E,,s+K##K0~~d#%%k2$

!!+.		  '		(r   c                     | j                         }|d| j                         z   z  }|d| j                         z   z  }|d| j                         z   z  }|S )Nr!   )	_gen_init_gen_children	_gen_iter_gen_attr_namesr   r   s     r   r   zNodeCfg.generate_sourceT   sY    nntd((***tdnn&&&td**,,,
r   c                 6   d| j                   z  }| j                  rHdj                  | j                        }dj                  d | j                  D              }|dz  }d|z  }nd}d}|d|z  z  }|d	|z  z  }| j                  d
gz   D ]  }|d|d|dz  } |S )Nzclass %s(Node):
z, c              3   >   K   | ]  }d j                  |        yw)z'{0}'N)format).0es     r   	<genexpr>z$NodeCfg._gen_init.<locals>.<genexpr>`   s     JAgnnQ/Js   z, 'coord', '__weakref__'z(self, %s, coord=None)z'coord', '__weakref__'z(self, coord=None)z    __slots__ = (%s)
z    def __init__%s:
coordz        self.z = r!   )r   r9   join)r   r   argsslotsarglistr   s         r   rC   zNodeCfg._gen_init[   s    !DII-99T--.DIIJ9I9IJJE//E.5G,E*G'%//&00$$y0 	;DtT::C	; 
r   c                     d}| j                   rR|dz  }| j                  D ]  }|dt        |      z  z  } | j                  D ]  }|dt        |      z  z  } |dz  }|S |dz  }|S )Nz    def children(self):
z        nodelist = []
zV        if self.%(child)s is not None: 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 ()
r9   r;   dictr<   r   r   r;   r<   s       r   rD   zNodeCfg._gen_childreno   s    ),,C +H5)+ ++ "^^ /	T9-/ // 55C 
 ((C
r   c                     d}| j                   re| j                  D ]  }|dt        |      z  z  } | j                  D ]  }|dt        |      z  z  } | j                  s| j                  s|dz  }|S |dz  }|S )Nz    def __iter__(self):
zH        if self.%(child)s is not None:
            yield self.%(child)s
rT   zE        for child in (self.%(child)s or []):
            yield child
z        return
        yield
rU   rW   s       r   rE   zNodeCfg._gen_iter   s    ) P9=A=NP PP
 "^^ K	048y4IK KK
 JJ$..&' 
	 "#C 
r   c                 V    ddj                  d | j                  D              z   dz   }|S )Nz    attr_names = ( c              3   &   K   | ]	  }d |z    yw)z%r, Nr5   )rK   nms     r   rM   z*NodeCfg._gen_attr_names.<locals>.<genexpr>   s     ,MRVb[,Ms   ))rO   r:   rG   s     r   rF   zNodeCfg._gen_attr_names   s*    "RWW,M499,M%MMPSS
r   N)
r2   r3   r4   __doc__r   r   rC   rD   rE   rF   r5   r   r   r	   r	   :   s%    ($(06r   r	   a  #-----------------------------------------------------------------
# ** 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
#-----------------------------------------------------------------

a3  
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)

N)stringr   objectr   r	   r   r   r5   r   r   <module>ra      s8    '$v '$Tjf j\ (Ur   