Ë ›-øÕãóX—dZddlZddlZddlmZddlmZddlm Z m Z ddl m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZed«ZGd„d e«Z d e!d e!fd „Z"Gd „d«Z#edd¬«Z$Gd„dee$«Z%Gd„de«Z&ede%e d¬«Z'Gd„dee'e&¬«Z(y)zT This module contains base classes and helper functions for defining Pratt parsers. éN)ÚABCMeta)Úname)ÚDecimalÚDecimalException)ÚAnyÚcastÚoverloadÚCallableÚDictÚGenericÚListÚOptionalÚUnionÚTupleÚTypeÚPatternÚMatchÚMutableMappingÚMutableSequenceÚIteratorÚTypeVar) ú(start)ú(end)ú(string)ú(float)ú (decimal)ú (integer)ú(name)ú (invalid)ú (unknown)có—eZdZdZy)Ú ParseErrorz.An error when parsing source with TDOP parser.N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©óú5/usr/lib/python3.12/site-packages/elementpath/tdop.pyr"r"1s„Ú8r(r"ÚsymbolÚreturnc󊇗dtdtfd„Š|j«r|j«S|tvr|ddj«St d„|D««rXdj d„|D««}|j«j dd «j d d «j d d «S|j d d «}|j«r |j«j d d «Sd j ˆfd „|D««}|j dd «j d d «j d d «S) zP Converts a symbol string to an identifier (only alphanumeric and '_'). Úcr+cóz—|j«s|dk(r|Sdtt|««j«zS)NÚ_z%s_)ÚisalnumÚ unicode_nameÚstrÚtitle)r-s r)Ú get_id_namez)_symbol_to_classname..get_id_name9s3€Ø �9‰9Œ;˜!˜sš(؈Hàœ<¬¨A«Ó/×5Ñ5Ó7Ñ7Ð 7r(ééÿÿÿÿc3ó$K—|]}|dv–—Œ y­w)z-_Nr'©Ú.0r-s r)Ú z'_symbol_to_classname..Csèø€Ð '¡˜1ˆQ�$ŒY¡ùs‚Ú c3ó2K—|]}t|«–—Œy­w©N)r1r8s r)r:z'_symbol_to_classname..Dsèø€Ð9±&¨Qœ aŸ±&ùs‚ÚÚ-r/c3ó.•K—|] }‰|«–—Œy­wr=r')r9r-r4s €r)r:z'_symbol_to_classname..Ksøèø€Ð3©F q‘K —N©Fùsƒ)r2r0r3ÚSPECIAL_SYMBOLSÚallÚjoinÚreplaceÚ isidentifier)r*Úvaluer4s @r)Ú_symbol_to_classnamerG5sø€ð8”sð8œsó8ð ‡~�~ÔØ�|‰|‹~ÐØ ”?Ñ "Ø�a˜ˆ|×!Ñ!Ó#Ð#Ü Ñ '¡Ó 'Ô 'Ø—‘Ñ9±&Ó9Ó9ˆØ�{‰{‹}×$Ñ$ S¨"Ó-×5Ñ5°c¸2Ó>×FÑFÀsÈBÓOÐOà �N‰N˜3 Ó $€EØ ×ÑÔØ�{‰{‹}×$Ñ$ S¨"Ó-Ð-à �G‰GÓ3©FÓ3Ó 3€EØ �=‰=˜˜bÓ !× )Ñ )¨#¨rÓ 2× :Ñ :¸3ÀÓ CÐCr(có”—eZdZdZdeddfd„Zdedefd„Zdedefd„Z defd „Z defd „Z de fd „Z d edefd „Zdedefd„Zdedefd„Zy)Ú MultiLabelaV Helper class for defining multi-value label for tokens. Useful when a symbol has more roles. A label of this type has equivalence with each of its values. Example: label = MultiLabel('function', 'operator') label == 'symbol' # False label == 'function' # True label == 'operator' # True Úvaluesr+Ncó—||_yr=)rJ)ÚselfrJs r)Ú__init__zMultiLabel.__init__Zs €Øˆ� r(Úothercó@‡—tˆfd„|jD««S)Nc3ó(•K—|] }‰|k(–—Œ y­wr=r'©r9ÚvrNs €r)r:z$MultiLabel.__eq__..^óøèø€Ð3¡{ !�5˜A•:¡{ùóƒ©ÚanyrJ©rLrNs `r)Ú__eq__zMultiLabel.__eq__]óø€ÜÓ3 t§{¢{Ó3Ó3Ð3r(có@‡—tˆfd„|jD««S)Nc3ó(•K—|] }‰|k7–—Œ y­wr=r'rQs €r)r:z$MultiLabel.__ne__..arSrT)rBrJrWs `r)Ú__ne__zMultiLabel.__ne__`rYr(cóJ—|jj›|j›�Sr=)Ú __class__r#rJ©rLs r)Ú__repr__zMultiLabel.__repr__cs€ØŸ™×0Ò0°$·+²+Ð>Ð>r(cóX—dj|j«jdd«S)NÚ__r;r/)rCrJrDr_s r)Ú__str__zMultiLabel.__str__fs"€Ø�y‰y˜Ÿ™Ó%×-Ñ-¨c°3Ó7Ð7r(có,—t|j«Sr=)ÚhashrJr_s r)Ú__hash__zMultiLabel.__hash__is€Ü�D—K‘KÓ Ð r(Úitemcó@‡—tˆfd„|jD««S)Nc3ó&•K—|]}‰|v–—Œ y­wr=r')r9rRrgs €r)r:z*MultiLabel.__contains__..msøèø€Ð2¡k �4˜1”9¡kùsƒrU)rLrgs `r)Ú __contains__zMultiLabel.__contains__lsø€ÜÓ2 d§k¢kÓ2Ó2Ð2r(Úscó@‡—tˆfd„|jD««S)Nc3ó@•K—|]}|j‰«–—Œy­wr=)Ú startswith©r9rRrks €r)r:z(MultiLabel.startswith..psøèø€Ð8©K q�1—<‘< —?©KùóƒrU©rLrks `r)rnzMultiLabel.startswithosø€ÜÓ8¨D¯KªKÓ8Ó8Ð8r(có@‡—tˆfd„|jD««S)Nc3ó@•K—|]}|j‰«–—Œy­wr=)Úendswithros €r)r:z&MultiLabel.endswith..ssøèø€Ð6©+ Q�1—:‘:˜a—=©+ùrprUrqs `r)rtzMultiLabel.endswithrsø€ÜÓ6¨$¯+ª+Ó6Ó6Ð6r()r#r$r%r&r2rMÚobjectÚboolrXr\r`rcÚintrfrjrnrtr'r(r)rIrIOs�„ñ ð ð¨óð4˜Fð4 tó4ð4˜Fð4 tó4ð?˜#ó?ð8˜ó8ð!˜#ó!ð3 ð3¨ó3ð9˜Cð9 Dó9ð7˜#ð7 $ô7r(rIÚTKz Token[Any])Úboundcó—eZdZUdZdZeed<dZeed<dZe ed<dZ e ed<dZ e ed<d Z e e ed <d Zeeed <d ed<e eed<eeefed< d:dd de edd fd„Zededefd„«Zededeefd„«Zdeeefdeeeeffd„Zdeeefdedd fd„Zdeeefdd fd„Zdefd„Zdededd fd„Zde fd„Zde fd„Zd ede fd!„Z!e"defd"„«Z#e"de fd#„«Z$e"de fd$„«Z%e"deeeffd%„«Z&d;d'„Z'de fd(„Z(de fd)„Z)dd4e de6fd9„Z7y )?ÚTokena Token base class for defining a parser based on Pratt's method. Each token instance is a list-like object. The number of token's items is the arity of the represented operator, where token's items are the operands. Nullary operators are used for symbols, names and literals. Tokens with items represent the other operators (unary, binary and so on). Each token class has a *symbol*, a lbp (left binding power) value and a rbp (right binding power) value, that are used in the sense described by the Pratt's method. This implementation of Pratt tokens includes two extra attributes, *pattern* and *label*, that can be used to simplify the parsing of symbols in a concrete parser. :param parser: The parser instance that creates the token instance. :param value: The token value. If not provided defaults to token symbol. :cvar symbol: the symbol of the token class. :cvar lbp: Pratt's left binding power, defaults to 0. :cvar rbp: Pratt's right binding power, defaults to 0. :cvar pattern: the regex pattern used for the token class. Defaults to the escaped symbol. Can be customized to match more detailed conditions (e.g. a function with its left round bracket), in order to simplify the related code. :cvar label: defines the typology of the token class. Its value is used in representations of the token instance and can be used to restrict code choices without more complicated analysis. The label value can be set as needed by the parser implementation (eg. 'function', 'axis', 'constructor function' are used by the XPath parsers). In the base parser class defaults to 'symbol' with 'literal' and 'operator' as possible alternatives. If set by a tuple of values the token class label is transformed to a multi-value label, that means the token class can covers multiple roles (e.g. as XPath function or axis). In those cases the definitive role is defined at parse time (nud and/or led methods) after the token instance creation. rÚlbpÚrbpr>r*Ú lookup_nameÚlabelNÚpattern)Ú_itemsÚparserrFÚspanr�zParser[Token[TK]]r‚rFrƒr+có°—g|_||_|�|n |j|_|j€d|_y|jj «|_y)N)rr)r�r‚r*rFÚ next_matchrƒ)rLr‚rFs r)rMzToken.__init__©sI€àˆŒ ؈Œ Ø#Ð/‘U°T·[±[ˆŒ Ø$×/Ñ/Ð7�Fˆ� ¸V×=NÑ=N×=SÑ=SÓ=Uˆ� r(Úicó—yr=r'©rLr†s r)Ú __getitem__zToken.__getitem__°s€Ø),r(rkcó—yr=r'rqs r)r‰zToken.__getitem__³s€Ø©r^r#Úidr_s r)r`zToken.__repr__Ìó €Ø# t§~¡~×'>Ñ'>ÄÀ4ÃÐ&IÑIÐIr(rNcóŒ—t|t«r4|j|jk(xr|j|jk(Sy)NF)Ú isinstancer{r*rFrWs r)rXz Token.__eq__Ïs4€Ü �eœUÔ #Ø—;‘; %§,¡,Ñ.ÒL°4·:±:ÀÇÁÑ3LÐ LØr(có—t|«Sr=©r“r_s r)Úarityz Token.arityÔs €ä�4‹yÐr(có„—|jdk(rd|jzS|jtvrd|jzS|jdk(r9t|«dk(r|djSddj d„|D««›d �S|sd|jzSd|j›ddj d „|D««›d �S) z%Returns a tree representation string.rz(%s)z(%r)Ú(r5rr;c3ó4K—|]}|j–—Œy­wr=©Útree©r9rgs r)r:zToken.tree..âsèø€Ð;±d¨d § ¥ ±dùó‚Ú)c3ó4K—|]}|j–—Œy­wr=r¥r§s r)r:zToken.tree..æsèø€Ð-IÁD¸D¨d¯i­iÁDùr¨)r*rFrAr“r¦rCr_s r)r¦z Token.treeØs¹€ð �;‰;˜(Ò "ؘDŸJ™JÑ&Ð &Ø �[‰[œOÑ +ؘDŸJ™JÑ&Ð &Ø �[‰[˜CÒ Ü�4‹y˜AŠ~ؘA‘w—|‘|Ð#Ø�s—x‘xÑ;±dÓ;Ó;Ð<¸AÐ>Ð >ÙØ˜DŸK™KÑ'Ð 'à�t—{‘{�m 1 S§X¡XÑ-IÁDÓ-IÓ%IÐ$JÈ!ÐLÐ Lr(có—|j}|dk(rtt|j«S|dk(rt|j«S|tvr%t |j«j dd«St|«}|s|S|dk(r6d|jvr|dj›d|›�S|›d|dj›�S|d k(r$|dj›d|›d|dj›�S|›ddjd „|D««›�S) z)Returns the source representation string.rrz\\Ú\r5Úpostfixrr;éc3ó4K—|]}|j–—Œy­wr=)Úsourcer§s r)r:zToken.source..ýsèø€Ð2PÉ4À4°4·;µ;É4ùr¨) r*rr2rFrAÚreprrDr“rr°rC)rLr*Úlengths r)r°z Token.sourceèsè€ð—‘ˆØ �XÒ Üœ˜TŸZ™ZÓ(Ð (Ø �{Ò "Ü�t—z‘z“?Ð "Ø ”Ñ &ܘŸ ™ Ó#×+Ñ+¨E°4Ó8Ð 8䘓YˆFÙØ� ؘ1’Ø § ¡ Ñ*Ø&*¨1¡g§n£n±fÐ=Ð=Ú"(¨$¨q©'¯.ª.Ð9Ð9ؘ1’Ø%)¨!¡W§^£^²V¸TÀ!¹W¿^º^ÐLÐLâ"(¨#¯(©(Ñ2PÉ4Ó2PÔ*PÐQÐQr(cóè—|jd}|jjd|jd«dz}|dk(rd|dzfS|||jjd|j d«z fS)zCA tuple with the position of the token in terms of line and column.rNÚ r5)rƒr‚r°ÚcountÚrindex)rLÚ token_indexÚlines r)ÚpositionzToken.positionÿsy€ð—i‘i ‘lˆ Ø�{‰{×!Ñ! , ;Ð/×5Ñ5°dÓ;¸aÑ?ˆØ �1Š9Ø�k A‘oÐ%Ð %Ø�[ 4§;¡;×#5Ñ#5°l°{Ð#C×#JÑ#JÈ4Ó#PÑPÐPÐPr(ú Token[TK]cóü—|jjj|j«€Jd«‚|jjd|j|j«}|j |_|S)zØ$š Ø!�Fà—y’yÙ" b§i¡i°7Ñ&:Ø šØÐ)Ù&¨&¯-©-¸7Ñ*BØ"(šLØ!%˜ØØ— ‘ ˜v xÐ0Ô1Ø#%¤t¨B£x˜�Ùð!ð$ &Ø'-§z¡z£|Ñ$�F˜HðÐ)Ù&¨&¯-©-¸7Ñ*BØ"(šLØ!%™ð=øô*"òØÐ)Ù&¨&¯-©-¸7Ñ*BØ"(šLÙð üs*‚B"C7Â%CÂ8C7ÃC4Ã1C7Ã3C4Ã4C7©ÚmessageråcóH—|r |j|vr|j|«‚yyr=©r*rÑ©rLrårÛs r)ÚexpectedzToken.expectedhs(€Ù �t—{‘{¨'Ñ1Ø×#Ñ# GÓ,Ð ,ð2ˆ7r(cóF—|r|j|vr|j|«‚yr=rçrès r)Ú unexpectedzToken.unexpectedls&€Ù˜$Ÿ+™+¨Ñ0Ø×#Ñ# GÓ,Ð ,ð1r(có—|r t|«S|jtvrtd|z«S|jdk(rtd|jz«S|jdk(rtd|jz«S|jdk(rtd|jz«S|jdk7rtd |jz«S|jj jd k(r td «Std «S) Nz unexpected %srzinvalid literal %rr zunknown symbol %rrzunexpected name %rrzunexpected literal %rrzsource is emptyzunexpected end of source)r"r*rArFr‚r¿©rLrås r)rÑzToken.wrong_syntaxpsà€Ù ܘgÓ&Ð &Ø �[‰[¤Ñ /ܘo°Ñ4Ó5Ð 5Ø �[‰[˜KÒ 'ÜÐ2°T·Z±ZÑ?Ó@Ð @Ø �[‰[˜KÒ 'ÜÐ1°D·J±JÑ>Ó?Ð ?Ø �[‰[˜HÒ $ÜÐ2°T·Z±ZÑ?Ó@Ð @Ø �[‰[˜GÒ #ÜÐ5¸¿ ¹ ÑBÓCÐ CØ �[‰[× Ñ × %Ñ %¨Ò 2ÜÐ/Ó0Ð 0äÐ8Ó9Ð 9r(có—t|«Sr=)Ú TypeErrorrís r)Ú wrong_typezToken.wrong_type‚s €Ü˜Ó!Ð!r(có—t|«Sr=)rÅrís r)Ú wrong_valuezToken.wrong_value…s €Ü˜'Ó"Ð"r(r=)r+rº©TT)z invalid type)z invalid value)8r#r$r%r&r|rwÚ__annotations__r}r*r2r~rr€rÚ __slots__r rxrrrMr r‰Úslicerrr�r‘r”r–rcr`rurvrXÚpropertyr¡r¦r°r¹rÀrÃrÇrÎrÒr×rÚrrÝrérër"rÑrïrðrÅròr'r(r)r{r{ys…ñ ðB€CˆƒLØ€CˆƒLØ€FˆCÓØ€K�ÓØ€Eˆ3ÓØ!€GˆX�c‰]Ó!à3€Ià �‰HÓØ ÓØ �C‰=ÓØ ��S�‰/Óð)-ñVÐ2ðVØ  ™ ðVØ15óVðØ,˜SÐ, RÒ,óØ,à Ø?˜UÐ? °rÑ':Ò?óØ?ð˜U 3¨ :Ñ.ðØ�R˜¨Ñ,Ð,Ñ-óð˜U 3¨ :Ñ.ð°3ð¸4óð˜U 3¨ :Ñ.ð°4óð ˜ó ð$˜ð$ 2ð$¨$ó$ð<˜ó<ð J˜#óJð˜Fð tóð ð�sòóððð M�cò Móð MððR˜òRóðRð,ðQ˜%  S ™/òQóðQóðD óDð P˜tó Pñ ð°DðÀDóð "�Ró"ð"˜ð"˜ró"ð˜#óð%&˜Sð%& X¨kÑ%:ó%&ðN@Dò- ð-¨x¸©}ð-Èó-ðBFò- 3ð-°¸#±ð-È$ó-ñ: H¨S¡Mð:¸Zó:ñ$" #ð"¸9ó"ñ# 3ð#¸Zô#r(r{c󬇗eZdZUeeed<eeed<eeed<eeeed<e eeefed<dede eedfd e eefd dfˆfd „ Z ˆxZ S) Ú ParserMetaÚtoken_base_classÚliterals_patternr¼Ú tokenizerr¾rÚbases.Ú namespacer+c󀕗tt|� ||||«}tj|j j j«D]:\}}t|t«sŒ|j |j k(sŒ1td«‚t|d«s t|_ t|d«stjd«|_t|d«stjd«|_d|vrd|_d|vrBi|_|D]6}t|d«sŒ|j$j'|j$«|S|S) NzÑ>Ö@‰DˆAˆqܘ!œZÕ(¨Q¯\©\¸S¿^¹^Ó-KÜ"Ð#aÓbÐbðAô �sÐ.Ô/Ü#(ˆCÔ Ü�sÐ.Ô/Ü#%§:¡:ØOó$ˆCÔ ô�s˜NÔ+Ü!Ÿz™zÐ*:Ó;ˆCÔ Ø ˜iÑ 'Ø ˆCŒMØ  Ñ *Ø!ˆCÔ Û#� ܘ: ~Õ6Ø×$Ñ$×+Ñ+¨J×,CÑ,CÔDØØˆ ð $ðˆ r()r#r$r%rrrôrr2rrrr rÚ __classcell__)r^s@r)rùrù‰s€ø…à˜3‘iÓØ˜c‘lÓ"ؘ#‘,ÓØ˜ ™ Ñ%Ó%Ø   d¨3¡i Ñ0Ó0ð˜3ð u¨T°#©Y¸¨^Ñ'<ðÈÈcÐSVÈhÉðØ÷ñr(rùÚTK_coT)ryÚ covariantc óœ—eZdZUdZeZdZeee e d<iZ e e e efe d<ee d<e e d<eee e d<ee d<ee d <eee e d <ee e d <ee e d <d Zd6d„Zde fd„Zde fd„Zdedefd„Zde defd„Zddœde dee defd„Zde de fd„Zd7dedefd„Zedeeeffd„«Zdefd„Z defd„Z!d8d ed!edefd"„Z"e#d#e de fd$„«Z$e%d%e&e e efd&e'de efd'„«Z(e%d%e ddfd(„«Z)e%d%e d)e d&e'de efd*„«Z*e%d7d%e d+ede efd,„«Z+e%d7d%e d+ede efd-„«Z,e%d7d%e d+ede efd.„«Z-e%d7d%e d+ede efd/„«Z.e%d7d%e d+ede efd0„«Z/e%d7d%e d+ede efd1„«Z0e%d7d%e&e e efd+ede1e1d2e'fge1d2e'fffd3„«Z2e%d6d4„«Z3e%de4e e efdee fd5„«Z5y)9ÚParsera; Parser class for implementing a Top-Down Operator Precedence parser. :cvar symbol_table: a dictionary that stores the token classes defined for the language. :cvar token_base_class: the base class for creating language's token classes. :cvar tokenizer: the language tokenizer compiled regexp. Nrür¾Ú _start_tokenr°Útokensr¿Ú next_tokenr…rûr¼)r°rr…rr¿rr+cóÜ—|j€|j«d|_td«|_d|_|j d|«|_|jx|_|_ y)Nr>r'r) rüÚbuildr°rÝrr…r¾rr¿rr_s r)rMzParser.__init__Ès\€Ø �>‰>Ð !Ø �J‰JŒL؈Œ ܘ2“hˆŒ ؈ŒØ8˜D×-Ñ-¨iÑ8¸Ó>ˆÔØ'+×'8Ñ'8Ð8ˆŒ �T•_r(cóJ—d|jjt|«fzSr™ršr_s r)r`zParser.__repr__Ñrœr(có4—|jj›d�S)Nz())r^r#r_s r)rczParser.__str__Ôs€Ø—.‘.×)Ñ)Ð*¨"Ð-Ð-r(rNcóŒ—t|t«xr3|j|juxr|j|jk(Sr=)ržrrúr¾rWs r)rXz Parser.__eq__×sC€Ü˜%¤Ó(ò4Ø × !Ñ ! U×%;Ñ%;Ð ;ò4à × Ñ  ×!3Ñ!3Ñ 3ð 4r(cóZ—|jsJd«‚ t|jj|««|_||_|j«|j«}|jjd«|td«|_d|_ |jx|_|_ S#t$r;}|j d||«}|j dj|««‚d}~wwxYw#td«|_d|_ |jx|_|_ wxYw)zý Parses a source code of the formal language. This is the main method that has to be called for a parser's instance. :param source: The source string. :return: The root of the token's tree that parse the source. zParser tokenizer is not built!rzinvalid source type, {}Nrr')rürÝÚfinditerrrïr¾rÑÚformatr°ÚadvanceÚ expressionrrér…rr¿)rLr°Úerrr¿Ú root_tokens r)Úparsez Parser.parseÜs€ð�~Š~Ð?Ð?Ó?ˆ~ð =ð PÜ" 4§>¡>×#:Ñ#:¸6Ó#BÓC�” ð !ˆDŒKØ �L‰LŒNØŸ™Ó*ˆJØ �O‰O× $Ñ $ WÔ -Øä˜r›(ˆDŒKØ"ˆDŒOØ+/×+<Ñ+<Ð <ˆDŒJ˜�øôò PØ6˜×)Ñ)¨+Ñ6°t¸VÓD�Ø×(Ñ(Ð)B×)IÑ)IÈ#Ó)NÓOÐOûð Pûô˜r›(ˆDŒKØ"ˆDŒOØ+/×+<Ñ+<Ð <ˆDŒJ˜�ús)–)B2¿AC9Â2 C6Â;6C1Ã1C6Ã6C9Ã91D*rärÛråcót—|jjdk(r|jj«‚|r3|jj|vr|jj|«‚|j|_|jD]?|_|j €J‚|j j «j«rŒ?n'|jd|«|_|jS|j j«\}}}}|�' |j||«|_|jS|�á|ddvr8|j|«}|jd||«|_|jSd|vsd |vr3 t|«}|jd ||«|_|jSd |vr3 t#|«}|jd||«|_|jS|jd|t'|««|_|jS|�'|jd||«|_|jS|�'|jd||«|_|jSd} t)| |j j «z«‚#t$ry|jj|«€5|jd||«|_|jj«‚|jd||«|_Y|jSwxYw#t$rE}|jd ||«|_|jjt!|«¬ «‚d}~wwxYw#t$$rE}|jd ||«|_|jjt!|«¬ «‚d}~wwxYw)au The Pratt's function for advancing to next token. :param symbols: Optional arguments tuple. If not empty one of the provided symbols is expected. If the next token's symbol differs the parser raises a parse error. :param message: Optional custom message for unexpected symbols. :return: The current token instance. rNr rrz'"rÚeÚErrräÚ.rrz.unexpected matching %r: incompatible tokenizer)rr*rÑr¿rr…ÚgroupÚisspacer¾ÚgroupsÚKeyErrorr¼r½ÚunescapeÚfloatrÅr2rrrwr) rLrårÛÚliteralr*rÚunknownrFr!Úmsgs r)rzParser.advanceös¥€ð �?‰?× !Ñ ! WÒ ,Ø—/‘/×.Ñ.Ó0Ð 0Ù ˜Ÿ™×/Ñ/°wÑ>Ø—/‘/×.Ñ.¨wÓ7Ð 7à—_‘_ˆŒ à#Ÿ{œ{ˆDŒOØ—?‘?Ð.Ð .Ð.Ø—?‘?×(Ñ(Ó*×2Ñ2Õ4Ùð +ð 9˜d×/Ñ/°Ñ8¸Ó>ˆDŒOØ—:‘:Ð à)-¯©×)?Ñ)?Ó)AÑ&ˆ�˜˜wØ Ð ð LØ"; $×"3Ñ"3°FÑ";¸DÓ"A�”ðH�z‰zÐð=Ð Ø�q‰z˜UÑ"ØŸ ™  gÓ.�Ø"? $×"3Ñ"3°JÑ"?ÀÀeÓ"L�”ð6�z‰zÐð5˜‘ 3¨'¡>ðPÜ! '›N�Eð 'C d×&7Ñ&7¸ Ñ&BÀ4ÈÓ&O�D”Oð&�z‰zÐð%˜‘ðRÜ# GÓ,�Eð 'E d×&7Ñ&7¸ Ñ&DÀTÈ5Ó&Q�D”Oð�z‰zÐð#A $×"3Ñ"3°KÑ"@ÀÄsÈ7Ã|Ó"T�”ð�z‰zÐðÐ Ø9˜d×/Ñ/°Ñ9¸$ÀÓEˆDŒOð�z‰zÐð Ð Ø<˜d×/Ñ/° Ñ<¸TÀ7ÓKˆDŒOð �z‰zÐðCˆCܘs T§_¡_×%:Ñ%:Ó%<Ñ<Ó=Ð =øôCò LØ×$Ñ$×*Ñ*¨6Ó2Ð:Ø&D d×&7Ñ&7¸ Ñ&DÀTÈ6Ó&R�D”OØŸ/™/×6Ñ6Ó8Ð8Ø"= $×"3Ñ"3°HÑ"=¸dÀFÓ"K�•ð>�z‰zÐðG Lûô"òIØ&D d×&7Ñ&7¸ Ñ&DÀTÈ7Ó&S�D”OØŸ/™/×6Ñ6¼sÀ3»xÐ6ÓHÐHûðIûô(òIØ&D d×&7Ñ&7¸ Ñ&DÀTÈ7Ó&S�D”OØŸ/™/×6Ñ6¼sÀ3»xÐ6ÓHÐHûðIúsEÄJÆ LÆ7 M)ÊA4LÌLÌ M&Ì!AM!Í!M&Í) N7Í2AN2Î2N7Ú stop_symbolscó —|s|jjd«‚|jjdk(r|jj«‚|j|_g} t |j «|_|jjd«}|�B|j«}||vr|j|«nF |j||«|_n+|j|jj«« Œ¥dj|«S#t$r5|jd|«|_|jj«‚wxYw#t$r|jd|«|_YŒwwxYw)a¹ Advances until one of the symbols is found or the end of source is reached, returning the raw source string placed before. Useful for raw parsing of comments and references enclosed between specific symbols. :param stop_symbols: The symbols that have to be found for stopping advance. :return: The source string chunk enclosed between the initial position and the first stop symbol. z at least a stop symbol required!rr®r r>)rrðr*rÑr¿Únextrr…r(rÂrÞr¾r+Ú StopIterationrC)rLr1Ú source_chunkr*s r)Ú advance_untilzParser.advance_until9sh€ñØ—/‘/×,Ñ,Ð-OÓPÐ PØ �_‰_× #Ñ # wÒ .Ø—/‘/×.Ñ.Ó0Ð 0à—_‘_ˆŒ Ø"$ˆ Øð AÜ"& t§{¡{Ó"3�”ð Ÿ™×.Ñ.¨qÓ1�ØÐ%Ø#Ÿ\™\›^�FØ \Ñ1Ø$×+Ñ+¨FÕ3ðAØ.G¨d×.?Ñ.?ÀÑ.GÈÓ.M˜DœOØ!ð !×'Ñ'¨¯©×(=Ñ(=Ó(?Õ@ð)ð*�w‰w�|Ó$Ð$øô (òAØ.L¨d×.?Ñ.?À Ñ.LÈTÓ.R˜DœOØ"&§/¡/×">Ñ">Ó"@Ð@ðAûô!ò Ø"< $×"3Ñ"3°GÑ"<¸TÓ"B�”Ùð úsÁ&EÃDÄ>EÅ#FÆFr}có2—|j«|jj«}||jjkrE|j«|jj |«}||jjkrŒEt t|«S)aP Pratt's function for parsing an expression. It calls token.nud() and then advances until the right binding power is less the left binding power of the next token, invoking the led() method on the following token. :param rbp: right binding power for the expression. :return: left token. )rr¿rÒrr|r×rr)rLr}rÔs r)r zParser.expressionasm€ð � ‰ ŒØ�z‰z�~‰~ÓˆØ�D—O‘O×'Ñ'Ò'Ø �L‰LŒNØ—:‘:—>‘> $Ó'ˆDð�D—O‘O×'Ñ'Ó'ô”E˜4Ó Ð r(có.—|jjS)z:Property that returns the current line and column indexes.)r¿r¹r_s r)r¹zParser.positionqs€ð�z‰z×"Ñ"Ð"r(có6—|jj«S)zu Returns `True` if the parser is positioned at the start of the source, ignoring the spaces. )r¿rÃr_s r)rÃzParser.is_source_startvs€ð �z‰z×)Ñ)Ó+Ð+r(có6—|jj«S)zx Returns `True` if the parser is positioned at the start of a source line, ignoring the spaces. )r¿rÇr_s r)rÇzParser.is_line_start}s€ð �z‰z×'Ñ'Ó)Ð)r(rÈrÉcó:—|jj||«S)ay Returns `True` if the source has an extra space (whitespace, tab or newline) immediately before or after the current position of the parser. :param before: if `True` considers also the extra spaces before the current token symbol. :param after: if `True` considers also the extra spaces after the current token symbol. )r¿rÎ)rLrÈrÉs r)rÎzParser.is_spaced„s€ð�z‰z×#Ñ# F¨EÓ2Ð2r(Ústring_literalcóL—|ddjdd«jdd«S)Nr5r6z\'Ú'z\"Ú")rD)r<s r)r,zParser.unescape�s)€à˜a Ð#×+Ñ+¨E°3Ó7×?Ñ?ÀÀsÓKÐKr(r*Úkwargsc óÔ—t|t«r5d|vrtd|z«‚|jd|«} |j|}nmt|t2«rt5|t6«st9d t6›d |›d�«‚|}|jj|j:«|urtd|z«‚|j=«D]V\}} |dk(r| |j>kDr| |_Œ"|dk(r| |j@kDr| |_ Œ>tC| «sŒJt-||| «ŒX|S#t $�r?||d<||d<|jdd«}t|t «r t|Žx}|d<d|vr|jd«}nBdjt|«t|«j«jdd««}|jd |jf«}|j|j|d d œ«t!t"t$t'|||««}||j|<t)j*|«t-t.j0|j||«Y�Œ³wxYw)a Register/update a token class in the symbol table. :param symbol: The identifier symbol for a new class or an existent token class. :param kwargs: Optional attributes/methods for the token class. :return: A token class. r;z&%r: a symbol can't contain whitespacesr~r*rÚ class_namez_{}{}r>rýN)r$r%Ú __return__zA string or a z subclass requested, not r'z!Token class %r is not registered.r|r})"ržr2rÅÚgetr¾r+ÚtuplerIrßrrGr3rDrúr r$rrrrrÚregisterÚsetattrrrÚtypeÚ issubclassr{rïr~rr|r}Úcallable) r r*r@r~Ú token_classrÚtoken_class_nameÚtoken_class_basesÚkeyrFs r)rFzParser.register”s?€ô �fœcÔ "Ø�f‰}Ü Ð!IÈFÑ!RÓSÐSà Ÿ*™* ]°FÓ;ˆKð TØ!×.Ñ.¨{Ñ;‘ ô@˜F¤DÔ)´¸FÄEÔ1JÝÎeÒU[Ð\Ó]Ð ]à ˆKØ×Ñ×#Ñ# F×$6Ñ$6Ó7¸{ÑJÜ Ð!DÀ{Ñ!RÓSÐSà Ÿ,™,ž.‰JˆC�Ø�eŠ| ¨ ¯©Ò 7Ø"'� •ؘ’ %¨+¯/©/Ò"9Ø"'� •ܘ%•ܘ  S¨%Õ0ð )ðÐøô]ó Tð$*��xÑ Ø(3��}Ñ%ØŸ ™  7¨HÓ5�ܘe¤UÔ+Ü.8¸%Ð.@Ð@�E˜F 7™Oà 6Ñ)Ø'-§z¡z°,Ó'?Ñ$à'.§~¡~Ü,¨VÓ4ܘE› ×(Ñ(Ó*×2Ñ2°3¸Ó;ó(Ð$ð %+§J¡J¨w¸×9MÑ9MÐ8OÓ$PÐ!Ø— ‘ Ø"%§.¡.Ø$4Ø"&ñôô #Üœ‘K¤Ð)9Ð;LÈfÓ!Uó� ð1<�× Ñ  Ñ-Ü×(Ñ(¨Ô5ÜœŸ ™  C§N¡NÑ3Ð5EÀ{×Sð; Tús¶DÄEI'É&I'có:—|j|j«=y)z/Unregister a token class from the symbol table.N)r¾rÂ)r r*s r)Ú unregisterzParser.unregisterÖs€ð × Ñ ˜VŸ\™\›^Ñ ,r(Ú new_symbolc óÜ—|j|}|j|fi|¤Ž}|jj«D],\}}||vs|dvs|j d«rŒ t |||«Œ.|S)z*Duplicate a token class with a new symbol.)r*r€r/)r¾rFrrrnrG)r r*rQr@rKÚnew_token_classrNrFs r)Ú duplicatezParser.duplicateÛsw€ð×&Ñ& vÑ.ˆ Ø&˜#Ÿ,™, zÑ<°VÑ<ˆØ%×.Ñ.×4Ñ4Ö6‰JˆC�Ø�f‰} Ð'<Ñ <ÀÇÁÈsÔ@SØÜ �O S¨%Õ 0ð7ðÐr(Úbpcó°—dttdttfd„}dttdtdtdtfd„}|j|d|||¬«S) z:Register a token for a symbol that represents a *literal*.rLr+có—|Sr=r'r_s r)rÒzParser.literal..nudéó€ØˆKr(Ú_argsÚ_kwargscó—|jSr=rÙ)rLrYrZs r)rÚz Parser.literal..evaluateìs €Ø—:‘:Ð r(r.)rr|rÚrÒ)r{rrrF)r r*rUrÒrÚs r)r.zParser.literalæs^€ð ”eœE‘lð ¤u¬U¡|ó ð œ5¤™<ð ´ð Äð Ìó ð�|‰|˜F¨)¸ÀhÐTWˆ|ÓXÐXr(cóh—dttdttfd„}|j|d||¬«S)zCRegister a token for a symbol that represents a *nullary* operator.rLr+có—|Sr=r'r_s r)rÒzParser.nullary..nudôrXr(Úoperator)rr|rÒ©r{rrF©r r*rUrÒs r)ÚnullaryzParser.nullaryñs4€ð ”eœE‘lð ¤u¬U¡|ó à�|‰|˜F¨*¸"À#ˆ|ÓFÐFr(cóp‡—dttdttfˆfd„ }|j|d‰‰|¬«S)zHRegister a token for a symbol that represents a *prefix* unary operator.rLr+cóH•—|jj‰¬«f|dd|S©N©r}©r‚r )rLrUs €r)rÒzParser.prefix..nudûs&ø€Ø—k‘k×,Ñ,°Ð,Ó4Ð5ˆD‘ˆG؈Kr(zprefix operator)rr|r}rÒr_r`s ` r)Úprefixz Parser.prefixøs;ø€ð ”eœE‘lð ¤u¬U¡|õ ð�|‰|˜FÐ*;ÀÈÐQTˆ|ÓUÐUr(có„—dttdttdttfd„}|j|d|||¬«S)zIRegister a token for a symbol that represents a *postfix* unary operator.rLrÔr+có—|f|dd|Sr=r'rÖs r)r×zParser.postfix..leds€Ø�eˆD‘ˆG؈Kr(zpostfix operator©rr|r}r×r_©r r*rUr×s r)r­zParser.postfixsE€ð ”eœE‘lð ¬%´©,ð ¼5Ĺ<ó ð�|‰|˜FÐ*<À"È"ÐRUˆ|ÓVÐVr(cóЇ—dttdttdttfˆfd„ }|j|d‰‰|¬«S)zIRegister a token for a symbol that represents an *infix* binary operator.rLrÔr+cóJ•—||jj‰¬«f|dd|Srdrf©rLrÔrUs €r)r×zParser.infix..led s(ø€Ø˜DŸK™K×2Ñ2°rÐ2Ó:Ð:ˆD‘ˆG؈Kr(r^rjr_rks ` r)Úinfixz Parser.infixsDø€ð ”eœE‘lð ¬%´©,ð ¼5Ĺ<õ ð�|‰|˜F¨*¸"À"È#ˆ|ÓNÐNr(có�‡—dttdttdttfˆfd„ }|j|d‰‰dz |¬«S)zJRegister a token for a symbol that represents an *infixr* binary operator.rLrÔr+cóP•—||jj‰dz ¬«f|dd|S)Nr5rerfrns €r)r×zParser.infixr..leds,ø€Ø˜DŸK™K×2Ñ2°r¸A±vÐ2Ó>Ð>ˆD‘ˆG؈Kr(r^r5rjr_rks ` r)Úinfixrz Parser.infixrsHø€ð ”eœE‘lð ¬%´©,ð ¼5Ĺ<õ ð�|‰|˜F¨*¸"À"ÀqÁ&Ècˆ|ÓRÐRr(.cóz‡—|j|d||¬«Šdtdtfdtdtffˆfd„ }|S)z… Register a token for a symbol that represents a custom operator or redefine a method for an existing token. r^)rr|r}Úfunc.r+c󨕗|jjd«d}tt‰|««st |›d‰›�«‚t ‰||«|S)Nr/rz is not a method of )r#Ú partitionrJÚgetattrrïrG)rtÚ method_namerKs €r)ÚbindzParser.method..bind!sSø€ØŸ-™-×1Ñ1°#Ó6°qÑ9ˆKÜœG K°Ó=Ô>Ü ; /Ð1EÀkÀ]Ð SÓTÐTÜ �K ¨dÔ 3؈Kr()rFr r)r r*rUryrKs @r)Úmethodz Parser.methodsGø€ð—l‘l 6°ÀÈ�lÓLˆ ð ”x ¤S Ñ)ð ¬h°s¼C°xÑ.@õ ð ˆ r(có<—d|jvr|jd«d|jvr|jd«d|jvr|jd«d|jvr|jd«|j|j«|_y)zŸ Builds the parser class. Checks if all declared symbols are defined and builds the regex tokenizer using the symbol related patterns. rrrr N)r¾rFÚcreate_tokenizerrü)r s r)rz Parser.build)s„€ð ˜C×,Ñ,Ñ ,Ø �L‰L˜Ô #Ø ˜#×*Ñ*Ñ *Ø �L‰L˜Ô !Ø ˜c×.Ñ.Ñ .Ø �L‰L˜Ô %Ø ˜c×.Ñ.Ñ .Ø �L‰L˜Ô %à×,Ñ,¨S×-=Ñ-=Ó>ˆ� r(c ó —g}g}g}t«}|j«D]Í\}}|tvrŒ|j�|j |j«Œ7|j j |«�%|jtj|««Œwt|«dk(r%|jtj|««Œª|jtj|««ŒÏg}|r,|jdjt|d„¬«««|r/|jdjdj|«««|r;|jdjdjt|d„¬««««|r |jdj|««d j|jjdj|«|j j«} tj| «S) aë Returns a regex based tokenizer built from a symbol table of token classes. The returned tokenizer skips extra spaces between symbols. A regular expression is created from the symbol table of the parser using a template. The symbols are inserted in the template putting the longer symbols first. Symbols and their patterns can't contain spaces. :param symbol_table: a dictionary containing the token classes of the formal language. r5Ú|có—t|« Sr=r ©Úxs r)Úz)Parser.create_tokenizer..Zs€ÔTWÐXYÓTZÑSZr()rNz[{}]r>z\b(?:{})\b(?![\-\.])có—t|« Sr=r r€s r)r‚z)Parser.create_tokenizer.._s €¼cÀ!»f¹Wr(z({})|({})|({})|(\S)|\s+)ÚsetrrAr€Úaddr¼r½rÞrÚescaper“rCÚsortedrrûr ) r r¾Úcharacter_patternsÚstring_patternsÚ name_patternsÚcustom_patternsr*rKÚsymbols_patternsÚtokenizer_patterns r)r|zParser.create_tokenizer;s±€ð ÐØˆØˆ Ü›%ˆà#/×#5Ñ#5Ö#7Ñ ˆF�KØœÑ(ØØ×$Ñ$Ð0Ø×#Ñ# K×$7Ñ$7Õ8Ø×!Ñ!×'Ñ'¨Ó/Ð;Ø×$Ñ$¤R§Y¡Y¨vÓ%6Õ7Ü�V“ Ò!Ø"×)Ñ)¬"¯)©)°FÓ*;Õ<à×&Ñ&¤r§y¡y°Ó'8Õ9ð$8ð')ÐÙ Ø × #Ñ # C§H¡H¬V°OÑIZÔ-[Ó$\Ô ]Ù Ø × #Ñ # F§M¡M°"·'±'Ð:LÓ2MÓ$NÔ OÙ Ø × #Ñ #Ð$;×$BÑ$BØ—‘œ  Ñ3DÔEÓFó%ô ñ Ø × #Ñ # C§H¡H¨_Ó$=Ô >à6×=Ñ=Ø × Ñ × (Ñ (Ø �H‰HÐ%Ó &Ø × Ñ × $Ñ $ó Ðô �z‰zÐ+Ó,Ð,r()r+N)rró)6r#r$r%r&r{rúrürrr2rôr¾r rrrrrõrMr`rcrurvrXr#rr6rwr r÷rr¹rÃrÇrÎÚ staticmethodr,Ú classmethodrrrFrPrTr.rargr­rorrr rzrrr|r'r(r)rr±s÷…ñðÐØ(,€Iˆx˜ ™ Ñ%Ó,Ø+-€L�$�s˜D ™KÐ'Ñ(Ó-àÓØ ƒKØ �U˜3‘ZÑ Ó Ø ƒLØÓؘ˜s™Ñ$Ó$ؘc‘lÓ"ؘ#‘,ÓàW€Ió9ðJ˜#óJð.˜ó.ð4˜Fð4 tó4ð =˜Cð= Eó=ð4?CòA ðA¨h°s©mðAÀuóAðF&%¨3ð&%°3ó&%ñP!˜cð!¨%ó!ð ð#˜%  S ™/ò#óð#ð, ó,ð*˜tó*ñ 3 ð 3°Dð 3ÀDó 3ððL ðL¨òLóðLðð?˜e C¨¨e©Ð$4Ñ5ð?Àð?ÈÈeÉò?óð?ðBð- ð-¨ò-óð-ðð˜sð°ð¸sðÀtÈEÁ{òóððñY˜SðY cðY°$°u±+òYóðYðñG˜SðG cðG°$°u±+òGóðGð ñV˜CðV SðV°°e±òVóðVðñW˜SðW cðW°$°u±+òWóðWðñO˜3ðO CðO°°U± òOóðOðñS˜CðS SðS°°e±òSóðSðñ˜E # t¨E¡{Ð"2Ñ3ð¸ðؘ # s (Ñ+Ð,¨h°s¸C°xÑ.@Ð@ÑAòóðð ò?óð?ð"ð--¨N¸3ÀÀUÁ Ð;KÑ,Lð--ÐQXÐY\ÑQ]ò--óñ--r(r)Ú metaclass))r&rrÚabcrÚ unicodedatarr1ÚdecimalrrÚtypingrrr r r r r rrrrrrrrrrÚ frozensetrAÚ SyntaxErrorr"r2rGrIrxr{rùrrr'r(r)Úr—sÉðñó Û ÝÝ,ß-÷'÷'÷'÷'õ'ñ2ðó€ô 9�ô9ðD ðD¨óD÷4$7ñ$7ñN ˆT˜Ô&€ôM#ˆO˜BÑ ôM#ô`"�ô"ñJ �˜u S™z°TÔ:€ôx-ˆW�U‰^ zöx-r(