eMFSrSSKr\"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 5/opt/imh/python3.13/lib/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 & rcR[U5S:Xd USS:XdeXlSUlg)Nr )lencode study_level)r ss r set_codeParser.set_codes*1v{aetm++ 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: rr/)r1r0rangerfind_synchrestartspan) r is_char_in_stringr1poslimittriesimr3s 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$ rcvUS:XdURUS- S:XdeUS:aURUSUlgg)zgThrow away the start of the string. Intended to be called with the result of find_good_parse_start(). rr7r/N)r1)r los r set_lo Parser.set_losA Qw$))BqD/T111 6 "#DI rcURS:agSUlURnUR[5nUR SS5nUR SS5nUR SS5nUR SS5nUR SS5n[ nS =p4S /=UlnURnS [U5pXx:GakXn 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:amXn US-nU S:XaMXS- X|-U :XaX|-nO`U S:XaUS-nU S :XaUS :XaU"U5 O@MJU S:XaXx:deXS:XaUS-nUS-nMkXx:aMmUS- U :Xa[nO[nGMU S:XaURSU5nUS :deGM9U S:XdeXx:deXS:XaUS-nUS-U:Xa[nUS-nXx:aGMkU[:waU[:wa US :a[nX lU[ :HUSU:H:XdeUSU: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}. r7Nxxxxxxxxxxxxxxxz xr/rrr""'\#r.)r2r1 translatetransreplaceC_NONE goodlinesappendr0C_STRING_FIRST_LINEC_STRING_NEXT_LINESfind C_BACKSLASH C_BRACKET continuation) r r1r_levellnorX push_goodrAnchquotefirstlnows 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 )#! Tz u u7d?"%'CaC 3e@aH,(; ': SyIIdA&Av v: :5L5w$AgQ3!8#.L!Aket / / 33 $L(&IbMS,@AAA R=C  cN rc:UR5 UR$r$)rhr_r s r get_continuation_typeParser.get_continuation_typeKs    rcURS:agUR5 SUlURURp![ U5S- n[ U5nU(a^U(deUn[ X#S- X#5HnUR SSUS- 5S-nM [X5(aUS- nOO U(aM^US:Xa US:XdeUnUWsUlUl Sn/nURn US4/n XE:Ga[XU5n U (aHU R5n U S- nX4:aXS;aUS- nX4:a XS;aMX4:aXnU nXE:aGOcXn 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 :Xa[U RU[ U5S-45 URSXE5S-nUS:deU RU[ U545 GMU S:XdeUS-nXE:deXS: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 rPNr7r/r ([{)]}r.rNrOrSrR)r2rhr1rXr0r8r9_junkre stmt_startstmt_endrY_chew_ordinaryreend_match_stringrer\lastchlastopenbracketpostuplestmt_bracketing)r r1rXrApqnothingrystack push_stack bracketingrBnewprds r _study2Parser._study2Os&   q  ))T^^i  NQ  IH1A Q3>JJtQ!,q0?   aCa 66M6A)*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-1u u!!1c%j/2: :!A5L5w$1g!A{eB /4%)$$Z0rcUR5 UR[:XdeURnURn[ U5nUR SSU5S-=pEUS-nX:aE[X!5nU(aUR5S- 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. r/rr7 ) rr_r^rzr1r0r9_itemrerwr\r) expandtabsr*)r jr1rcorigirArBextras r compute_bracket_indentParser.compute_bracket_indents   I---  # #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. r.)rhrX)r rXs r get_num_lines_in_stmtParser.get_num_lines_in_stmts) NN }y},,rcUR5 UR[:XdeURnURnXS;aUS-nXS;aMUnUR SU5S-nS=pVX$:aXnUS;a US-nUS-nOvUS;aU(aUS- nUS-nO^US:XdUS:Xa[ XU5R5nO7US :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. rr7r/rrqrrrNrOrS=z=<>!z\s*\\Nrp) rr_r]r1rtr\rxrwrematchr0rr*)r r1rAstartposendposfoundr`rds r compute_backslash_indentParser.compute_backslash_indents   K///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. rr7)rrtrur1)r rArcrr1s 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_pyparserP) verbosity)rrr8rWr]rZr[r^compileVERBOSE MULTILINEsearchr:rrsDOTALLrxrrrvdictrfromkeysrUupdater&runittestrr rr rs  $)8!)i ::&ZZ",,' &!'' . **ZZ   ** ZZ"))! #U!* **ZZ  :: ZZ  ::ZZ t " %*c* / // / // 2z 22K$K$\ z )Q7r