a
    d                     @   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,eed 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edddZedddZdd Zdd  Zed!d"d#Zd-eed$d%d&Zd'd( Zeeed)d*d+Z  ZS ).RuleContext)	parentCtxinvokingStateN)parentr	   c                    s   t    || _|| _d S N)super__init__r   r	   )selfr   r	   	__class__ [/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/antlr4/RuleContext.pyr   '   s    
zRuleContext.__init__c                 C   s$   d}| }|d ur |j }|d7 }q|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;   s    zRuleContext.isEmptyc                 C   s   t S r   )r   r   r   r   r   getSourceInterval@   s    zRuleContext.getSourceIntervalc                 C   s   | S r   r   r   r   r   r   getRuleContextC   s    zRuleContext.getRuleContextc                 C   s   | S r   r   r   r   r   r   
getPayloadF   s    zRuleContext.getPayloadc                 C   s^   |   dkrdS t 4}|  D ]}||  q | W  d    S 1 sP0    Y  d S )Nr    )getChildCountr   getChildrenwritegetTextgetvalue)r   Zbuilderchildr   r   r   r"   P   s    zRuleContext.getTextc                 C   s   dS r   r   r   r   r   r   getRuleIndexX   s    zRuleContext.getRuleIndexc                 C   s   dS Nr   r   r   r   r   r   getAltNumbera   s    zRuleContext.getAltNumber)	altNumberc                 C   s   d S r   r   )r   r(   r   r   r   setAltNumberi   s    zRuleContext.setAltNumber)ic                 C   s   d S r   r   )r   r*   r   r   r   getChildl   s    zRuleContext.getChildc                 C   s   dS r&   r   r   r   r   r   r   o   s    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   )ZvisitChildren)r   r-   r   r   r   acceptv   s    zRuleContext.accept	ruleNamesrecogc                 C   s   t j| ||dS )Nr/   )r   toStringTree)r   r0   r1   r   r   r   r2      s    zRuleContext.toStringTreec                 C   s   |  d d S r   )toStringr   r   r   r   __str__   s    zRuleContext.__str__)r0   stopreturnc                 C   s   t  }| }|d |d ur||ur|d u rH| s~|t|j n6| }|dkrl|t|k rl|| nt|}|| |jd ur|d us|j s|d |j}q|d | W  d    S 1 s0    Y  d S )N[r    ])	r   r!   r   strr	   r%   lenr   r#   )r   r0   r5   bufr   riZruleNamer   r   r   r3      s    
$


zRuleContext.toString)Nr
   )NN)__name__
__module____qualname__	__slots__ZEMPTYr   intr   r   r   r   r   r   r"   r%   r'   r)   r+   r   r    r   r.   listParserr2   r4   r:   r3   __classcell__r   r   r   r   r   #   s&   


	:	r   )
ior   Zantlr4.tree.Treer   r   r   Zantlr4.tree.Treesr   r   rD   r   r   r   r   <module>   s
   