U
    :qLev                     @   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+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 )-RuleContextN)parentinvokingStatec                    s   t    || _|| _d S N)super__init__	parentCtxr
   )selfr	   r
   	__class__ i/home/p21-0144/sympy/latex2sympy2solve-back-end/sympyEq/lib/python3.8/site-packages/antlr4/RuleContext.pyr   '   s    
zRuleContext.__init__c                 C   s$   d}| }|d k	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   sR   |   dkrdS t 2}|  D ]}||  q | W  5 Q R  S Q R X 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 k	r||k	r|d krH| s~|t|j n6| }|dkrl|t|k rl|| nt|}|| |jd k	r|d k	s|j s|d |j}q|d | W  5 Q R  S Q R X 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__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   antlr4.tree.Treer   r   r   Zantlr4.tree.Treesr   r   rD   r   r   r   r   <module>   s
   