o
    ڷi                     @   sH   d dl mZ d dlmZmZmZ d dlmZ dZdZ	G dd deZdS )    )StringIO)RuleNodeINVALID_INTERVALParseTreeVisitor)TreesNc                       s   e Zd ZdZdZd/dedef 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d ZdefddZdefddZdd Zd d! Zd"efd#d$Zd0d%ed&efd'd(Zd)d* Zd%ed+ed,efd-d.Z  ZS )1RuleContext)	parentCtxinvokingStateNparentr	   c                    s   t    || _|| _d S N)super__init__r   r	   )selfr   r	   	__class__ H/home/ubuntu/vllm_env/lib/python3.10/site-packages/antlr4/RuleContext.pyr   '   s   

zRuleContext.__init__c                 C   s*   d}| }|d ur|j }|d7 }|d us|S )Nr      )r   )r   npr   r   r   depth1   s   zRuleContext.depthc                 C   s
   | j dkS Nr
   )r	   r   r   r   r   isEmpty;      
zRuleContext.isEmptyc                 C   s   t S r   )r   r   r   r   r   getSourceInterval@      zRuleContext.getSourceIntervalc                 C      | S r   r   r   r   r   r   getRuleContextC   r   zRuleContext.getRuleContextc                 C   r   r   r   r   r   r   r   
getPayloadF   r   zRuleContext.getPayloadc                 C   s^   |   dkrdS t }|  D ]	}||  q| W  d    S 1 s(w   Y  d S )Nr    )getChildCountr   getChildrenwritegetTextgetvalue)r   builderchildr   r   r   r%   P   s   $zRuleContext.getTextc                 C      dS r   r   r   r   r   r   getRuleIndexX   r   zRuleContext.getRuleIndexc                 C   r)   Nr   r   r   r   r   r   getAltNumbera   r   zRuleContext.getAltNumber	altNumberc                 C      d S r   r   )r   r-   r   r   r   setAltNumberi   r   zRuleContext.setAltNumberic                 C   r.   r   r   )r   r0   r   r   r   getChildl   r   zRuleContext.getChildc                 C   r)   r+   r   r   r   r   r   r"   o   r   zRuleContext.getChildCountc                 c   s    dD ]}|V  qd S )Nr   r   )r   cr   r   r   r#   r   s   zRuleContext.getChildrenvisitorc                 C   s
   | | S r   )visitChildren)r   r3   r   r   r   acceptv   r   zRuleContext.accept	ruleNamesrecogc                 C   s   t j| ||dS )N)r6   r7   )r   toStringTree)r   r6   r7   r   r   r   r8      s   zRuleContext.toStringTreec                 C   s   |  d d S r   )toStringr   r   r   r   __str__   s   zRuleContext.__str__stopreturnc                 C   s   t  j}| }|d |d ur]||ur]|d u r$| s#|t|j n| }|dkr6|t|k r6|| nt|}|| |jd urR|d usM|j sR|d |j}|d ur]||us|d | W  d    S 1 spw   Y  d S )N[r    ])	r   r$   r   strr	   r*   lenr   r&   )r   r6   r;   bufr   riruleNamer   r   r   r9      s$   
$


$zRuleContext.toStringr   )NN)__name__
__module____qualname__	__slots__EMPTYr   intr   r   r   r   r   r    r%   r*   r,   r/   r1   r"   r#   r   r5   listParserr8   r:   r@   r9   __classcell__r   r   r   r   r   #   s(    


	:	r   )
ior   antlr4.tree.Treer   r   r   antlr4.tree.Treesr   r   rL   r   r   r   r   <module>   s   