o
    Øôjx   ã                   @   s�   d dl mZ d dlmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZmZ d	ZG d
d„ deƒZG dd„ deƒZd	S )é    )ÚStringIO)Úreduce)ÚPredictionContextÚmerge)Ústr_list)ÚATN)Ú	ATNConfig)ÚSemanticContext)ÚUnsupportedOperationExceptionÚIllegalStateExceptionNc                   @   sÎ   e Zd ZdZd.defdd„Zdd„ Zd/d	efd
d„Zd	efdd„Z	dd„ Z
dd„ Zdefdd„Zdefdd„Zdefdd„Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)efd*d+„Zd,d-„ ZdS )0ÚATNConfigSet)	ÚconfigLookupÚfullCtxÚreadonlyÚconfigsÚ	uniqueAltÚconflictingAltsÚhasSemanticContextÚdipsIntoOuterContextÚcachedHashCodeTr   c                 C   s<   t ƒ | _|| _d| _g | _d| _d | _d| _d| _d| _	d S )NFr   éÿÿÿÿ)
Údictr   r   r   r   r   r   r   r   r   )Úselfr   © r   új/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/antlr4/atn/ATNConfigSet.pyÚ__init__$   s   
zATNConfigSet.__init__c                 C   s
   | j  ¡ S ©N)r   Ú__iter__©r   r   r   r   r   A   ó   
zATNConfigSet.__iter__NÚconfigc                 C   s˜   | j rtdƒ‚|jtjurd| _|jdkrd| _|  |¡}||u r,d| _	| j
 |¡ dS | j }t|j|j||ƒ}t|j|jƒ|_|jrGd|_||_dS )NúThis set is readonlyTr   r   )r   Ú	ExceptionÚsemanticContextr	   ÚNONEr   ÚreachesIntoOuterContextr   ÚgetOrAddr   r   Úappendr   r   ÚcontextÚmaxÚprecedenceFilterSuppressed)r   r    Ú
mergeCacheÚexistingÚrootIsWildcardÚmergedr   r   r   ÚaddM   s$   

zATNConfigSet.addc                    sl   ˆ   ¡ }| j |d ¡}|d ur!t‡ fdd„|D ƒd ƒ}|d ur!|S |d u r/ˆ g}|| j|< ˆ S | ˆ ¡ ˆ S )Nc                 3   s   � | ]
}ˆ   |¡r|V  qd S r   )ÚequalsForConfigSet©Ú.0Úcfg©r    r   r   Ú	<genexpr>j   s   € z(ATNConfigSet.getOrAdd.<locals>.<genexpr>)ÚhashCodeForConfigSetr   ÚgetÚnextr'   )r   r    ÚhÚlÚrr   r4   r   r&   f   s   

ÿzATNConfigSet.getOrAddc                 C   ó   t dd„ | jD ƒƒS )Nc                 s   s   � | ]}|j V  qd S r   )Ústate)r2   Úcr   r   r   r5   u   s   € z)ATNConfigSet.getStates.<locals>.<genexpr>)Úsetr   r   r   r   r   Ú	getStatest   ó   zATNConfigSet.getStatesc                 C   r<   )Nc                 s   s"   � | ]}|j tjkr|j V  qd S r   )r#   r	   r$   r1   r   r   r   r5   x   s   €  z-ATNConfigSet.getPredicates.<locals>.<genexpr>)Úlistr   r   r   r   r   ÚgetPredicatesw   rA   zATNConfigSet.getPredicatesÚic                 C   s
   | j | S r   )r   )r   rD   r   r   r   r7   z   r   zATNConfigSet.getÚinterpreterc                 C   s>   | j rtdƒ‚t| jƒdkrd S | jD ]	}| |j¡|_qd S )Nr!   r   )r   r   Úlenr   ÚgetCachedContextr(   )r   rE   r    r   r   r   ÚoptimizeConfigs}   s   
