o
    6d13                     @   sx  d dl mZ d dlZG dd deZG dd deZG dd deZG d	d
 d
eZG dd deZG dd deZ	G dd deZ
G dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd  d eZG d!d" d"eZG d#d$ d$eZG d%d& d&eZG d'd( d(eZG d)d* d*eZG d+d, d,eZG d-d. d.eZdS )/    )OrderedDictNc                   @   s   e Zd Zdd ZdS )ASTNodec                 C   s   || _ || _|| _dS )z
        Args:
            lineno (int): The line number where the start of this element
                occurs.
            lexpos (int): The character offset into the file where this element
                occurs.
        N)pathlinenolexpos)selfr   r   r    r   iC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\site-packages\stone/frontend/ast.py__init__   s   
zASTNode.__init__N)__name__
__module____qualname__r
   r   r   r   r	   r      s    r   c                       ,   e Zd Z fddZdd Zdd Z  ZS )AstNamespacec                    $   t t| ||| || _|| _dS )z
        Args:
            name (str): The namespace of the spec.
            doc (Optional[str]): The docstring for this namespace.
        N)superr   r
   namedoc)r   r   r   r   r   r   	__class__r   r	   r
      s   
zAstNamespace.__init__c                 C      |   S N__repr__r   r   r   r	   __str__       zAstNamespace.__str__c                 C      d | jS )NzAstNamespace({!r}))formatr   r   r   r   r	   r   #      zAstNamespace.__repr__r   r   r   r
   r   r   __classcell__r   r   r   r	   r      s    
r   c                       r   )	AstImportc                       t t| ||| || _dS )zV
        Args:
            target (str): The name of the namespace to import.
        N)r   r"   r
   target)r   r   r   r   r$   r   r   r	   r
   )      
zAstImport.__init__c                 C   r   r   r   r   r   r   r	   r   1   r   zAstImport.__str__c                 C   r   )NzAstImport({!r}))r   r$   r   r   r   r	   r   4   r   zAstImport.__repr__r    r   r   r   r	   r"   '   s    r"   c                       r   )AstAliasc                    s0   t t| ||| || _|| _|| _g | _dS )z
        Args:
            name (str): The name of the alias.
            type_ref (AstTypeRef): The data type of the field.
            doc (Optional[str]): Documentation string for the alias.
        N)r   r&   r
   r   type_refr   annotations)r   r   r   r   r   r'   r   r   r   r	   r
   9   s
   
zAstAlias.__init__c                 C   
   || _ d S r   r(   r   r(   r   r   r	   set_annotationsF      
zAstAlias.set_annotationsc                 C      d | j| jS )NzAstAlias({!r}, {!r})r   r   r'   r   r   r   r	   r   I   s   zAstAlias.__repr__)r   r   r   r
   r,   r   r!   r   r   r   r	   r&   7   s    r&   c                       r   )
AstTypeDefc	           	         s   t t| ||| || _t|ttdfsJ t||| _t|tj	tdfs+J || _
t|ts5J || _t|ttdfsGJ t||| _dS )a  
        Args:
            name (str): Name assigned to the type.
            extends (Optional[str]); Name of the type this inherits from.
            doc (Optional[str]): Docstring for the type.
            fields (List[AstField]): Fields of a type, not including
                inherited ones.
            examples (Optional[OrderedDict[str, AstExample]]): Map from label
                to example.
        N)r   r0   r
   r   
isinstance
AstTypeReftypeextendssix	text_typer   listfieldsr   examples)	r   r   r   r   r   r4   r   r8   r9   r   r   r	   r
   N   s   
zAstTypeDef.__init__c                 C   r   r   r   r   r   r   r	   r   f   r   zAstTypeDef.__str__c                 C      d | j| j| jS )NzAstTypeDef({!r}, {!r}, {!r})r   r   r4   r8   r   r   r   r	   r   i   
   zAstTypeDef.__repr__r    r   r   r   r	   r0   L   s    r0   c                       (   e Zd Z	d fdd	Zdd Z  ZS )AstStructDefNc
           
   
      sF   t t| |||||||| t|	ttdfsJ t|	|	| _dS )z
        Args:
            subtypes (Tuple[List[AstSubtypeField], bool]): Inner list
                enumerates subtypes. The bool indicates whether this struct
                is a catch-all.

        See AstTypeDef for other constructor args.
        N)r   r>   r
   r1   tupler3   subtypes)
r   r   r   r   r   r4   r   r8   r9   r@   r   r   r	   r
   r   s
   

zAstStructDef.__init__c                 C   r:   )NzAstStructDef({!r}, {!r}, {!r})r;   r   r   r   r	   r      r<   zAstStructDef.__repr__r   r   r   r   r
   r   r!   r   r   r   r	   r>   p   s    r>   c                       $   e Zd Z fddZdd Z  ZS )AstStructPatchc                    sV   t t| ||| || _t|tsJ || _t|ttd fs&J t||| _	d S r   )
