o
    QDiSa                     @  s   d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
mZmZ d dlmZmZ i ZG dd deZG d	d
 d
eZG dd dZdd Zedkrmd dlZd dlmZ eeeddZeeZeejedd dS dS )    )annotationsN)Buffer)ParserConfig)Parserisnameleftrecnomemo	tatsumasu)generic_mainrec                      s    e Zd Zdd fddZ  ZS )r   Nconfigr   c                  s@   t j|| d d d d dddd	}|jdi |}t j||d d S )NF )owner
whitespace	nameguardcomments_reeol_comments_re
ignorecase	namechars	parseinfor    )r   newreplacesuper__init__)selftextr   settings	__class__r   X/var/www/Datamplify/venv/lib/python3.10/site-packages/frictionless/vendors/wkt/parser.pyr      s   zBuffer.__init__Nr   r   )__name__
__module____qualname__r   __classcell__r   r   r   r!   r      s    r   c                      s  e Zd Zdpdq fddZe dd Ze dd	 Ze d
d Ze dd Ze dd Z	e dd Z
e dd Ze dd Ze dd Ze dd Ze dd Ze dd Ze dd Ze d d! Ze d"d# Ze d$d% Ze d&d' Ze d(d) Ze d*d+ Ze d,d- Ze d.d/ Ze d0d1 Ze d2d3 Ze d4d5 Ze d6d7 Ze d8d9 Ze d:d; Ze d<d= Z e d>d? Z!e d@dA Z"e dBdC Z#e dDdE Z$e dFdG Z%e dHdI Z&e dJdK Z'e dLdM Z(e dNdO Z)e dPdQ Z*e dRdS Z+e dTdU Z,e dVdW Z-e dXdY Z.e dZd[ Z/e d\d] Z0e d^d_ Z1e d`da Z2e dbdc Z3e ddde Z4e dfdg Z5e dhdi Z6e djdk Z7e dldm Z8e dndo Z9  Z:S )rr   Nr   r   c                  sB   t j|| d d d d dddtdd}|jdi |}t j|d d S )NFr   wkt_representation)
r   r   r   r   r   r   r   r   keywordsstartr   r   )r   r   KEYWORDSr   r   r   )r   r   r   r   r   r!   r   *   s   zParser.__init__c              	   C     |   n |   |   W d    n1 sw   Y  |   |   W d    n1 s0w   Y  |   |   W d    n1 sHw   Y  |   |   W d    n1 s`w   Y  | d W d    d S 1 suw   Y  d S )Na  expecting one of: 'POINT'<circularstring_text_representation><collection_text_representation><compoundcurve_text_representation><curve_text_representation><curvepolygon_text_representation><geometrycollection_text_representation><linestring_text_representation><multicurve_text_representation><multipoint_text_representation><multisurface_text_representation><point_text_representation><surface_text_representation>)_choice_option_point_text_representation__curve_text_representation__surface_text_representation_ _collection_text_representation__errorr   r   r   r!   _wkt_representation_;   "   








"zParser._wkt_representation_c                 C  F   |  d |   |   W d    n1 sw   Y  |   d S )NPOINT)_token	_optional_z_m__point_text_r4   r   r   r!   r/   W   
   


z"Parser._point_text_representation_c              	   C     |   V |   |   W d    n1 sw   Y  |   |   W d    n1 s0w   Y  |   |   W d    n1 sHw   Y  | d W d    d S 1 s]w   Y  d S )Nzexpecting one of: 'CIRCULARSTRING' 'COMPOUNDCURVE''LINESTRING'<circularstring_text_representation><compoundcurve_text_representation><linestring_text_representation>)r-   r.    _linestring_text_representation_$_circularstring_text_representation_#_compoundcurve_text_representation_r3   r4   r   r   r!   r0   ^      






"z"Parser._curve_text_representation_c                 C  r7   )N
LINESTRING)r9   r:   r;   _linestring_text_body_r4   r   r   r!   r?   p   r=   z'Parser._linestring_text_representation_c                 C  r7   )NCIRCULARSTRING)r9   r:   r;   _circularstring_text_r4   r   r   r!   r@   w   r=   z+Parser._circularstring_text_representation_c                 C  r7   )NCOMPOUNDCURVE)r9   r:   r;   _compoundcurve_text_r4   r   r   r!   rA   ~   r=   z*Parser._compoundcurve_text_representation_c                 C     |    d S r"   )"_curvepolygon_text_representation_r4   r   r   r!   r1         z$Parser._surface_text_representation_c              
   C  s  |   s |  ) | d |   |   W d    n1 s"w   Y  |   W d    n1 s5w   Y  |   |   W d    n1 sMw   Y  |   |   W d    n1 sew   Y  | d W d    d S 1 szw   Y  d S )NCURVEPOLYGONzpexpecting one of: 'CURVEPOLYGON' 'POLYGON' 'TRIANGLE'<polygon_text_representation><triangle_text_representation>)	r-   r.   r9   r:   r;   _curvepolygon_text_body__polygon_text_representation__triangle_text_representation_r3   r4   r   r   r!   rJ      s$   









"z)Parser._curvepolygon_text_representation_c                 C  r7   )NPOLYGON)r9   r:   r;   _polygon_text_body_r4   r   r   r!   rN      r=   z$Parser._polygon_text_representation_c                 C  r7   )NTRIANGLE)r9   r:   r;   _triangle_text_body_r4   r   r   r!   rO      r=   z%Parser._triangle_text_representation_c              	   C  r,   )Na_  expecting one of: 'GEOMETRYCOLLECTION' 'MULTICURVE''MULTIPOINT' 'MULTISURFACE'<geometrycollection_text_representation><multicurve_text_representation><multilinestring_text_representation><multipoint_text_representation><multipolygon_text_representation><multisurface_text_representation><polyhedralsurface_text_representation><tin_text_representation>)r-   r.    _multipoint_text_representation_ _multicurve_text_representation_"_multisurface_text_representation_(_geometrycollection_text_representation_r3   r4   r   r   r!   r2      r6   z'Parser._collection_text_representation_c                 C  r7   )N
MULTIPOINT)r9   r:   r;   _multipoint_text_r4   r   r   r!   rT      r=   z'Parser._multipoint_text_representation_c              
   C  s   |   [ |  ) | d |   |   W d    n1 s"w   Y  |   W d    n1 s5w   Y  |   |   W d    n1 sMw   Y  | d W d    d S 1 sbw   Y  d S )N
MULTICURVEzUexpecting one of: 'MULTICURVE' 'MULTILINESTRING'<multilinestring_text_representation>)r-   r.   r9   r:   r;   _multicurve_text_%_multilinestring_text_representation_r3   r4   r   r   r!   rU      s   







"z'Parser._multicurve_text_representation_c                 C  r7   )NMULTILINESTRING)r9   r:   r;   _multilinestring_text_r4   r   r   r!   r\      r=   z,Parser._multilinestring_text_representation_c              
   C  s2  |    |  ) | d |   |   W d    n1 s"w   Y  |   W d    n1 s5w   Y  |   |   W d    n1 sMw   Y  |   |   W d    n1 sew   Y  |   |   W d    n1 s}w   Y  | 	d W d    d S 1 sw   Y  d S )NMULTISURFACEzexpecting one of: 'MULTIPOLYGON' 'MULTISURFACE''POLYHEDRALSURFACE' 'TIN'<multipolygon_text_representation><polyhedralsurface_text_representation><tin_text_representation>)
r-   r.   r9   r:   r;   _multisurface_text_"_multipolygon_text_representation_'_polyhedralsurface_text_representation__tin_text_representation_r3   r4   r   r   r!   rV      s*   











"z)Parser._multisurface_text_representation_c                 C  r7   )NMULTIPOLYGON)r9   r:   r;   _multipolygon_text_r4   r   r   r!   ra      r=   z)Parser._multipolygon_text_representation_c                 C  r7   )NPOLYHEDRALSURFACE)r9   r:   r;   _polyhedralsurface_text_r4   r   r   r!   rb      r=   z.Parser._polyhedralsurface_text_representation_c                 C  r7   )NTIN)r9   r:   r;   
_tin_text_r4   r   r   r!   rc     r=   z Parser._tin_text_representation_c                 C  r7   )NGEOMETRYCOLLECTION)r9   r:   r;   _geometrycollection_text_r4   r   r   r!   rW     r=   z/Parser._geometrycollection_text_representation_c                 C  rI   r"   )_linestring_text_r4   r   r   r!   rD     rK   zParser._linestring_text_body_c                 C  rI   r"   )_curvepolygon_text_r4   r   r   r!   rM     rK   zParser._curvepolygon_text_body_c                 C  rI   r"   )_polygon_text_r4   r   r   r!   rQ     rK   zParser._polygon_text_body_c                 C  rI   r"   )_triangle_text_r4   r   r   r!   rS      rK   zParser._triangle_text_body_c              	   C     |   F |   |   W d    n1 sw   Y  |   |   |   |   W d    n1 s8w   Y  | d W d    d S 1 sMw   Y  d S N6expecting one of: '(' 'EMPTY' <empty_set> <left_paren>)r-   r.   _empty_set__left_paren__point__right_paren_r3   r4   r   r   r!   r<   $     




"zParser._point_text_c                 C  sv   |    |   |   |   W d    n1 sw   Y  |   |   W d    d S 1 s4w   Y  d S r"   )_x__y_r:   _z__m_r4   r   r   r!   ru   /  s   



"zParser._point_c                 C  rI   r"   _number_r4   r   r   r!   rx   8  rK   z
Parser._x_c                 C  rI   r"   r|   r4   r   r   r!   ry   <  rK   z
Parser._y_c                 C  rI   r"   r|   r4   r   r   r!   rz   @  rK   z
Parser._z_c                 C  rI   r"   r|   r4   r   r   r!   r{   D  rK   z
Parser._m_c              	           Q       W d    n1 sw   Y            fdd} |    W d    n1 sCw   Y   d W d    d S 1 sXw   Y  d S )Nc                               d S r"   _comma_ru   r   r4   r   r!   block1Q     z(Parser._linestring_text_.<locals>.block1rr   r-   r.   rs   rt   ru   _closurerv   r3   r   r   r   r4   r!   rl   H     






"zParser._linestring_text_c              	     r~   )Nc                     r   r"   r   r   r4   r   r!   r   b  r   z,Parser._circularstring_text_.<locals>.block1rr   r   r   r   r4   r!   rF   Y  r   zParser._circularstring_text_c              	     r~   )Nc                     r   r"   )r   _single_curve_text_r   r4   r   r!   r   s  r   z+Parser._compoundcurve_text_.<locals>.block1rr   )r-   r.   rs   rt   r   r   rv   r3   r   r   r4   r!   rH   j  r   zParser._compoundcurve_text_c              	   C  s   |   > |   |   W d    n1 sw   Y  |   |   W d    n1 s0w   Y  | d W d    d S 1 sEw   Y  d S )Nzexpecting one of: 'CIRCULARSTRING'<circularstring_text_representation><empty_set> <left_paren><linestring_text> <linestring_text_body>)r-   r.   rD   r@   r3   r4   r   r   r!   r   {  s   




"zParser._single_curve_text_c              	   C  r>   Nzexpecting one of: 'CIRCULARSTRING' 'COMPOUNDCURVE'<circularstring_text_representation><compoundcurve_text_representation><empty_set> <left_paren><linestring_text> <linestring_text_body>r-   r.   rD   r@   rA   r3   r4   r   r   r!   _curve_text_  rB   zParser._curve_text_c              	   C  r>   r   r   r4   r   r   r!   _ring_text_  rB   zParser._ring_text_c              	   C  s   |   C |   | d |   W d    n1 sw   Y  |   |   W d    n1 s5w   Y  | d W d    d S 1 sJw   Y  d S )NrL   z[expecting one of: 'CURVEPOLYGON' <empty_set> <left_paren><polygon_text> <polygon_text_body>)r-   r.   r9   rM   rQ   r3   r4   r   r   r!   _surface_text_  s   





"zParser._surface_text_c              	     r~   )Nc                     r   r"   )r   r   r   r4   r   r!   r     r   z*Parser._curvepolygon_text_.<locals>.block1rr   )r-   r.   rs   rt   r   r   rv   r3   r   r   r4   r!   rm     r   zParser._curvepolygon_text_c              	     r~   )Nc                     r   r"   )r   rl   r   r4   r   r!   r     r   z%Parser._polygon_text_.<locals>.block1rr   )r-   r.   rs   rt   rl   r   rv   r3   r   r   r4   r!   rn     r   zParser._polygon_text_c              	   C  rp   rq   )r-   r.   rs   rt   rl   rv   r3   r4   r   r   r!   ro     rw   zParser._triangle_text_c              	     r~   )Nc                     r   r"   )r   r<   r   r4   r   r!   r     r   z(Parser._multipoint_text_.<locals>.block1rr   )r-   r.   rs   rt   r<   r   rv   r3   r   r   r4   r!   rY     r   zParser._multipoint_text_c              	     r~   )Nc                     r   r"   )r   r   r   r4   r   r!   r     r   z(Parser._multicurve_text_.<locals>.block1rr   )r-   r.   rs   rt   r   r   rv   r3   r   r   r4   r!   r[     r   zParser._multicurve_text_c              	     r~   )Nc                     r   r"   )r   rD   r   r4   r   r!   r     r   z-Parser._multilinestring_text_.<locals>.block1rr   )r-   r.   rs   rt   rD   r   rv   r3   r   r   r4   r!   r^     r   zParser._multilinestring_text_c              	     r~   )Nc                     r   r"   )r   r   r   r4   r   r!   r   %  r   z*Parser._multisurface_text_.<locals>.block1rr   )r-   r.   rs   rt   r   r   rv   r3   r   r   r4   r!   r`     r   zParser._multisurface_text_c              	     r~   )Nc                     r   r"   r   rQ   r   r4   r   r!   r   6  r   z*Parser._multipolygon_text_.<locals>.block1rr   r-   r.   rs   rt   rQ   r   rv   r3   r   r   r4   r!   re   -  r   zParser._multipolygon_text_c              	     r~   )Nc                     r   r"   r   r   r4   r   r!   r   G  r   z/Parser._polyhedralsurface_text_.<locals>.block1rr   r   r   r   r4   r!   rg   >  r   zParser._polyhedralsurface_text_c              	     r~   )Nc                     r   r"   )r   rS   r   r4   r   r!   r   X  r   z!Parser._tin_text_.<locals>.block1rr   )r-   r.   rs   rt   rS   r   rv   r3   r   r   r4   r!   ri   O  r   zParser._tin_text_c              	     r~   )Nc                     r   r"   )r   r5   r   r4   r   r!   r   i  r   z0Parser._geometrycollection_text_.<locals>.block1rr   )r-   r.   rs   rt   r5   r   rv   r3   r   r   r4   r!   rk   `  r   z Parser._geometrycollection_text_c                 C     |  d d S )NEMPTYr9   r4   r   r   r!   rs   q     zParser._empty_set_c              	   C  s   |   Y |   | d W d    n1 sw   Y  |   | d W d    n1 s2w   Y  |   | d W d    n1 sKw   Y  | d W d    d S 1 s`w   Y  d S )NZMZMzexpecting one of: 'M' 'Z' 'ZM')r-   r.   r9   r3   r4   r   r   r!   r;   u  s   