ÿzATNConfigSet.optimizeConfigsÚcollc                 C   s   |D ]}|   |¡ qdS )NF)r/   )r   rI   r>   r   r   r   ÚaddAll…   s   zATNConfigSet.addAllc                 C   sp   | |u rdS t |tƒsdS | jd uo5| j|jko5| j|jko5| j|jko5| j|jko5| j|jko5| j|jk}|S )NTF)Ú
isinstancer   r   r   r   r   r   r   )r   ÚotherÚsamer   r   r   Ú__eq__Š   s$   


ÿ
þ
ý
ü
û
úzATNConfigSet.__eq__c                 C   s(   | j r| jdkr|  ¡ | _| jS |  ¡ S )Nr   )r   r   ÚhashConfigsr   r   r   r   Ú__hash__š   s
   

zATNConfigSet.__hash__c                 C   s   t dd„ | jdƒS )Nc                 S   s   t | |fƒS r   )Úhash)r9   r3   r   r   r   Ú<lambda>¢   s    z*ATNConfigSet.hashConfigs.<locals>.<lambda>r   )r   r   r   r   r   r   rO   ¡   s   zATNConfigSet.hashConfigsc                 C   s
   t | jƒS r   ©rF   r   r   r   r   r   Ú__len__¤   r   zATNConfigSet.__len__c                 C   s   t | jƒdkS )Nr   rS   r   r   r   r   ÚisEmpty§   ó   zATNConfigSet.isEmptyc                 C   sN   | j d u r	tdƒ‚| ¡ }| j  |d ¡}|d ur%|D ]
}| |¡r$ dS qdS )Nz1This method is not implemented for readonly sets.TF)r   r
   r6   r7   r0   )r   r    r9   r:   r>   r   r   r   Ú__contains__ª   s   

ÿzATNConfigSet.__contains__c                 C   s,   | j rtdƒ‚| j ¡  d| _| j ¡  d S )Nr!   r   )r   r   r   Úclearr   r   r   r   r   r   rX   µ   s
   
zATNConfigSet.clearr   c                 C   s   || _ d | _d S r   )r   r   )r   r   r   r   r   ÚsetReadonly¼   s   
zATNConfigSet.setReadonlyc                 C   s¼   t ƒ �Q}| t| jƒ¡ | jr| d¡ | t| jƒ¡ | jtjkr/| d¡ | t| jƒ¡ | j	d urA| d¡ | t| j	ƒ¡ | j
rI| d¡ | ¡ W  d   ƒ S 1 sWw   Y  d S )Nz,hasSemanticContext=z,uniqueAlt=z,conflictingAlts=z,dipsIntoOuterContext)r   Úwriter   r   r   Ústrr   r   ÚINVALID_ALT_NUMBERr   r   Úgetvalue)r   Úbufr   r   r   Ú__str__À   s   




$ózATNConfigSet.__str__)Tr   )Ú__name__Ú
__module__Ú__qualname__Ú	__slots__Úboolr   r   r   r/   r&   r@   rC   Úintr7   ÚATNSimulatorrH   rB   rJ   rN   rP   rO   rT   rU   rW   rX   rY   r_   r   r   r   r   r      s(    r   c                       s   e Zd Z‡ fdd„Z‡  ZS )ÚOrderedATNConfigSetc                    s   t ƒ  ¡  d S r   )Úsuperr   r   ©Ú	__class__r   r   r   Ó   rV   zOrderedATNConfigSet.__init__)r`   ra   rb   r   Ú__classcell__r   r   ri   r   rg   Ñ   s    rg   )Úior   Ú	functoolsr   Úantlr4.PredictionContextr   r   Úantlr4.Utilsr   Úantlr4.atn.ATNr   Úantlr4.atn.ATNConfigr   Úantlr4.atn.SemanticContextr	   Úantlr4.error.Errorsr
   r   rf   Úobjectr   rg   r   r   r   r   Ú<module>   s   
 <