o
    h
                     @   s   d dl Z d dlZd dlZd dlmZ e jeZe j	e j
edZe j
edZdZdd Zefdd	Zed
kr?e  dS dS )    N)debugzLaTeX.g4_antlra  # *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
#
# Generated from ../LaTeX.g4, derived from latex2sympy
#     latex2sympy is licensed under the MIT license
#     https://github.com/augustt198/latex2sympy/blob/master/LICENSE.txt
#
# Generated with antlr4
#    antlr4 is licensed under the BSD-3-Clause License
#    https://github.com/antlr/antlr4/blob/master/LICENSE.txt
c                	   C   sR   t d zt tdgddd  W dS  tjtfy(   t d Y dS w )	NzChecking antlr4 version...antlr4zutf-8
r   TzThe 'antlr4' command line tool is not installed, or not on your PATH.
> Please refer to the README.md file for more information.F)r   
subprocesscheck_outputdecodesplitCalledProcessErrorFileNotFoundError r   r   Z/var/www/vscode/kcb/lib/python3.10/site-packages/sympy/parsing/latex/_build_latex_antlr.pycheck_antlr_version   s   r   c           	   	   C   s  t   td|  tj| st|  ttj| dd}|	t
 W d    n1 s/w   Y  dtd| ddg}tdd	| tj|| d
 td ttj| dpdttj| dD ]{}|dsrt| qetj| tj| }t|d}dd | D }W d    n1 sw   Y  t| t|d*}d}|| dr|d7 }|| ds|	t
 |||d   W d    n1 sw   Y  td| qedS )Nz#Updating ANTLR-generated code in {}z__init__.pyzw+r   z-oz-no-visitorz-no-listenerz Running code generation...
	$ {} )cwdz<Applying headers, removing unnecessary files and renaming...zLaTeX*.*zlatex*.*z.pyrc                 S   s   g | ]}|  d  qS )r   )rstrip).0liner   r   r   
<listcomp>J   s    z build_parser.<locals>.<listcomp>wr   #   z	{}T)r   r   formatospathexistsmakedirsopenjoinwriteheadergrammar_filer   r   globendswithunlinkbasenamelower	readlines
startswith
writelines)	
output_dirfpargsr   new_pathflinesout_fileoffsetr   r   r   build_parser&   sJ   
	



r3   __main__)r   r   r#   sympy.utilities.miscr   r   dirname__file__hereabspathr   r"   dir_latex_antlrr!   r   r3   __name__r   r   r   r   <module>   s    4
