ó S‚ ?c@sPddlTddlmZdefd„ƒYZd„Zdd d„ƒYZdS( iÿÿÿÿ(t*(t PlexErrortRegexpSyntaxErrorcBseZRS((t__name__t __module__(((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR scCst|ƒjƒS(se Convert traditional string representation of regular expression |s| into Plex representation. (tREParsertparse_re(ts((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pytresRcBsteZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z RS( cCs)||_d|_d|_|jƒdS(Niÿÿÿÿi(Rtitendtnext(tselfR((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyt__init__s   cCs6|jƒ}|js2|jdt|jƒƒn|S(Ns Unexpected %s(t parse_altR terrortreprtc(R R((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyRs  cCss|jƒ}|jdkro|g}x0|jdkrV|jƒ|j|jƒƒq'Wttt|ƒƒ}n|S(s#Parse a set of alternative regexps.t|(t parse_seqRR tappendtapplytAltttuple(R Rtre_list((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR$s   cCsLg}x0|j r8|jdkr8|j|jƒƒq Wttt|ƒƒS(sParse a sequence of regexps.s|)(R RRt parse_modRtSeqR(R R((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR/scCs‚|jƒ}xo|j r}|jdkr}|jdkrFt|ƒ}n*|jdkrdt|ƒ}n t|ƒ}|jƒqW|S(s7Parse a primitive regexp followed by *, +, ? modifiers.s*+?Rt+(t parse_primR RtReptRep1tOptR (R R((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR6s  cCsÌ|jƒ}|dkr'tdƒ}n¡|dkr<t}nŒ|dkrQt}nw|dkry|jƒ}|jdƒnO|dkr¡|jƒ}|jdƒn'|d kr¼|jƒ}nt|ƒ}|S( sParse a primitive regexp.t.s t^t$t(t)t[t]s\(tgettAnyButtBoltEolRtexpectt parse_charsettChar(R RR((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyRCs"            cCs:g}d}|jdkr.d}|jƒn|jdkrW|jdƒ|jƒnx°|j r |jdkr |jƒ}|jdkrù|jdƒdkrù|jƒ|jƒ}xJtt|ƒt|ƒdƒD]}|jt|ƒƒqÙWqZ|j|ƒqZWt j |dƒ}|r,t |ƒSt |ƒSdS(s5Parse a charset. Does not include the surrounding [].iR!iR&t-tN( RR RR R't lookaheadtxrangetordtchrtstringtjoinR(tAny(R t char_listtinverttc1tc2tatchars((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR,Xs(    $  & cCsU|j}|jd}|_|t|ƒkr?|||_nd|_d|_dS(sAdvance to the next char.iR/N(RR tlenRR (R RR ((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR qs   cCs0|jr|jdƒn|j}|jƒ|S(NsPremature end of string(R RRR (R R((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR'{s    cCs5|j|}|t|jƒkr-|j|SdSdS(sLook ahead n chars.R/N(R R=R(R tntj((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR0‚s  cCs7|j|kr|jƒn|jdt|ƒƒdS(s^ Expect to find character |c| at current position. Raises an exception otherwise. s Missing %sN(RR RR(R R((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR+Šs cCs)tdt|jƒ|j|fƒ‚dS(s1Raise exception to signal syntax error in regexp.s,Syntax error in regexp %s at position %d: %sN(RRRR (R tmess((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyR”s(RRR RRRRRR,R R'R0R+R(((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyRs        N((tRegexpstErrorsRRRR(((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Traditional.pyt s