HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/pycparser/__pycache__/_ast_gen.cpython-310.pyc
o

;j,�@s�ddlmZddlZddlmZGdd�d�ZGdd�d�ZdZd	Ze	d
kr_ej
�ej
�e
��Zej
�ed�Zej
�ed�Zee�Zeed
��Ze�e�Wd�dS1sXwYdSdS)�)�TemplateN)�IOc@s4eZdZddd�Zdeeddfdd�Zd	d
�ZdS)�ASTCodeGenerator�
_c_ast.cfgcCs ||_dd�|�|�D�|_dS)zIInitialize the code generator from a configuration
        file.
        cSsg|]	\}}t||��qS�)�NodeCfg)�.0�name�contentsrr�F/opt/saltstack/salt/lib/python3.10/site-packages/pycparser/_ast_gen.py�
<listcomp>s��z-ASTCodeGenerator.__init__.<locals>.<listcomp>N)�cfg_filename�
parse_cfgfile�node_cfg)�selfr
rrr�__init__s�zASTCodeGenerator.__init__�file�returnNcCsDtt�j|jd�}|t7}|jD]
}||��d7}q|�|�dS)z2Generates the code into file, an open file buffer.)r
z

N)r�_PROLOGUE_COMMENT�
substituter
�_PROLOGUE_CODEr�generate_source�write)rr�srcrrrr�generate s

zASTCodeGenerator.generatec
cs��t|d��a}|D]U}|��}|r|�d�rq	|�d�}|�d�}|�d�}|dks2||ks2||kr=td|�d|�d	���|d
|�}||d|�}|rWdd�|�d
�D�ng}	||	fVq	Wd
�d
S1sjwYd
S)z`Parse the configuration file and yield pairs of
        (name, contents) for each node.
        �r�#�:�[�]�zInvalid line in �:
�
NcSsg|]}|���qSr)�strip)r�vrrrr;sz2ASTCodeGenerator.parse_cfgfile.<locals>.<listcomp>�,)�openr#�
startswith�find�RuntimeError�split)
r�filename�f�lineZcolon_iZ
lbracket_iZ
rbracket_ir	�valZvallistrrrr*s"�


�"�zASTCodeGenerator.parse_cfgfile)r)�__name__�
__module__�__qualname__rr�strrrrrrrrs


rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)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|_|D]+}|�d�}|j�|�|�d�r*|j�|�q|�d�r6|j�|�q|j�|�qdS)N�*z**)r	�all_entries�attr�child�	seq_child�rstrip�append�endswith)rr	r
�entryZclean_entryrrrrGs


�zNodeCfg.__init__cCs<|��}|d|��7}|d|��7}|d|��7}|S)Nr")�	_gen_init�
_gen_children�	_gen_iter�_gen_attr_names�rrrrrrYs
zNodeCfg.generate_sourcecCs�d|j�d�}|jr&d�|j�}d�dd�|jD��}|d7}d|�d�}nd	}d
}|d|�d�7}|d
|�d�7}|jdgD]
}|d|�d|�d�7}q@|S)Nzclass z(Node):
�, css�|]	}d|�d�VqdS)�'Nr)r�errr�	<genexpr>es�z$NodeCfg._gen_init.<locals>.<genexpr>z, 'coord', '__weakref__'z(self, z
, coord=None)z'coord', '__weakref__'z(self, coord=None)z    __slots__ = (z)
z    def __init__r!Zcoordz
        self.z = r")r	r4�join)rr�args�slotsZarglistr	rrrr<`szNodeCfg._gen_initcCs�d}|jr>|d7}|jD]}|d|�d�7}|d|�d|�d�7}q|jD]}|d|�d	�7}|d
|�d�7}q%|d7}|S|d
7}|S)Nz    def children(self):
z        nodelist = []
�        if self.� is not None:
z            nodelist.append(("z", self.z))
z'        for i, child in enumerate(self.�	 or []):
z            nodelist.append((f"z[{i}]", child))
z        return tuple(nodelist)
z        return ()
�r4r6r7�rrr6r7rrrr=ts

�zNodeCfg._gen_childrencCs~d}|jr9|jD]}|d|�d�7}|d|�d�7}q|jD]}|d|�d�7}|d7}q|js7|js7|d	7}|S|d	7}|S)
Nz    def __iter__(self):
rHrIz            yield self.r"z        for child in (self.rJz            yield child
z        return
        yield
rKrLrrrr>�s


�zNodeCfg._gen_itercCs"dd�dd�|jD��d}|S)Nz    attr_names = (�css�|]}|�d�VqdS)rANr)rZnmrrrrD�s�z*NodeCfg._gen_attr_names.<locals>.<genexpr>�))rEr5r@rrrr?�szNodeCfg._gen_attr_namesN)
r/r0r1�__doc__rrr<r=r>r?rrrrr?sra�#-----------------------------------------------------------------
# ** ATTENTION **
# This code was automatically generated from _c_ast.cfg
#
# 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
#-----------------------------------------------------------------

ae
import sys
from typing import Any, ClassVar, IO, Optional

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:
    __slots__ = ()
    """ Abstract base class for AST nodes.
    """
    attr_names: ClassVar[tuple[str, ...]] = ()
    coord: Optional[Any]
    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: IO[str] = sys.stdout,
        offset: int = 0,
        attrnames: bool = False,
        showemptyattrs: bool = True,
        nodenames: bool = False,
        showcoord: bool = False,
        _my_node_name: Optional[str] = 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.

            showemptyattrs:
                False if you want to suppress printing empty attributes.

            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:
            def is_empty(v):
                v is None or (hasattr(v, '__len__') and len(v) == 0)
            nvlist = [(n, getattr(self,n)) for n in self.attr_names \
                        if showemptyattrs or not is_empty(getattr(self,n))]
            if attrnames:
                attrstr = ', '.join(f'{name}={value}' for name, value in nvlist)
            else:
                attrstr = ', '.join(f'{value}' for _, value in nvlist)
            buf.write(attrstr)

        if showcoord:
            buf.write(f' (at {self.coord})')
        buf.write('\n')

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


class NodeVisitor:
    """ 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: 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: Node):
        """ Called if no explicit visitor function exists for a
            node. Implements preorder visiting of the node.
        """
        for _, c in node.children():
            self.visit(c)

�__main__rzc_ast.py�w)�stringr�os�typingrrrrrr/�path�dirname�abspath�__file__�base_dirrEZcfg_pathZout_pathZast_genr&�outrrrrr�<module>s"*c+"��