r   rC   r
   r   r1   r7   r8   r   r3   r9   )r   r   r   r   r   r8   r9   r   r   r	   r
      s   
zAstStructPatch.__init__c                 C   r.   )NzAstStructPatch({!r}, {!r}))r   r   r8   r   r   r   r	   r         zAstStructPatch.__repr__rA   r   r   r   r	   rC          	rC   c                       r=   )AstUnionDefFc
           
   
      s(   t t| |||||||| |	| _dS )z
        Args:
            closed (bool): Set if this is a closed union.

        See AstTypeDef for other constructor args.
        N)r   rF   r
   closed)
r   r   r   r   r   r4   r   r8   r9   rG   r   r   r	   r
      s   

zAstUnionDef.__init__c                 C      d | j| j| j| jS )Nz#AstUnionDef({!r}, {!r}, {!r}, {!r}))r   r   r4   r8   rG   r   r   r   r	   r         zAstUnionDef.__repr__)FrA   r   r   r   r	   rF      s    rF   c                       rB   )AstUnionPatchc                    s\   t t| ||| || _t|tsJ || _t|ttd fs&J t||| _	|| _
d S r   )r   rJ   r
   r   r1   r7   r8   r   r3   r9   rG   )r   r   r   r   r   r8   r9   rG   r   r   r	   r
      s   
zAstUnionPatch.__init__c                 C   r:   )NzAstUnionPatch({!r}, {!r}, {!r}))r   r   r8   rG   r   r   r   r	   r      r<   zAstUnionPatch.__repr__rA   r   r   r   r	   rJ      s    
rJ   c                       rB   )r2   c                    s0   t t| ||| || _|| _|| _|| _dS )aY  
        Args:
            name (str): Name of the referenced type.
            args (tuple[list, dict]): Arguments to type.
            nullable (bool): Whether the type is nullable (can be null)
            ns (Optional[str]): Namespace that referred type is a member of.
                If none, then refers to the current namespace.
        N)r   r2   r
   r   argsnullablens)r   r   r   r   r   rK   rL   rM   r   r   r	   r
      s
   	
zAstTypeRef.__init__c                 C   rH   )Nz"AstTypeRef({!r}, {!r}, {!r}, {!r}))r   r   rK   rL   rM   r   r   r   r	   r      rI   zAstTypeRef.__repr__rA   r   r   r   r	   r2      s    r2   c                       rB   )	AstTagRefc                    r#   )zK
        Args:
            tag (str): Name of the referenced type.
        N)r   rN   r
   tag)r   r   r   r   rO   r   r   r	   r
      r%   zAstTagRef.__init__c                 C   r   )NzAstTagRef({!r}))r   rO   r   r   r   r	   r      s   zAstTagRef.__repr__rA   r   r   r   r	   rN      s    rN   c                       rB   )AstAnnotationRefc                    r   )zX
        Args:
            annotation (str): Name of the referenced annotation.
        N)r   rP   r
   
annotationrM   )r   r   r   r   rQ   rM   r   r   r	   r
      s   
zAstAnnotationRef.__init__c                 C   r.   )NzAstAnnotationRef({!r}, {!r}))r   rQ   rM   r   r   r   r	   r      s   zAstAnnotationRef.__repr__rA   r   r   r   r	   rP      rE   rP   c                       rB   )AstAnnotationDefc	           	         s6   t t| ||| || _|| _|| _|| _|| _dS )a  
        Args:
            name (str): Name of the defined annotation.
            annotation_type (str): Type of annotation to define.
            annotation_type_ns (Optional[str]): Namespace where the annotation
              type was defined. If None, current namespace or builtin.
            args (str): Arguments to define annotation.
            kwargs (str): Keyword Arguments to define annotation.
        N)r   rR   r
   r   annotation_typeannotation_type_nsrK   kwargs)	r   r   r   r   r   rS   rT   rK   rU   r   r   r	   r
      s   
zAstAnnotationDef.__init__c                 C   s   d | j| j| j| j| jS )Nz.AstAnnotationDef({!r}, {!r}, {!r}, {!r}, {!r}))r   r   rS   rT   rK   rU   r   r   r   r	   r     s   zAstAnnotationDef.__repr__rA   r   r   r   r	   rR      s    rR   c                       rB   )AstAnnotationTypeDefc                    s*   t t| ||| || _|| _|| _dS )a  
        Args:
            name (str): Name of the defined annotation type.
            doc (str): Docstring for the defined annotation type.
            params (List[AstField]): Parameters that can be passed to the
                annotation type.
        N)r   rV   r
   r   r   params)r   r   r   r   r   r   rW   r   r   r	   r
     s   
