a
    dW                     @   s`   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	 d dl
mZ dZG dd	 d	eZdS )
    )Enum)ATN)	ATNConfig)ATNConfigSet)RuleStopState)SemanticContextNc                   @   s  e Zd ZdZdZdZeeedddZ	eeddd	Z
eedd
dZeedddZeedddZeedddZeedddZeedddZeedddZeedddZeedddZeedddZeeddd Zeedd!d"Zd#S )$PredictionModer         )modeconfigsc                 C   sj   |  |rdS |tjkrJ|jrJt }|D ]}t|tjd}|| q(|}| 	|}| 
|oh| | S )NT)configZsemantic)allConfigsInRuleStopStatesr   SLLZhasSemanticContextr   r   r   NONEaddgetConflictingAltSubsetshasConflictingAltSethasStateAssociatedWithOneAlt)clsr   r   dupcaltsets r   b/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/antlr4/atn/PredictionMode.py#hasSLLConflictTerminatingPrediction   s    


z2PredictionMode.hasSLLConflictTerminatingPrediction)r   c                 C   s   t dd |D S )Nc                 s   s   | ]}t |jtV  qd S N
isinstancestater   .0cfgr   r   r   	<genexpr>       z:PredictionMode.hasConfigInRuleStopState.<locals>.<genexpr>anyr   r   r   r   r   hasConfigInRuleStopState   s    z'PredictionMode.hasConfigInRuleStopStatec                 C   s   t dd |D S )Nc                 s   s   | ]}t |jtV  qd S r   r   r    r   r   r   r#      r$   z<PredictionMode.allConfigsInRuleStopStates.<locals>.<genexpr>)allr'   r   r   r   r      s    z)PredictionMode.allConfigsInRuleStopStates)r   c                 C   s
   |  |S r   )getSingleViableAltr   r   r   r   r   resolvesToJustOneViableAltp  s    z)PredictionMode.resolvesToJustOneViableAltc                 C   s   |  | S r   )hasNonConflictingAltSetr+   r   r   r   allSubsetsConflict|  s    z!PredictionMode.allSubsetsConflictc                 C   s   t dd |D S )Nc                 s   s   | ]}t |d kV  qdS r	   Nlenr!   altsr   r   r   r#     r$   z9PredictionMode.hasNonConflictingAltSet.<locals>.<genexpr>r%   r+   r   r   r   r-     s    z&PredictionMode.hasNonConflictingAltSetc                 C   s   t dd |D S )Nc                 s   s   | ]}t |d kV  qdS r/   r0   r2   r   r   r   r#     r$   z6PredictionMode.hasConflictingAltSet.<locals>.<genexpr>r%   r+   r   r   r   r     s    z#PredictionMode.hasConflictingAltSetc                    s.   |sdS t t| t fddt|D S )NTc                 3   s   | ]}| kV  qd S r   r   r2   firstr   r   r#     r$   z1PredictionMode.allSubsetsEqual.<locals>.<genexpr>)nextiterr)   r+   r   r4   r   allSubsetsEqual  s    zPredictionMode.allSubsetsEqualc                 C   s(   |  |}t|dkr"tt|S tjS Nr	   )getAltsr1   r6   r7   r   INVALID_ALT_NUMBER)r   r   r)   r   r   r   getUniqueAlt  s    
zPredictionMode.getUniqueAltc                 C   s
   t j| S r   )setunionr+   r   r   r   r:     s    zPredictionMode.getAltsc                 C   sX   t  }|D ]D}t|jj|jf}||d }|d u rBt }|||< ||j q
|	 S r   )
dicthashr   ZstateNumbercontextgetr=   r   altvalues)r   r   ZconfigToAltsr   hr3   r   r   r   r     s    z'PredictionMode.getConflictingAltSubsetsc                 C   sF   t  }|D ]6}||jd }|d u r4t }|||j< ||j q
|S r   )r?   rB   r   r=   r   rC   )r   r   mr   r3   r   r   r   getStateToAltMap  s    
zPredictionMode.getStateToAltMapc                 C   s   t dd | | D S )Nc                 s   s   | ]}t |d kV  qdS r/   r0   r2   r   r   r   r#     r$   z>PredictionMode.hasStateAssociatedWithOneAlt.<locals>.<genexpr>)r&   rG   rD   r'   r   r   r   r     s    z+PredictionMode.hasStateAssociatedWithOneAltc                 C   s@   t  }|D ],}t|}|| t|dkr
tj  S q
t|S r9   )r=   minr   r1   r   r;   )r   r   Z
viableAltsr3   ZminAltr   r   r   r*     s    
z!PredictionMode.getSingleViableAltN)__name__
__module____qualname__r   ZLLZLL_EXACT_AMBIG_DETECTIONclassmethodr   r   r   r(   r   listr,   r.   r-   r   r8   r<   r:   r   rG   r   r*   r   r   r   r   r      s@   _# 

r   )enumr   Zantlr4.atn.ATNr   Zantlr4.atn.ATNConfigr   Zantlr4.atn.ATNConfigSetr   Zantlr4.atn.ATNStater   Zantlr4.atn.SemanticContextr   r   r   r   r   r   <module>   s   