"zParser._z_m_c                 C  r   )N(r   r4   r   r   r!   rt     r   zParser._left_paren_c                 C  r   )N)r   r4   r   r   r!   rv     r   zParser._right_paren_c                 C  r   )N,r   r4   r   r   r!   r     r   zParser._comma_c                 C  r   )Nz3[+-]?([0-9]+(\.[0-9]*)?|\.[0-9]+)([eE][+-]?[0-9]+)?)_patternr4   r   r   r!   r}     r   zParser._number_r"   r#   );r$   r%   r&   r   r	   r5   r/   r0   r?   r@   rA   r1   rJ   rN   rO   r2   rT   rU   r\   rV   ra   rb   rc   rW   rD   rM   rQ   rS   r<   ru   rx   ry   rz   r{   rl   rF   rH   r   r   r   r   rm   rn   ro   rY   r[   r^   r`   re   rg   ri   rk   rs   r;   rt   rv   r   r}   r'   r   r   r   r!   r   )   s    






















































r   c                   @  s  e Z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
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d#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dGdH Z&dIdJ Z'dKdL Z(dMdN Z)dOdP Z*dQdR Z+dSdT Z,dUdV Z-dWdX Z.dYdZ Z/d[d\ Z0d]d^ Z1d_d` Z2dadb Z3dcdd Z4dedf Z5dgdh Z6didj Z7dkS )l	Semanticsc                 C     |S r"   r   r   astr   r   r!   r(        zSemantics.wkt_representationc                 C  r   r"   r   r   r   r   r!   point_text_representation  r   z#Semantics.point_text_representationc                 C  r   r"   r   r   r   r   r!   curve_text_representation  r   z#Semantics.curve_text_representationc                 C  r   r"   r   r   r   r   r!   linestring_text_representation  r   z(Semantics.linestring_text_representationc                 C  r   r"   r   r   r   r   r!   "circularstring_text_representation  r   z,Semantics.circularstring_text_representationc                 C  r   r"   r   r   r   r   r!   !compoundcurve_text_representation  r   z+Semantics.compoundcurve_text_representationc                 C  r   r"   r   r   r   r   r!   surface_text_representation  r   z%Semantics.surface_text_representationc                 C  r   r"   r   r   r   r   r!    curvepolygon_text_representation  r   z*Semantics.curvepolygon_text_representationc                 C  r   r"   r   r   r   r   r!   polygon_text_representation  r   z%Semantics.polygon_text_representationc                 C  r   r"   r   r   r   r   r!   triangle_text_representation  r   z&Semantics.triangle_text_representationc                 C  r   r"   r   r   r   r   r!   collection_text_representation  r   z(Semantics.collection_text_representationc                 C  r   r"   r   r   r   r   r!   multipoint_text_representation  r   z(Semantics.multipoint_text_representationc                 C  r   r"   r   r   r   r   r!   multicurve_text_representation  r   z(Semantics.multicurve_text_representationc                 C  r   r"   r   r   r   r   r!   #multilinestring_text_representation  r   z-Semantics.multilinestring_text_representationc                 C  r   r"   r   r   r   r   r!    multisurface_text_representation  r   z*Semantics.multisurface_text_representationc                 C  r   r"   r   r   r   r   r!    multipolygon_text_representation  r   z*Semantics.multipolygon_text_representationc                 C  r   r"   r   r   r   r   r!   %polyhedralsurface_text_representation  r   z/Semantics.polyhedralsurface_text_representationc                 C  r   r"   r   r   r   r   r!   tin_text_representation  r   z!Semantics.tin_text_representationc                 C  r   r"   r   r   r   r   r!   &geometrycollection_text_representation  r   z0Semantics.geometrycollection_text_representationc                 C  r   r"   r   r   r   r   r!   linestring_text_body  r   zSemantics.linestring_text_bodyc                 C  r   r"   r   r   r   r   r!   curvepolygon_text_body  r   z Semantics.curvepolygon_text_bodyc                 C  r   r"   r   r   r   r   r!   polygon_text_body  r   zSemantics.polygon_text_bodyc                 C  r   r"   r   r   r   r   r!   triangle_text_body  r   zSemantics.triangle_text_bodyc                 C  r   r"   r   r   r   r   r!   
point_text  r   zSemantics.point_textc                 C  r   r"   r   r   r   r   r!   point  r   zSemantics.pointc                 C  r   r"   r   r   r   r   r!   x  r   zSemantics.xc                 C  r   r"   r   r   r   r   r!   y  r   zSemantics.yc                 C  r   r"   r   r   r   r   r!   z  r   zSemantics.zc                 C  r   r"   r   r   r   r   r!   m  r   zSemantics.mc                 C  r   r"   r   r   r   r   r!   linestring_text  r   zSemantics.linestring_textc                 C  r   r"   r   r   r   r   r!   circularstring_text  r   zSemantics.circularstring_textc                 C  r   r"   r   r   r   r   r!   compoundcurve_text  r   zSemantics.compoundcurve_textc                 C  r   r"   r   r   r   r   r!   single_curve_text  r   zSemantics.single_curve_textc                 C  r   r"   r   r   r   r   r!   
curve_text  r   zSemantics.curve_textc                 C  r   r"   r   r   r   r   r!   	ring_text  r   zSemantics.ring_textc                 C  r   r"   r   r   r   r   r!   surface_text  r   zSemantics.surface_textc                 C  r   r"   r   r   r   r   r!   curvepolygon_text  r   zSemantics.curvepolygon_textc                 C  r   r"   r   r   r   r   r!   polygon_text  r   zSemantics.polygon_textc                 C  r   r"   r   r   r   r   r!   triangle_text  r   zSemantics.triangle_textc                 C  r   r"   r   r   r   r   r!   multipoint_text  r   zSemantics.multipoint_textc                 C  r   r"   r   r   r   r   r!   multicurve_text
  r   zSemantics.multicurve_textc                 C  r   r"   r   r   r   r   r!   multilinestring_text  r   zSemantics.multilinestring_textc                 C  r   r"   r   r   r   r   r!   multisurface_text  r   zSemantics.multisurface_textc                 C  r   r"   r   r   r   r   r!   multipolygon_text  r   zSemantics.multipolygon_textc                 C  r   r"   r   r   r   r   r!   polyhedralsurface_text  r   z Semantics.polyhedralsurface_textc                 C  r   r"   r   r   r   r   r!   tin_text  r   zSemantics.tin_textc                 C  r   r"   r   r   r   r   r!   geometrycollection_text  r   z!Semantics.geometrycollection_textc                 C  r   r"   r   r   r   r   r!   	empty_set  r   zSemantics.empty_setc                 C  r   r"   r   r   r   r   r!   z_m"  r   zSemantics.z_mc                 C  r   r"   r   r   r   r   r!   
left_paren%  r   zSemantics.left_parenc                 C  r   r"   r   r   r   r   r!   right_paren(  r   zSemantics.right_parenc                 C  r   r"   r   r   r   r   r!   comma+  r   zSemantics.commac                 C  r   r"   r   r   r   r   r!   number.  r   zSemantics.numberN)8r$   r%   r&   r(   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r!   r     sl    r   c                 K  sd   | r| dkrt j }nt| }| }W d    n1 sw   Y  t }|j|fd| i|S )N-filename)sysstdinreadopenr   parse)r   kwargsr   fparserr   r   r!   main2  s   

r   __main__)asjsonr   )name   )indent)
__future__r   r   tatsu.bufferingr   tatsu.infosr   tatsu.parsingr   r   r   r   r	   
tatsu.utilr
   r   r+   r   r   r$   jsonr   r   dataprintdumpsr   r   r   r!   <module>   s.       l "
