ó V~?c@s\ddlmZddlZddlmZddlmZddd„ƒYZd„ZdS( iÿÿÿÿ(tcopyN(tmaxint(t TupleTypet TransitionMapcBs°eZdZdZdZddd„Zed„Zed„Z dd„Z e d„Z e e d„Zd„Zd„Zd „Zd „Zd „Zd „Zd „Zd„ZRS(s? A TransitionMap maps an input event to a set of states. An input event is one of: a range of character codes, the empty string (representing an epsilon move), or one of the special symbols BOL, EOL, EOF. For characters, this implementation compactly represents the map by means of a list: [code_0, states_0, code_1, states_1, code_2, states_2, ..., code_n-1, states_n-1, code_n] where |code_i| is a character code, and |states_i| is a set of states corresponding to characters with codes |c| in the range |code_i| <= |c| <= |code_i+1|. The following invariants hold: n >= 1 code_0 == -maxint code_n == maxint code_i < code_i+1 for i in 0..n-1 states_0 == states_n-1 Mappings for the special events '', BOL, EOL, EOF are kept separately in a dictionary. cCs>|st itg}n|s(i}n||_||_dS(N(Rtmaptspecial(tselfRR((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Transitions.pyt__init__,s   c CsŽt|ƒ|krw|\}}|j|ƒ}|j|ƒ}|j}xB||krsd||d|<|d}qHWnd|j|ƒ||tkr(d}q¬d|j|ƒ}nn|tkrdd|j|dƒ}nH||dkr†|j|ƒ}n&d|j|ƒ|j|dƒf}|j|||ƒndS(Ntanys< %ss> %sis%s..%s(Rt dump_charR3(RR RRR4tk((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Transitions.pyR2Ñs    cCs8d|kodknr,tt|ƒƒSd|SdS(Niiÿschr(%d)(treprtchr(RR ((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Transitions.pyR7áscCs$|jd||j|ƒfƒdS(Ns %s --> %s (twritetdump_set(RtkeyRR4((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Transitions.pyR3çscCs t|ƒS(N(R((RR((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Transitions.pyR<êsN(t__name__t __module__t__doc__R$RRRRRRRRRRR R R.R0R5R2R7R3R<(((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Transitions.pyR s"         cCsK|jƒ}g}x"|D]}|jd|jƒqWdtj|dƒS(NsS%ds[%s]R&(tkeysRtnumberR)R*(Rt state_listtstr_listtstate((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Transitions.pyR(õs   ((RR)tsysRttypesRRR((((s:/usr/lib/python2.7/site-packages/Pyrex/Plex/Transitions.pyts  è