ndVFSrSSKr\"S5urrrrr\R"S\R\R-5Rr \R"S\R5Rr\R"S\R\R-5Rr\R"S\R5Rr\R"S\R5Rr\R"S \R5Rr"S S \5r\R-\"S 5S 5r\R1SS55 \R1SS55 \R1SS55 "SS5r\S:XaSSKJr \"SSS9 gg)aDefine 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. Nz ^ [ \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\rSrSrSrSrSrg)ParseMapfaTDict 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' cg)Nx)selfkeys 6/opt/alt/python313/lib64/python3.13/idlelib/pyparse.py __missing__ParseMap.__missing__rsr N)__name__ __module__ __qualname____firstlineno____doc__r __static_attributes__r rr rrfs  rrrc#N# UHn[U5[S54v M g7f)(Nord.0cs r rx /Ac!fc#h #%z({[c#N# UHn[U5[S54v M g7f))Nrrs r rryrr z)}]c#N# UHn[U5[U54v M g7fNrrs r rrzs 2z!c!fc!f zr z"'\ #ch\rSrSrSrSrSrSrSrSr Sr S r S r S r S rS rSrSrSrg)Parser}cXlX lgr$) indentwidthtabwidth)r r)r*s r __init__Parser.__init__s & rcXlSUlg)Nr)code study_level)r ss r set_codeParser.set_codes rc\URSp2[U5n[S5HvnURSSU5nUS:a O\URSSU5S-n[ X&U5nU(a-U"UR 55(dUR 5n OUnMx Uc?[ U5nU(a+U"UR 55(dUR 5nU$US-n[ X&5=n(a5UR 5upU"U5(dUn[ X&5=n(aM5U$)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: r )r.lenrangerfind_synchrestartspan) r is_char_in_stringr.poslimittriesimr0s r find_good_parse_startParser.find_good_parse_startsIItc D 1XE 5!U+A1u 4A&*A%(A*177955ggiE ;A*177955ggiJ !GD$$a$668DA$Q''D$$a$ rc:US:aURUSUlgg)zgThrow away the start of the string. Intended to be called with the result of find_good_parse_start(). rN)r.)r los r set_lo Parser.set_los! 6 "#DI rcURS:agSUlURnUR[5nUR SS5nUR SS5nUR SS5nUR SS5nUR SS5n[ nS =p4S /=UlnURnS [U5pXx:GaMXn US-nU S:XaMU S:XaUS-nUS :XaU"U5 M2U S :XaUS-nM?U S :XaU(aUS- nMSU S :XdU S :XaU n XS- US-U S-:XaU S-n Un [U 5S- n X|-nXx:afXn US-nU S:XaMXS- X|-U :XaX|-nOYU S:XaUS-nU S :XaUS :XaU"U5 O9MJU S:XaXS:XaUS-nUS-nMdXx:aMfUS- U :Xa[nO[nGMU S:XaURSU5nGM*XS:XaUS-nUS-U:Xa[nUS-nXx:aGMMU[:waU[:wa US :a[nX lUSU:wa U"U5 gg)zFind 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}. r5Nxxxxxxxxxxxxxxxz xr4rrr""'\#)r/r. translatetransreplaceC_NONE goodlinesappendr6C_STRING_FIRST_LINEC_STRING_NEXT_LINESfind C_BACKSLASH C_BRACKET continuation) r r.r_levellnorX push_goodr@nchquotefirstlnows r _study1Parser._study1s   q  yy~~e$||J,||FC(||D#&||D#&||E4( &'S($$ #d)1eB!ASyTzAgA:cNSy Sy!AIESyB#I!AaC=EAI-!AIEJNCeB!ASy aC}-CTz!Ag6$z )#! Tz7d?"%'CaC 3e@aH,(; ': SyIIdA&w$AgQ3!8#.L!Aket / / 33 $L( R=C  cN rc:UR5 UR$r$)rhr_r s r get_continuation_typeParser.get_continuation_typeKs    rcpURS:agUR5 SUlURURp![ U5S- n[ U5nU(aUUn[ X#S- X#5HnUR SSUS- 5S-nM [X5(aUS- nOO U(aMUUS:XaUnUWsUlUl Sn/nURn US4/n XE:Ga[XU5n U (aHU R5n U S- nX4:aXS;aUS- nX4:a XS;aMX4:aXnU nXE:aGOLXn U S;a-U "U5 U RU[ U545 U nUS-nMU S ;a/U(aUS U nUS-nU RU[ U545 MU S :XdU S :XaZU RU[ U5S-45 U n[XU5R5nU RU[ U545 GM3U S :XaSU RU[ U5S-45 URSXE5S-nU RU[ U545 GMUS-nXS:waXU-nUS-nXE:aGMXplU(aUS OSUl[#U 5Ulg)a 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 rONr5r4r ([{)]}rSrMrNrR)r/rhr.rXr6r7r8_junkre stmt_startstmt_endrY_chew_ordinaryreend_match_stringrer\lastchlastopenbracketpostuplestmt_bracketing)r r.rXr@pqnothingrystack push_stack bracketingrAnewprds r _study2Parser._study2Os&   q  ))T^^i  NQ  IA Q3>JJtQ!,q0?   aCa 6A)*A&\\ !fX e !,Auuw1HfG!3!AfG!36!WF6BU{1 !!1c%j/2aCU{b aC!!1c%j/2SyB#I!!1c%jl"34#DQ/335!!1c%j/2Sy!!1c%jl"34IIdA)A-!!1c%j/2!Aw$1g!A{eB /4%)$$Z0rcUR5 URnURn[U5nUR SSU5S-=pEUS-nX:aE[ X!5nU(aUR 5S- nSnOCURSU5S-=pQX:aMEU=pX!S;aUS-nX!S;aMURn[X%URUR55U-$)z`Return number of spaces the next line should be indented. Line continuation must be C_BRACKET. r4rr5 ) rrzr.r6r8_itemrerwr\r) expandtabsr*)r jr.rcorigir@rAextras r compute_bracket_indentParser.compute_bracket_indents   # #yy IJJtQ*Q.. aCe AEEGaK $*Q..eMA'U"aC'U"$$E4!9'' 67%??rcPUR5 URnUSUS- $)zReturn 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. rS)rhrX)r rXs r get_num_lines_in_stmtParser.get_num_lines_in_stmts) NN }y},,rcUR5 URnURnXS;aUS-nXS;aMUnURSU5S-nS=pVX$:aXnUS;a US-nUS-nOvUS;aU(aUS- nUS-nO^US:XdUS:Xa[ XU5R 5nO7US :XaO7US:Xa%US :XaUS:Xd XS- S ;aXS-S :waSnO US-nX$:aMU(a US-n[ R"S XU5S LnU(dUnXS;aUS-nXS;aM[XRURUR55S-$)zReturn 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. rr5r4rrqrrrMrNrR=z=<>!z\s*\\Nrp) rr.rtr\rxrwrematchr6rr*)r r.r@startposendposfoundr`rds r compute_backslash_indentParser.compute_backslash_indents yy OOg!Ag4*Q.jBU{ aCu!AIEaCsbCi#DV488:s!c FdQ3iv5!9#aC+j. !AHHXtf~6$>EA'(aC'(4*55%)]]45789 9rcUR5 URURp!UnURnX2:aXCS;aUS-nX2:a XCS;aMXAU$)zPReturn the leading whitespace on the initial line of the last interesting stmt. rr5)rrtrur.)r r@rcrr.s r get_base_indent_stringParser.get_base_indent_string,s[  1 yye5(AAe5(ayrc@UR5 URS:H$)z-79r " @ $rr&__main__)mainzidlelib.idle_test.test_pyparserO) verbosity)rrr7rWr]rZr[r^compileVERBOSE MULTILINEsearchr9rrsDOTALLrxrrrvdictrfromkeysrUupdater&runittestrr rr rs  $)8!)i ::&ZZ",,' &!'' . **ZZ   ** ZZ"))! #U!* **ZZ  :: ZZ  ::ZZ t " %*c* / // / // 2z 22K$K$\ z )Q7r