mò %U²Ic@s‹dZdZdZdkZdkZdkTdkZgZeeƒD]"Zeddjo eeqEqE[ddd d gZ [[e Z de e e2<d?e3<d@e2<dAe3<dBe2<dCe3<dDe2<dEe3<dFd<dGd<dHd<dIdda„Z?db„Z@eAdcjoQdkBZBeCeBiDƒd joe>eEeBiDd ƒiFƒq‡e>eBiGiFƒndS(fsÀTokenization help for Python programs. generate_tokens(readline) is a generator that breaks a stream of text into Python tokens. It accepts a readline-like method which is called repeatedly to get the next line of input (or "" for EOF). It generates 5-tuples with these members: the token type (see token.py) the token (a string) the starting (row, column) indices of the token (a 2-tuple of ints) the ending (row, column) indices of the token (a 2-tuple of ints) the original line (string) It is designed to match the working of the Python tokenizer exactly, except that it produces COMMENT tokens for comments and gives type OP for all operators Older entry points tokenize_loop(readline, tokeneater) tokenize(readline, tokeneater=printtoken) are the same, except instead of generating tokens, tokeneater is a callback function to which the 5 fields described above are passed as 5 arguments, each time a new token is found.sKa-Ping Yee s@GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip MontanaroN(t*it_tCOMMENTttokenizetgenerate_tokenstNLiicGsddi|ƒdS(Nt(t|t)(tjointchoices(R ((t%/data/zmath/lib/python2.4/tokenize.pytgroup,scGst|ŒdS(NR(R R (R ((R tany-scGst|ŒdS(Nt?(R R (R ((R tmaybe.ss[ \f\t]*s #[^\r\n]*s\\\r?\ns [a-zA-Z_]\w*s0[xX][\da-fA-F]*[lL]?s 0[0-7]*[lL]?s [1-9]\d*[lL]?s [eE][-+]?\d+s\d+\.\d*s\.\d+s\d+s\d+[jJ]s[jJ]s[^'\\]*(?:\\.[^'\\]*)*'s[^"\\]*(?:\\.[^"\\]*)*"s%[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''s%[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""s [uU]?[rR]?'''s [uU]?[rR]?"""s&[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'s&[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"s\*\*=?s>>=?s<<=?s<>s!=s//=?s[+\-*/%&|^=<>]=?t~s[][(){}]s\r?\ns[:;.,`@]s%[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*t's%[uU]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*t"s'''s"""sr'''sr"""su'''su"""sur'''sur"""sR'''sR"""sU'''sU"""suR'''suR"""sUr'''sUr"""sUR'''sUR"""trtRtutUsr'sr"sR'sR"su'su"sU'sU"sur'sur"sUr'sUr"suR'suR"sUR'sUR"it TokenErrorcBstZRS(N(t__name__t __module__(((R RƒstStopTokenizingcBstZRS(N(RR(((R R…sc CsA|\}}|\}}d||||t|t|ƒfGHdS(Ns%d,%d-%d,%d: %s %s(tsrowtscolterowtecolttok_namettypetreprttoken( R R"t.4t.6tlineRRRR((R t printtoken‡scCs+yt||ƒWntj onXdS(s: The tokenize() function accepts two parameters: one representing the input stream, and one providing an output mechanism for tokenize(). The first parameter, readline, must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as a string. The second parameter, tokeneater, must also be a callable object. It is called once for each token, with five arguments, corresponding to the tuples generated by generate_tokens(). N(t tokenize_looptreadlinet tokeneaterR(R(R)((R R‹s cCs%xt|ƒD]}||Œq WdS(N(RR(t token_infoR)(R(R)R*((R R'žs ccsd}}}tidd}}d\}} d}dg}x|ƒ}|d}dt|ƒ}} |oø|ptd| f‚n|i|ƒ}|oN|idƒ}}t||| | ||f||fVd\}} d}qB| oX|ddjoG|d d jo6t||| |t|ƒf|fVd}d}q@qB||}||}q@nÞ|djoª| o¢|pPnd}x~|| jop||d jo|d}nD||d jo|tdt}n||d jo d}nP|d}qW|| joPn||djoDttf||dj||||f|t|ƒf|fVq@n||djo4|i|ƒt|| |df||f|fVnx†||djoJ||jotdƒ‚n|d }t d||f||f|fVq¼Wn'|ptd|dff‚nd}xü|| joît!i||ƒ}|o |i#dƒ\}}||f||f|}}}|||!||} } | |jp| djo$| djot)| |||fVq<| djo+|djotpt*| |||fVq<| djot| |||fVq<| t+jo}t,| }|i||ƒ}|o9|idƒ}|||!} t| |||f|fVq||f} ||}|}Pq<| t-jp"| d t-jp| d t-jox| ddjoP||f} t,| pt,| dp t,| d}||d}} |}Pqt| |||fVq<| |jot.| |||fVq<| djo d}q<| djo|d}n| djo|d}nt/| |||fVqEt||||f||df|fV|d}qEWq@Wx1|dD]%}t d|df|dfdfVqQWt1d|df|dfdfVdS(sµ The generate_tokens() generator requires one argment, readline, which must be a callable object which provides the same interface as the readline() method of built-in file objects. Each call to the function should return one line of input as a string. The generator produces 5-tuples with these members: the token type; the token string; a 2-tuple (srow, scol) of ints specifying the row and column where the token begins in the source; a 2-tuple (erow, ecol) of ints specifying the row and column where the token ends in the source; and the line on which the token was found. The line passed is the logical line; continuation lines are included. iRt 0123456789tisEOF in multi-line stringiþÿÿÿs\ iýÿÿÿs\ t s s s# t#iÿÿÿÿs3unindent does not match any outer indentation levelsEOF in multi-line statementt.s iis s\s([{s)]}N(R,i(R,i(2tlnumtparenlevt continuedtstringt ascii_letterst namecharstnumcharstcontstrtneedconttNonetcontlinetindentsR(R%tlentpostmaxRtstrstarttendprogtmatchtendmatchtendtSTRINGt ERRORTOKENtcolumnttabsizeRRtappendtINDENTtIndentationErrortDEDENTt pseudoprogt pseudomatchtspantstarttsposteposR"tinitialtNUMBERtNEWLINEt triple_quotedtendprogst single_quotedtNAMEtOPtindentt ENDMARKER(R(R0R=R5RZR%RQRCRORRR8R"R?R>RBRPR;R:R2RMR@RFR7R6R1((R R¢sÔ     %  )#     = '  (  ' +      / (     ' #t__main__(s'''s"""sr'''sr"""sR'''sR"""su'''su"""sU'''sU"""sur'''sur"""sUr'''sUr"""suR'''suR"""sUR'''sUR"""(RRsr'sr"sR'sR"su'su"sU'sU"sur'sur"sUr'sUr"suR'suR"sUR'sUR"(Ht__doc__t __author__t __credits__R3treR"t_[1]tdirtxt__all__tN_TOKENSRRRR R Rt WhitespacetCommenttIgnoretNamet Hexnumbert Octnumbert Decnumbert IntnumbertExponentt PointfloattExpfloatt Floatnumbert ImagnumbertNumbertSingletDoubletSingle3tDouble3tTripletStringtOperatortBrackettSpecialtFunnyt PlainTokentTokentContStrt PseudoExtrast PseudoTokentmaptcompilet tokenprogRLt single3progt double3progR9RVRUttRWRGt ExceptionRRR&RR'RRtsysR<targvtopenR(tstdin(;R}R‚RfRqR'RReR~RŠRVRwR RiRR_R RyRdRRtR&RmR`RkRGR…RRRvRˆR3RrRuRlR^RhRR{R€RLRRWRnRoRgRjRR‡R†RsRaRpR"RR|RxRURzRc((R Rs L           *ð     …