zAstAnnotationTypeDef.__init__c                 C   r:   )Nz&AstAnnotationTypeDef({!r}, {!r}, {!r}))r   r   r   rW   r   r   r   r	   r   '  r<   zAstAnnotationTypeDef.__repr__rA   r   r   r   r	   rV     s    rV   c                       s@   e Zd ZdZ fddZdd Zdd Zdd	 Zd
d Z  Z	S )AstFieldz
    Represents both a field of a struct and a field of a union.
    TODO(kelkabany): Split this into two different classes.
    c                    s<   t t| ||| || _|| _d| _d| _d| _g | _dS )z
        Args:
            name (str): The name of the field.
            type_ref (AstTypeRef): The data type of the field.
        NF)	r   rX   r
   r   r'   r   has_defaultdefaultr(   r   r   r   r   r   r'   r   r   r	   r
   4  s   
zAstField.__init__c                 C   r)   r   r   r   	docstringr   r   r	   set_docB  r-   zAstField.set_docc                 C   s   d| _ || _d S )NT)rY   rZ   )r   rZ   r   r   r	   set_defaultE  s   
zAstField.set_defaultc                 C   r)   r   r*   r+   r   r   r	   r,   I  r-   zAstField.set_annotationsc                 C   r:   )NzAstField({!r}, {!r}, {!r}))r   r   r'   r(   r   r   r   r	   r   L  r<   zAstField.__repr__)
r   r   r   __doc__r
   r_   r`   r,   r   r!   r   r   r   r	   rX   .  s    rX   c                       s<   e Zd Z fddZdd Zdd Zdd Zd	d
 Z  ZS )AstVoidFieldc                    s*   t t| ||| || _d | _g | _d S r   )r   rb   r
   r   r   r(   )r   r   r   r   r   r   r   r	   r
   U     
zAstVoidField.__init__c                 C   r)   r   r\   r]   r   r   r	   r_   [  r-   zAstVoidField.set_docc                 C   r)   r   r*   r+   r   r   r	   r,   ^  r-   zAstVoidField.set_annotationsc                 C   r   r   r   r   r   r   r	   r   a  r   zAstVoidField.__str__c                 C   r.   )NzAstVoidField({!r}, {!r}))r   r   r(   r   r   r   r	   r   d  rD   zAstVoidField.__repr__)	r   r   r   r
   r_   r,   r   r   r!   r   r   r   r	   rb   S  s    rb   c                       rB   )AstSubtypeFieldc                    $   t t| ||| || _|| _d S r   )r   rd   r
   r   r'   r[   r   r   r	   r
   l     
zAstSubtypeField.__init__c                 C   r.   )NzAstSubtypeField({!r}, {!r})r/   r   r   r   r	   r   q  rD   zAstSubtypeField.__repr__rA   r   r   r   r	   rd   j      rd   c                       s0   e Zd Z	d fdd	Zdd Zdd Z  ZS )	AstRouteDefNc
           
         sH   t t| ||| || _|| _|| _|| _|| _|	| _d | _	i | _
d S r   )r   rh   r
   r   version
deprecatedarg_type_refresult_type_referror_type_refr   attrs)
r   r   r   r   r   ri   rj   rk   rl   rm   r   r   r	   r
   y  s   
zAstRouteDef.__init__c                 C   r)   r   r\   r]   r   r   r	   r_     r-   zAstRouteDef.set_docc                 C   r)   r   )rn   )r   rn   r   r   r	   	set_attrs  r-   zAstRouteDef.set_attrsr   )r   r   r   r
   r_   ro   r!   r   r   r   r	   rh   w  s
    rh   c                       rB   )AstAttrFieldc                    re   r   )r   rp   r
   r   valuer   r   r   r   r   rq   r   r   r	   r
     rf   zAstAttrField.__init__c                 C   r.   )NzAstAttrField({!r}, {!r})r   r   rq   r   r   r   r	   r     rD   zAstAttrField.__repr__rA   r   r   r   r	   rp     rg   rp   c                       rB   )
AstExamplec                    s*   t t| ||| || _|| _|| _d S r   )r   rt   r
   labeltextr8   )r   r   r   r   ru   rv   r8   r   r   r	   r
     rc   zAstExample.__init__c                 C   r:   )NzAstExample({!r}, {!r}, {!r}))r   ru   rv   r8   r   r   r   r	   r     r<   zAstExample.__repr__rA   r   r   r   r	   rt     s    rt   c                       rB   )AstExampleFieldc                    re   r   )r   rw   r
   r   rq   rr   r   r   r	   r
     rf   zAstExampleField.__init__c                 C   r.   )NzAstExampleField({!r}, {!r})rs   r   r   r   r	   r     rD   zAstExampleField.__repr__rA   r   r   r   r	   rw     rg   rw   c                       rB   )AstExampleRefc                    s   t t| ||| || _d S r   )r   rx   r
   ru   )r   r   r   r   ru   r   r   r	   r
     s   
zAstExampleRef.__init__c                 C   r   )NzAstExampleRef({!r}))r   ru   r   r   r   r	   r     r   zAstExampleRef.__repr__rA   r   r   r   r	   rx     s    rx   )collectionsr   r5   objectr   r   r"   r&   r0   r>   rC   rF   rJ   r2   rN   rP   rR   rV   rX   rb   rd   rh   rp   rt   rw   rx   r   r   r   r	   <module>   s0    $%