Ë µ ½ÍLeÕãóJ—dZddlZed«\ZZZZZejdejejz«jZ ejdej«jZejdejejz«jZejdej«jZejdej«jZejd ej«jZGd „d e«Zej-ed «d «Zej1d„dD««ej1d„dD««ej1d„dD««Gd„d«Zedk(rddlmZedd¬«yy)aÄDefine partial Python code Parser used by editor and hyperparser. Instances of ParseMap are used with str.translate. The following bound search and match functions are defined: _synchre - start of popular statement; _junkre - whitespace or comment line; _match_stringre: string, possibly without closer; _itemre - line that may have bracket structure start; _closere - line that must be followed by dedent. _chew_ordinaryre - non-special characters. éNézä ^ [ \t]* (?: while | else | def | return | assert | break | class | continue | elif | try | except | raise | import | yield ) \b z' [ \t]* (?: \# \S .* )? \n aK \""" [^"\\]* (?: (?: \\. | "(?!"") ) [^"\\]* )* (?: \""" )? | " [^"\\\n]* (?: \\. [^"\\\n]* )* "? | ''' [^'\\]* (?: (?: \\. | '(?!'') ) [^'\\]* )* (?: ''' )? | ' [^'\\\n]* (?: \\. [^'\\\n]* )* '? zM [ \t]* [^\s#\\] # if we match, m.end()-1 is the interesting char z_ \s* (?: return | break | continue | raise | pass ) \b z [^[\](){}#'"\\]+ có—eZdZdZd„Zy)ÚParseMapapDict subclass that maps anything not in dict to 'x'. This is designed to be used with str.translate in study1. Anything not specifically mapped otherwise becomes 'x'. Example: replace everything except whitespace with 'x'. >>> keepwhite = ParseMap((ord(c), ord(c)) for c in ' \t\n\r') >>> "a + b\tc\nd".translate(keepwhite) 'x x x\tx\nx' có—y)Néx©)ÚselfÚkeys ú&/usr/lib/python3.12/idlelib/pyparse.pyÚ __missing__zParseMap.__missing__rs€ØóN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rr r rrfs „ñ ór ré€rc#óHK—|]}t|«td«f–—Œy­w)Ú(N©Úord©Ú.0Úcs r Ú rxóèø€Ð /© AŒc�!‹f”c˜#“hÔ ©ùó‚ "z({[c#óHK—|]}t|«td«f–—Œy­w)Ú)Nrrs r rryrrz)}]c#óHK—|]}t|«t|«f–—Œy­w©Nrrs r rrzsèø€Ð 2¡z !Œc�!‹f”c˜!“fÔ ¡zùrz"'\ #có`—eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zy)ÚParsercó —||_||_yr )Ú indentwidthÚtabwidth)r r$r%s r Ú__init__zParser.__init__s€Ø&ˆÔØ ˆ� r cóP—t|«dk(s |ddk(sJ‚||_d|_y)NréÿÿÿÿÚ )ÚlenÚcodeÚ study_level)r Úss r Úset_codezParser.set_codeƒs,€Ü�1‹v˜Š{˜a ™e tšmÐ+Ð+؈Œ ؈Õr có—|jd}}t|«}td«D]k}|jdd|«}|dkrnQ|jdd|«dz}t |||«}|r(||j ««s|j «}n|}Œm|€5t |«}|r&||j ««s|j «}|S|dz}t ||«x}r,|j «\}}||«s|}t ||«x}rŒ,|S)a^ Return index of a good place to begin parsing, as close to the end of the string as possible. This will be the start of some popular stmt like "if" or "def". Return None if none found: the caller should pass more prior context then, if possible, or if not (the entire program text up until the point of interest has already been tried) pass 0 to set_lo(). This will be reliable iff given a reliable is_char_in_string() function, meaning that when it says "no", it's absolutely guaranteed that the char is not in a string. Nrz: rr)é)r+r*ÚrangeÚrfindÚ_synchreÚstartÚspan) r Úis_char_in_stringr+ÚposÚlimitÚtriesÚiÚmr-s r Úfind_good_parse_startzParser.find_good_parse_startˆs€ð—I‘I˜tˆcˆô �D“ ˆÜ˜1–XˆEØ— ‘ ˜5 ! UÓ+ˆAØ�1ŠuÙØ— ‘ ˜4  AÓ&¨Ñ*ˆAܘ˜q %Ó(ˆAÙÑ*¨1¯7©7«9Ô5Ø—g‘g“i�ÙØ‰Eðð ˆ;ô˜“ˆAÙÑ*¨1¯7©7«9Ô5Ø—g‘g“i�؈Jð �!‰GˆÜ˜D !Ó$Ð$ˆaÐ$Ø—6‘6“8‰DˆAˆqÙ$ QÔ'Ø�ô˜D !Ó$Ð$ˆaÑ$ðˆ r cóp—|dk(s|j|dz dk(sJ‚|dkDr|j|d|_yy)zx Throw away the start of the string. Intended to be called with the result of find_good_parse_start(). rr0r)N)r+)r Úlos r Úset_loz Parser.set_lo¼sA€ð �QŠw˜$Ÿ)™) B q¡D™/¨TÒ1Ð1Ð1Ø �Š6ØŸ ™  " #˜ˆD�Ið r có¼—|jdk\ryd|_|j}|jt«}|j dd«}|j dd«}|j dd«}|j dd«}|j dd«}t }d x}}d gx|_}|j}d t|«}}||k�rN||} |dz}| dk(rŒ| dk(r|dz}|d k(r||«Œ.| d k(r|dz}Œ9| d k(r|r|dz }ŒF| d k(s| d k(r¯| } ||dz |dz| dzk(r| dz} |} t| «dz } || z}||krg||} |dz}| dk(rŒ||dz || z| k(r|| z}nX| dk(r|dz}| d k(r|d k(r||«n;ŒG| dk(r||ksJ‚||dk(r|dz}|dz}Œf||krŒg|dz | k(rt}nt}Œÿ| dk(r|jd|«}|d k\sJ‚�Œ| dk(sJ‚||ksJ‚||dk(r|dz}|dz|k(rt}|dz}||kr�ŒN|tk7r|tk7r |d kDrt}||_|t k(|d|k(k(sJ‚|d|k7r ||«yy)záFind the line numbers of non-continuation lines. As quickly as humanly possible , find the line numbers (0- based) of the non-continuation lines. Creates self.{goodlines, continuation}. r0NÚxxxxxxxxÚxÚxxxxÚxxz xr)rrrÚ"Ú'ééÚ\Ú#r()r,r+Ú translateÚtransÚreplaceÚC_NONEÚ goodlinesÚappendr*ÚC_STRING_FIRST_LINEÚC_STRING_NEXT_LINESÚfindÚ C_BACKSLASHÚ C_BRACKETÚ continuation) r r+rVÚlevelÚlnorOÚ push_goodr:ÚnÚchÚquoteÚfirstlnoÚws r Ú_study1zParser._study1Ås€ð × Ñ ˜qÒ Ø ØˆÔð �y‰yˆØ�~‰~œeÓ$ˆØ�|‰|˜J¨Ó,ˆØ�|‰|˜F CÓ(ˆØ�|‰|˜D #Ó&ˆØ�|‰|˜D #Ó&ˆØ�|‰|˜E 4Ó(ˆôˆ ؈ˆ�Ø&' SÐ(ˆŒ˜Ø×$Ñ$ˆ Ø”#�d“)ˆ1ˆØ�!‹eØ�a‘ˆBØ�!‘ˆAð�SŠyØà�TŠzؘA‘g�ؘA’:Ù˜c”Nàà�SŠyØ ™ �Øà�SŠyÙØ! A™I�Eàà�SŠy˜B #šIà�ؘ˜!™˜A˜a™C�= E¨A¡IÒ-Ø! A™I�EØ�ܘ“J ‘N�Ø�a‘C�ؘ!’eؘa™�Bؘ!™�Aà˜S’yØ à˜A˜a™C  !¡�}¨Ò-ؘa™C˜Øà˜T’zØ! A™g˜Ø š6à$¨šzÙ )¨#¤Ø!Ø à˜T’zØ  1šu˜ ˜uØ ™7 dš?Ø"%¨¡'˜Cؘa™C˜Ø ð3˜!“eð@˜a™ HÒ,ô(;™ ä':˜ Øà�SŠyà—I‘I˜d AÓ&�ؘA’v� �vÙà˜’:Ð �:Ø�q’5ˆL�5Ø�A‰w˜$ŠØ˜A‘g�Ø�Q‘3˜!’8Ü#.�LØ�!‘ˆAðk�!Œeðt Ô/Ò /ØÔ 3Ò3¸Àº Ü$ˆLØ(ˆÔð¤Ñ&¨I°b©M¸SÑ,@ÒAÐAÐAØ �R‰=˜CÒ Ù �c�Nð r có:—|j«|jSr )r_rV©r s r Úget_continuation_typezParser.get_continuation_typeKs€Ø � ‰ ŒØ× Ñ Ð r cób—|jdk\ry|j«d|_|j|j}}t |«dz }t |«}|rO|sJ‚|}t ||dz ||«D]}|j dd|dz «dz}Œt||«r|dz }nn|rŒO|dk(r |dk(sJ‚|}|c|_|_ d}g}|j} |dfg} ||k�r©t|||«} | rF| j«} | dz }||k\r||dvr|dz }||k\r||dvrŒ||k\r||}| }||k\r�nT||} | dvr,| |«| j|t |«f«| }|dz}Œ�| d vr)|r|d =| }|dz}| j|t |«f«Œ½| d k(s| d k(rZ| j|t |«dzf«| }t|||«j«}| j|t |«f«�Œ!| d k(rZ| j|t |«dzf«|jd||«dz}|dkDsJ‚| j|t |«f«�Œ€| dk(sJ‚|dz}||ksJ‚||dk7r| ||z}|dz}||kr�Œ©||_|r|d nd|_t#| «|_y)am study1 was sufficient to determine the continuation status, but doing more requires looking at every character. study2 does this for the last interesting statement in the block. Creates: self.stmt_start, stmt_end slice indices of last interesting stmt self.stmt_bracketing the bracketing structure of the last interesting stmt; for example, for the statement "say(boo) or die", stmt_bracketing will be ((0, 0), (0, 1), (2, 0), (2, 1), (4, 0)). Strings and comments are treated as brackets, for the matter. self.lastch last interesting character before optional trailing comment self.lastopenbracketpos if continuation is C_BRACKET, index of last open bracket rGNr0r)rÚú ú([{ú)]}r(rErFrJrI)r,r_r+rOr*r1r2Ú_junkreÚ stmt_startÚstmt_endrPÚ_chew_ordinaryreÚendÚ_match_stringrerSÚlastchÚlastopenbracketposÚtupleÚstmt_bracketing)r r+rOr:ÚpÚqÚnothingrnÚstackÚ push_stackÚ bracketingr;Únewpr[s r Ú_study2zParser._study2Os€ð& × Ñ ˜qÒ Ø Ø � ‰ ŒØˆÔðŸ)™) T§^¡^ˆiˆÜ � ‹N˜QÑ ˆÜ �‹IˆÙÙˆH�1ðˆAÜ  ¨1¨Q©3¡°¸1±Ö>�à—J‘J˜t Q¨¨!©Ó,¨qÑ0‘ð?ô ˜˜aÔ Ø�a‘C‘àòð �Š6à˜’6ˆM�6؈AØ)*¨AÐ&ˆŒ˜œðˆØˆØ—\‘\ˆ ؘ!�f�Xˆ Ø�!‹eä   q¨!Ó,ˆAÙà—u‘u“w�à˜1‘H�ؘ1’f  a¡¨GÑ!3ؘ!™�Að˜1’f  a¡¨GÒ!3à˜’6Ø! !™W�FØ�ؘ’6Ùà�a‘ˆBà�U‰{Ù˜1” Ø×!Ñ! 1¤c¨%£j /Ô2Ø�Ø�a‘C�Øà�U‰{ÙØ˜b˜ Ø�Ø�a‘C�Ø×!Ñ! 1¤c¨%£j /Ô2Øà�SŠy˜B #šIð×!Ñ! 1¤c¨%£j°¡lÐ"3Ô4Ø�Ü# D¨!¨QÓ/×3Ñ3Ó5�Ø×!Ñ! 1¤c¨%£j /Ô2Ùà�SŠyà×!Ñ! 1¤c¨%£j°¡lÐ"3Ô4Ø—I‘I˜d A qÓ)¨AÑ-�ؘ1’u� �uØ×!Ñ! 1¤c¨%£j /Ô2Ùà˜’:Ð �:Ø�!‘ˆAØ�q’5ˆL�5Ø�A‰w˜$Šà˜d 1™g™�Ø�!‘ˆAð{�!ŒeðBˆŒ Ù/4 %¨¢)¸$ˆÔÜ$ ZÓ0ˆÕr cóô—|j«|jtk(sJ‚|j}|j}t |«}|j dd|«dzx}}|dz}||krAt||«}|r|j«dz }d}nA|jd|«dzx}}||krŒA|x}}||dvr |dz}||dvrŒ |j}t |||j|j««|zS)zpReturn number of spaces the next line should be indented. Line continuation must be C_BRACKET. r)rr0ú ) ryrVrUror+r*r2Ú_itemrerlrSr$Ú expandtabsr%)r Újr+rZÚorigir:r;Úextras r Úcompute_bracket_indentzParser.compute_bracket_indentÊs€ð � ‰ ŒØ× Ñ ¤IÒ-Ð-Ð-Ø × #Ñ #ˆØ�y‰yˆÜ �‹IˆØ—J‘J˜t Q¨Ó*¨QÑ.Ð.ˆ�Ø ˆa‰Cˆà�!Šeܘ˜aÓ ˆAÙØ—E‘E“G˜a‘K�Ø�ØðŸ ™  $¨Ó*¨QÑ.Ð.��Að�!‹eðˆMˆA�Ø�q‘'˜UÑ"Ø�a‘C�ð�q‘'˜UÒ"à×$Ñ$ˆEÜ�4˜˜!�9×'Ñ'¨¯ © Ó6Ó7¸%Ñ?Ð?r cóP—|j«|j}|d|dz S)zÃReturn number of physical lines in last stmt. The statement doesn't have to be an interesting statement. This is intended to be called when continuation is C_BACKSLASH. r(éþÿÿÿ)r_rO)r rOs r Úget_num_lines_in_stmtzParser.get_num_lines_in_stmtés)€ð � ‰ ŒØ—N‘Nˆ ؘ‰}˜y¨™}Ñ,Ð,r cóÆ—|j«|jtk(sJ‚|j}|j}||dvr |dz}||dvrŒ |}|j d|«dz}dx}}||krƒ||}|dvr |dz}|dz}ni|dvr |r|dz }|dz}nX|dk(s|dk(rt |||«j«}n2|d k(rn2|dk(r"|d k(r|dk(s ||dz d vr||dzd k7rd}n |dz}||krŒƒ|r |dz}tjd |||«d u}|s|}||dvr |dz}||dvrŒ t||j|j|j««dzS)zÒReturn number of spaces the next line should be indented. Line continuation must be C_BACKSLASH. Also assume that the new line is the first one following the initial line of the stmt. r{r0r)rrfrgrErFrJÚ=z=<>!z\s*\\Nre) ryrVrTr+rirSrmrlÚreÚmatchr*r}r%)r r+r:ÚstartposÚendposÚfoundrWr[s r Úcompute_backslash_indentzParser.compute_backslash_indentósÌ€ð � ‰ ŒØ× Ñ ¤KÒ/Ð/Ð/Ø�y‰yˆØ �O‰OˆØ�1‰g˜ÑØ�!‘ˆAð�1‰g˜Òàˆð—‘˜4 Ó*¨QÑ.ˆØÐˆ�Ø�&ŠjØ�a‘ˆBØ�U‰{Ø ™ �Ø�a‘C‘Ø�u‘ÙØ! A™I�EØ�a‘C‘Ø�s’˜b CšiÜ# D¨!¨VÓ4×8Ñ8Ó:‘Ø�s’ðؘ!’  c¢ ؘ’F˜d 1 Q¡3™i¨vÑ5ؘ˜!™‘9 Ò#Ø�Øà�a‘C�ð+�&‹jñ. ð�!‘ˆAÜ—H‘H˜X t¨A¨f ~Ó6¸$Ð>ˆEáðˆAØ�q‘' Ñ(Ø�a‘C�ð�q‘' Ò(ô�4˜Ÿ™¨Ð*×5Ñ5Ø%)§]¡]ó4ó5Ø78ñ9ð 9r có´—|j«|j|j}}|}|j}||kr||dvr|dz}||kr||dvrŒ|||S)z`Return the leading whitespace on the initial line of the last interesting stmt. r{r0)ryrirjr+)r r:rZr~r+s r Úget_base_indent_stringzParser.get_base_indent_string,sg€ð � ‰ ŒØ�‰ § ¡ ˆ1ˆØ ˆØ�y‰yˆØ�!Še˜˜Q™ 5Ñ(Ø�A‘ˆAð�!Še˜˜Q™ 5Ò(à�A�aˆyÐr có@—|j«|jdk(S)z-ò79òr ò"ò @ó $r r"Ú__main__)Úmainzidlelib.idle_test.test_pyparserG)Ú verbosity)rr‡r1rNrTrQrRrUÚcompileÚVERBOSEÚ MULTILINEÚsearchr3rˆrhÚDOTALLrmr|r“rkÚdictrÚfromkeysrLÚupdater"rÚunittestr˜rr r Úr£s·ðñ ó ñ$)¨£8ñ!€ˆÐ)Ø�ið ˆ2�:‰:ðð&‡Z�Z�"—,‘,Ñó' ÷&!'¡ð' ð. ˆ"�*‰*ðð‡Z�Zó  ÷‘ð ð�"—*‘*ðð ‡Z�Z�"—)‘)Ñó!÷ #™Uð!ð* ˆ"�*‰*ðð‡Z�Zó ÷‘ðð ˆ2�:‰:ð ð‡Z�Zó ÷‘ð ð �2—:‘:ðà‡Z�Zóç‘ðô ˆtô ð" ×Ñ™% ›* cÓ*€Ø‡ � Ñ /©Ó /Ô/؇ � Ñ /©Ó /Ô/؇ � Ñ 2¡zÓ 2Ô2÷K$ñK$ð\ ˆzÒÝÙÐ )°QÖ7ðr