
    Mff                     F    d dl mZmZ ddlZd dlmZ  G d de          ZdS )   )ExcelFormulaParserExcelFormulaLexer    N)ANTLRExceptionc                   4    e Zd Zg dZd Zd Zd Zd Zd ZdS )Formula)__s__parser__sheet_refs__xcall_refsc                 8   	 || _         t          j        |          }t          j        |          | _        | j                                         | j        j        | _        | j        j	        | _
        d S # t          $ r}t          j        d|z             d }~ww xY w)Nzcan't parse formula )_Formula__sr   Lexerr   Parser_Formula__parserformulasheet_references_Formula__sheet_refsxcall_references_Formula__xcall_refsr   FormulaParseException)selfslexeres       P/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/xlwt/ExcelFormula.py__init__zFormula.__init__   s    		WDH%+A..E.5e<<DMM!!### $ >D $ >D 	W 	W 	W$:;QTU;UVVV	Ws   A/A3 3
B=BBc                     | j         | j        fS N)r   r   r   s    r   get_referenceszFormula.get_references   s     $"333    c                     |D ]Q\  }}| j         j        d |         t          j        d|          z   | j         j        |dz   d          z   | j         _        Rd S )N<H   )r   rpnstructpack)r   patchesoffsetidxs       r   patch_referenceszFormula.patch_references   sm    " 	s 	sKFC $ 1'6' :V[s=S=S SVZVcVghnophphqhqVr rDM	s 	sr"   c                     | j         S r   )r   r    s    r   textzFormula.text   s	    xr"   c                 t    t          j        dt          | j        j                            | j        j        z   S )z
        Offset    Size    Contents
        0         2       Size of the following formula data (sz)
        2         sz      Formula data (RPN token array)
        [2+sz]    var.    (optional) Additional data for specific tokens

        r$   )r'   r(   lenr   r&   r    s    r   r&   zFormula.rpn"   s-     {4T]%6!7!7884=;LLLr"   N)	__name__
__module____qualname__	__slots__r   r!   r,   r.   r&    r"   r   r   r      su        CCCI
W 
W 
W4 4 4s s s  M M M M Mr"   r   ) r   r   r'   antlrr   objectr   r5   r"   r   <module>r9      sx    4 3 3 3 3 3 3 3  ! ! ! ! ! !"M "M "M "M "Mf "M "M "M "M "Mr"   