U
    :qLeW                     @   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)configsemantic)allConfigsInRuleStopStatesr   SLLhasSemanticContextr   r   r   NONEaddgetConflictingAltSubsetshasConflictingAltSethasStateAssociatedWithOneAlt)clsr   r   dupcaltsets r   p/home/p21-0144/sympy/latex2sympy2solve-back-end/sympyEq/lib/python3.8/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>   s     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%      s     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%     s     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 r0   r1   r3   r   r   r   r%     s     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   r3   firstr   r   r%     s     z1PredictionMode.allSubsetsEqual.<locals>.<genexpr>)nextiterr*   r,   r   r5   r   allSubsetsEqual  s    zPredictionMode.allSubsetsEqualc                 C   s(   |  |}t|dkr"tt|S tjS Nr	   )getAltsr2   r7   r8   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 krBt }|||< ||j q
|	 S r   )
dicthashr!   stateNumbercontextgetr>   r   altvalues)r   r   ZconfigToAltsr   hr4   r   r   r   r     s    z'PredictionMode.getConflictingAltSubsetsc                 C   sF   t  }|D ]6}||jd }|d kr4t }|||j< ||j q
|S r   )r@   rD   r!   r>   r   rE   )r   r   mr   r4   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 r0   r1   r3   r   r   r   r%     s     z>PredictionMode.hasStateAssociatedWithOneAlt.<locals>.<genexpr>)r'   rI   rF   r(   r   r   r   r     s    z+PredictionMode.hasStateAssociatedWithOneAltc                 C   s@   t  }|D ],}t|}|| t|dkr
tj  S q
t|S r:   )r>   minr   r2   r   r<   )r   r   Z
viableAltsr4   ZminAltr   r   r   r+     s    
z!PredictionMode.getSingleViableAltN)__name__
__module____qualname__r   LLLL_EXACT_AMBIG_DETECTIONclassmethodr   r   r   r)   r   listr-   r/   r.   r   r9   r=   r;   r   rI   r   r+   r   r   r   r   r      s@   _# 

r   )enumr   antlr4.atn.ATNr   antlr4.atn.ATNConfigr   antlr4.atn.ATNConfigSetr   antlr4.atn.ATNStater   antlr4.atn.SemanticContextr   r   r   r   r   r   <module>   s   