ó S‚ ?c@s5ddlZddlZddlZddlmZddlZdZdZdZe dƒZ d„Z d„Z d „Z d „Zd „Zd d1d „ƒYZd„Zdefd„ƒYZdefd„ƒYZeƒZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZeƒZde_de_d„Zd „Zd!„Zd"„Z e d#ƒZ!d$e!_d%e!_dd&„Z#d'„Z$d(„Z%d)„Z&d*„Z'eeƒZ(d+e(_d,e(_eeƒZ)d-e)_d.e)_eeƒZ*d/e*_d0e*_dS(2iÿÿÿÿN(tmaxinttbolteolteofs cCsÀt|ƒ}|jƒd}t|ƒ}g}x‹||kr»t||ƒ}|d}|d}x:||kr|t||ƒkr|d}|d}qdW|j|ƒ|j|ƒq1W|S(s’ Return a list of character codes consisting of pairs [code1a, code1b, code2a, code2b,...] which cover all the characters in |s|. ii(tlisttsorttlentordtappend(tst char_listtitntresulttcode1tcode2((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytchars_to_rangess     %  cCsjt|tdƒƒ}t|tdƒdƒ}||krbtdƒtdƒ}||||fSdSdS(sŠ If the range of characters from code1 to code2-1 includes any lower case letters, return the corresponding upper case range. tatzitAN(tmaxRtmintNone(RRtcode3tcode4td((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytuppercase_range4s  cCsjt|tdƒƒ}t|tdƒdƒ}||krbtdƒtdƒ}||||fSdSdS(sŠ If the range of characters from code1 to code2-1 includes any upper case letters, return the corresponding lower case range. RtZiRN(RRRR(RRRRR((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytlowercase_rangeAs  cCs^g}xBtdt|ƒdƒD](}|jt||||dƒƒqWttt|ƒƒS(sƒ Given a list of codes as returned by chars_to_ranges, return an RE which will match a character in any of the ranges. iii(txrangeRRt CodeRangetapplytAltttuple(t code_listtre_listR ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt CodeRangesNs&cCsS|tko|knrBtt|tƒtttd|ƒƒSt||ƒSdS(s CodeRange(code1, code2) is an RE which matches any character with a code |c| in the range |code1| <= |c| < |code2|. iN(tnl_codeR t RawCodeRanget RawNewline(RR((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRXs tREcBsqeZdZdZdZd Zd„Zd„Zd„Z d„Z d„Z d„Z d„Z d „Zd „ZRS( sõRE is the base class for regular expression constructors. The following operators are defined on REs: re1 + re2 is an RE which matches |re1| followed by |re2| re1 | re2 is an RE which matches either |re1| or |re2| icCstjd|jjƒ‚dS(sM This method should add states to |machine| to implement this RE, starting at |initial_state| and ending at |final_state|. If |match_bol| is true, the RE must be able to match at the beginning of a line. If nocase is true, upper and lower case letters should be treated as equivalent. s %s.build_machine not implementedN(t exceptionstUnimplementedMethodt __class__t__name__(tselftmachinet initial_statet final_statet match_boltnocase((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt build_machinets cCs-|jƒ}|j|ƒ|j||ƒ|S(s~ Given a state |s| of machine |m|, return a new state reachable from |s| on character |c| or epsilon. (t new_statetlink_totadd_transition(R-tmR/tcR ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt build_opt€s  cCs t||ƒS(N(tSeq(R-tother((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt__add__ŠscCs t||ƒS(N(R (R-R;((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt__or__scCs|jr|jS|jƒSdS(N(tstrtcalc_str(R-((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt__str__s cCs)t|tƒs%|j||dƒndS(NsPlex.RE instance(t isinstanceR(t wrong_type(R-tnumtvalue((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytcheck_re–scCs2t|ƒtdƒkr.|j||dƒndS(Nttstring(ttypeRB(R-RCRD((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt check_stringšscCsQ|j||ƒt|ƒdkrMtjd||jjt|ƒfƒ‚ndS(NisOInvalid value for argument %d of Plex.%s.Expected a string of length 1, got: %s(RIRtErrorstPlexValueErrorR+R,trepr(R-RCRD((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt check_charžs cCslt|ƒtjkr4d|jj|jjf}nt|ƒj}tjd||jj||fƒ‚dS(Ns%s.%s instances<Invalid type for argument %d of Plex.%s (expected %s, got %s(RHttypest InstanceTypeR+t __module__R,RJt PlexTypeError(R-RCRDtexpectedtgot((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRB¥s  N(R,RPt__doc__tnullabletmatch_nlRR>R3R9R<R=R@RERIRMRB(((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR(hs      cCsWt|ƒdkr4tt|ƒt|ƒdƒ}n t|ƒ}dt|ƒ|_|S(s; Char(c) is an RE which matches the character |c|. isChar(%s)(RRRt SpecialSymbolRLR>(R8R ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytCharÕs " R&cBsGeZdZdZdZdZdZdZd„Z d„Z d„Z RS(sÒ RawCodeRange(code1, code2) is a low-level RE which matches any character with a code |c| in the range |code1| <= |c| < |code2|, where the range does not include newline. For internal use only. icCs7||f|_t||ƒ|_t||ƒ|_dS(N(trangeRR(R-RR((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt__init__ìscCs||r|j||tƒ}n|j|j|ƒ|rx|jrV|j|j|ƒn|jrx|j|j|ƒqxndS(N(R9tBOLR6RYRR(R-R7R/R0R1R2((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR3ñs  cCsd|j|jfS(NsCodeRange(%d,%d)(RR(R-((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR?ûsN( R,RPRTRURVRRYRRRZR3R?(((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR&às  t _RawNewlinecBs#eZdZdZdZd„ZRS(sd RawNewline is a low-level RE which matches a newline character. For internal use only. iicCsQ|r|j||tƒ}n|j||tƒ}|jttdf|ƒdS(Ni(R9R[tEOLR6R%(R-R7R/R0R1R2R ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR3s(R,RPRTRURVR3(((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR\þsRWcBs2eZdZdZdZdZd„Zd„ZRS(sx SpecialSymbol(sym) is an RE which matches the special input symbol |sym|, which is one of BOL, EOL or EOF. icCs ||_dS(N(tsym(R-R^((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRZscCsD|r-|jtkr-|j||tƒ}n|j|j|ƒdS(N(R^R]R9R[R6(R-R7R/R0R1R2((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR3sN( R,RPRTRURVRR^RZR3(((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRWs  R:cBs)eZdZd„Zd„Zd„ZRS(s]Seq(re1, re2, re3...) is an RE which matches |re1| followed by |re2| followed by |re3|...cGs¾d}xCtt|ƒƒD]/}||}|j||ƒ|oE|j}qW||_||_t|ƒ}d}x>|r°|d}||}|jr d}Pn|jssPqsqsW||_dS(Nii(RRRERUR#RV(R-R#RUR treRV((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRZ's$         c Cs¾|j}t|ƒdkr+|j|ƒn|}t|ƒ}xzt|ƒD]l} | |dkro|jƒ} n|} || } | j||| ||ƒ| }| jp³|o³| j}qJWdS(Nii(R#RR5RR4R3RVRU( R-R7R/R0R1R2R#ts1R R ts2R_((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR3;s   cCs dtjtt|jƒdƒS(NsSeq(%s)t,(RGtjointmapR>R#(R-((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR?Ls(R,RPRTRZR3R?(((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR:#s  R cBs)eZdZd„Zd„Zd„ZRS(sRAlt(re1, re2, re3...) is an RE which matches either |re1| or |re2| or |re3|...cGs¸||_d}d}g}g}d}xf|D]^}|j||ƒ|jrc|j|ƒd}n |j|ƒ|jr‚d}n|d}q.W||_||_||_||_dS(Nii(R#RERURRVt nullable_restnon_nullable_res(R-R#RURVReRfR R_((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRZTs&           cCsˆx*|jD]}|j|||||ƒq W|jr„|rT|j||tƒ}nx-|jD]}|j|||d|ƒq^WndS(Ni(ReR3RfR9R[(R-R7R/R0R1R2R_((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR3js cCs dtjtt|jƒdƒS(NsAlt(%s)Rb(RGRcRdR>R#(R-((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR?ss(R,RPRTRZR3R?(((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR Ps  tRep1cBs)eZdZd„Zd„Zd„ZRS(s@Rep1(re) is an RE which matches one or more repetitions of |re|.cCs5|jd|ƒ||_|j|_|j|_dS(Ni(RER_RURV(R-R_((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRZzs  cCsk|jƒ}|jƒ}|j|ƒ|jj||||pF|jj|ƒ|j|ƒ|j|ƒdS(N(R4R5R_R3RV(R-R7R/R0R1R2R`Ra((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR3€s    ( cCs d|jS(NsRep1(%s)(R_(R-((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR?ˆs(R,RPRTRZR3R?(((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRgws  t SwitchCasecBs5eZdZdZdZd„Zd„Zd„ZRS(sÔ SwitchCase(re, nocase) is an RE which matches the same strings as RE, but treating upper and lower case letters according to |nocase|. If |nocase| is true, case is ignored, otherwise it is not. cCs.||_||_|j|_|j|_dS(N(R_R2RURV(R-R_R2((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRZ•s   cCs#|jj|||||jƒdS(N(R_R3R2(R-R7R/R0R1R2((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR3›scCs)|jrd}nd}d||jfS(NtNoCasetCases%s(%s)(R2R_(R-tname((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyR?Ÿs  N( R,RPRTRR_R2RZR3R?(((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRhŒs   s8 Empty is an RE which matches the empty string. tEmptycCs5ttttt|ƒƒƒ}dt|ƒ|_|S(s@ Str1(s) is an RE which matches the literal string |s|. sStr(%s)(RR:R!RdRXRLR>(R R ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytStr1´scGsht|ƒdkr t|dƒSttttt|ƒƒƒ}dtjtt|ƒdƒ|_ |SdS(sŽ Str(s) is an RE which matches the literal string |s|. Str(s1, s2, s3, ...) is an RE which matches any of |s1| or |s2| or |s3|... iisStr(%s)RbN( RRmRR R!RdRGRcRLR>(tstrsR ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytStr¼s "cCs)tt|ƒƒ}dt|ƒ|_|S(sH Any(s) is an RE which matches any character in the string |s|. sAny(%s)(R$RRLR>(R R ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytAnyÈscCsMt|ƒ}|jdt ƒ|jtƒt|ƒ}dt|ƒ|_|S(sp AnyBut(s) is an RE which matches any character (including newline) which is not in the string |s|. is AnyBut(%s)(RtinsertRRR$RLR>(R trangesR ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytAnyButÑs    RFsT AnyChar is an RE which matches any single character (including a newline). tAnyCharcCsÂ|r;tt|ƒt|ƒdƒ}d||f|_nƒg}xRtdt|ƒdƒD]8}|jtt||ƒt||dƒdƒƒqZWttt|ƒƒ}dt |ƒ|_|S(s Range(c1, c2) is an RE which matches any single character in the range |c1| to |c2| inclusive. Range(s) where |s| is a string of even length is an RE which matches any single character in the ranges |s[0]| to |s[1]|, |s[2]| to |s[3]|,... is Range(%s,%s)iis Range(%s)( RRR>RYRRRR R!RL(R`RaR RrR ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytRangeäs6cCs t|tƒ}d||_|S(sI Opt(re) is an RE which matches either |re| or the empty string. sOpt(%s)(R RlR>(R_R ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytOptös cCs#tt|ƒƒ}d||_|S(sJ Rep(re) is an RE which matches zero or more repetitions of |re|. sRep(%s)(RvRgR>(R_R ((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pytRepþs cCst|ddƒS(s€ NoCase(re) is an RE which matches the same strings as RE, but treating upper and lower case letters as equivalent. R2i(Rh(R_((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRiscCst|ddƒS(s· Case(re) is an RE which matches the same strings as RE, but treating upper and lower case letters as distinct, i.e. it cancels the effect of any enclosing NoCase(). R2i(Rh(R_((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyRj ss= Bol is an RE which matches the beginning of a line. tBols7 Eol is an RE which matches the end of a line. tEols9 Eof is an RE which matches the end of the file. tEof((+tarrayRGRNtsysRRJR[R]tEOFRR%RRRR$RR(RXR&R\R'RWR:R RgRhRlRTR>RmRoRpRsRtRRuRvRwRiRjRxRyRz(((s6/usr/lib/python2.7/site-packages/Pyrex/Plex/Regexps.pyt s^       m  -'!