o
    ?iW                     @   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dedefddZ	edefdd	Z
edefd
dZedefddZedefddZedefddZedefddZedefddZedefddZedefddZedefddZedefddZedefdd Zedefd!d"Zd#S )$PredictionModer         modeconfigsc                 C   sj   |  |rdS |tjkr%|jr%t }|D ]}t|tjd}|| q|}| 	|}| 
|o4| | S )NT)configsemantic)allConfigsInRuleStopStatesr   SLLhasSemanticContextr   r   r   NONEaddgetConflictingAltSubsetshasConflictingAltSethasStateAssociatedWithOneAlt)clsr   r   dupcaltsets r   V/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/antlr4/atn/PredictionMode.py#hasSLLConflictTerminatingPrediction   s   


z2PredictionMode.hasSLLConflictTerminatingPredictionc                 C      t dd |D S )Nc                 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      z'PredictionMode.hasConfigInRuleStopStatec                 C   r   )Nc                 s   r   r    r!   r$   r   r   r   r'      r(   z<PredictionMode.allConfigsInRuleStopStates.<locals>.<genexpr>)allr+   r   r   r   r      r-   z)PredictionMode.allConfigsInRuleStopStatesr   c                 C   s
   |  |S r    )getSingleViableAltr   r   r   r   r   resolvesToJustOneViableAltp     
z)PredictionMode.resolvesToJustOneViableAltc                 C   s   |  | S r    )hasNonConflictingAltSetr0   r   r   r   allSubsetsConflict|  s   z!PredictionMode.allSubsetsConflictc                 C   r   )Nc                 s       | ]	}t |d kV  qdS r	   Nlenr%   altsr   r   r   r'     r(   z9PredictionMode.hasNonConflictingAltSet.<locals>.<genexpr>r)   r0   r   r   r   r3     r-   z&PredictionMode.hasNonConflictingAltSetc                 C   r   )Nc                 s   s    | ]	}t |d kV  qdS r6   r7   r9   r   r   r   r'     r(   z6PredictionMode.hasConflictingAltSet.<locals>.<genexpr>r)   r0   r   r   r   r     r-   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   r9   firstr   r   r'     s    z1PredictionMode.allSubsetsEqual.<locals>.<genexpr>)nextiterr.   r0   r   r;   r   allSubsetsEqual  s   zPredictionMode.allSubsetsEqualc                 C   s(   |  |}t|dkrtt|S tjS Nr	   )getAltsr8   r=   r>   r   INVALID_ALT_NUMBER)r   r   r.   r   r   r   getUniqueAlt  s   
zPredictionMode.getUniqueAltc                 C   s
   t j| S r    )setunionr0   r   r   r   rA     r2   zPredictionMode.getAltsc                 C   sX   t  }|D ]"}t|jj|jf}||d }|d u r!t }|||< ||j q|	 S r    )
dicthashr#   stateNumbercontextgetrD   r   altvalues)r   r   configToAltsr   hr:   r   r   r   r     s   z'PredictionMode.getConflictingAltSubsetsc                 C   sF   t  }|D ]}||jd }|d u rt }|||j< ||j q|S r    )rF   rJ   r#   rD   r   rK   )r   r   mr   r:   r   r   r   getStateToAltMap  s   
zPredictionMode.getStateToAltMapc                 C   s   t dd | | D S )Nc                 s   r5   r6   r7   r9   r   r   r   r'     r(   z>PredictionMode.hasStateAssociatedWithOneAlt.<locals>.<genexpr>)r*   rP   rL   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@   )rD   minr   r8   r   rB   )r   r   
viableAltsr:   minAltr   r   r   r/     s   

z!PredictionMode.getSingleViableAltN)__name__
__module____qualname__r   LLLL_EXACT_AMBIG_DETECTIONclassmethodr   r   r   r,   r   listr1   r4   r3   r   r?   rC   rA   r   rP   r   r/   r   r   r   r   r      sB    _# 

r   )enumr   antlr4.atn.ATNr   antlr4.atn.ATNConfigr   antlr4.atn.ATNConfigSetr   antlr4.atn.ATNStater   antlr4.atn.SemanticContextr   r   r   r   r   r   <module>   s   