o
    ¡ØÆh  ã                   @   s€   d dl mZ d dlmZ G dd„ deeƒZG dd„ deƒZG dd„ deƒZG d	d
„ d
eƒZG dd„ deeƒZ	G dd„ de	ƒZ
dS )é    )Údedent)Ú
StrAndReprc                   @   s2   e Zd ZdZddd„Zdd„ Zdd	„ Zd
d„ ZdS )Ú
ParseErrorz=A call to ``Expression.parse()`` or ``match()`` didn't match.éÿÿÿÿNc                 C   s   || _ || _|| _d S ©N)ÚtextÚposÚexpr)Úselfr   r   r	   © r   úd/var/www/html/HyperOracle/crypto_trader/venv/lib/python3.10/site-packages/parsimonious/exceptions.pyÚ__init__	   s   
zParseError.__init__c                 C   sH   | j jr
d| j j nt| j ƒ}d|| j| j| jd … |  ¡ |  ¡ f S )Nz'%s'z2Rule %s didn't match at '%s' (line %s, column %s).é   )r	   ÚnameÚstrr   r   ÚlineÚcolumn)r
   Ú	rule_namer   r   r   Ú__str__   s   ÿüzParseError.__str__c                 C   s&   t | jtƒrdS | j dd| j¡d S )zLReturn the 1-based line number where the expression ceased to
        match.NÚ
r   é   )Ú
isinstancer   ÚlistÚcountr   ©r
   r   r   r   r      s   zParseError.linec              	   C   s<   z| j | j dd| j ¡ W S  ttfy   | j d  Y S w )z?Return the 1-based column where the expression ceased to match.r   r   r   )r   r   ÚrindexÚ
ValueErrorÚAttributeErrorr   r   r   r   r   '   s
   ÿzParseError.column)r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s    

r   c                   @   s   e Zd Zdd„ ZdS )ÚLeftRecursionErrorc              
   C   s^   | j jr| j jnt| j ƒ}| j| j| jd … }td|›d|›d|  ¡ › d|  ¡ › d�	ƒ ¡ S )Nr   z$
            Left recursion in rule z at z (line z	, column a  ).

            Parsimonious is a packrat parser, so it can't handle left recursion.
            See https://en.wikipedia.org/wiki/Parsing_expression_grammar#Indirect_left_recursion
            for how to rewrite your grammar into a rule that does not use left-recursion.
            )	r	   r   r   r   r   r   r   r   Ústrip)r
   r   Úwindowr   r   r   r   1   s   ÿÿÿÿùzLeftRecursionError.__str__N)r   r   r    r   r   r   r   r   r"   0   s    r"   c                   @   s   e Zd ZdZdd„ ZdS )ÚIncompleteParseErrorzYA call to ``parse()`` matched a whole Expression but did not consume the
    entire text.c                 C   s.   d| j j| j| j| jd … |  ¡ |  ¡ f S )Nz’Rule '%s' matched in its entirety, but it didn't consume all the text. The non-matching portion of the text begins with '%s' (line %s, column %s).r   )r	   r   r   r   r   r   r   r   r   r   r   B   s   üzIncompleteParseError.__str__N)r   r   r    r!   r   r   r   r   r   r%   >   s    r%   c                       s    e Zd ZdZ‡ fdd„Z‡  ZS )ÚVisitationErroraD  Something went wrong while traversing a parse tree.

    This exception exists to augment an underlying exception with information
    about where in the parse tree the error occurred. Otherwise, it could be
    tiresome to figure out what went wrong; you'd have to play back the whole
    tree traversal in your head.

    c                    s*   || _ tƒ  d|j||j|d�f ¡ dS )z�Construct.

        :arg exc: What went wrong. We wrap this and add more info.
        :arg node: The node at which the error occurred

        z%s: %s

Parse tree:
%s)ÚerrorN)Úoriginal_classÚsuperr   r   Úprettily)r
   ÚexcÚ	exc_classÚnode©Ú	__class__r   r   r   V   s   
þýÿzVisitationError.__init__)r   r   r    r!   r   Ú__classcell__r   r   r.   r   r&   J   s    r&   c                   @   s   e Zd ZdZdS )Ú
BadGrammarz¥Something was wrong with the definition of a grammar.

    Note that a ParseError might be raised instead if the error is in the
    grammar definition syntax.

    N)r   r   r    r!   r   r   r   r   r1   g   s    r1   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚUndefinedLabelz¡A rule referenced in a grammar was never defined.

    Circular references and forward references are okay, but you have to define
    stuff at some point.

    c                 C   s
   || _ d S r   ©Úlabel)r
   r4   r   r   r   r   w   ó   
zUndefinedLabel.__init__c                 C   s
   d| j  S )Nz!The label "%s" was never defined.r3   r   r   r   r   r   z   r5   zUndefinedLabel.__str__N)r   r   r    r!   r   r   r   r   r   r   r2   p   s    r2   N)Útextwrapr   Úparsimonious.utilsr   Ú	Exceptionr   r"   r%   r&   r1   r2   r   r   r   r   Ú<module>   s    *	