<s> """<STR_LIT>""" <EOL> import ellyChar <EOL> spc = u'<STR_LIT:U+0020>' <EOL> lbr = u'<STR_LIT:[>' <EOL> rbr = u'<STR_LIT:]>' <EOL> bs = u'<STR_LIT:\\>' <EOL> SPs = u'<STR_LIT>' <EOL> def normalize ( strg ) : <EOL> """<STR_LIT>""" <EOL> s = [ spc ] <EOL> f = False <EOL> lc = '<STR_LIT>' <EOL> for c in strg : <EOL> if c == spc : <EOL> if f or s [ - <NUM_LIT:1> ] == spc : <EOL> continue <EOL> elif c == lbr : <EOL> f = True <EOL> if s [ - <NUM_LIT:1> ] == spc : <EOL> s . pop ( ) <EOL> elif c == rbr : <EOL> f = False <EOL> elif lc == bs and c == '<STR_LIT:s>' : <EOL> s . pop ( ) <EOL> c = ellyChar . RS <EOL> lc = c <EOL> s . append ( c ) <EOL> return u'<STR_LIT>' . join ( s ) . strip ( SPs ) <EOL> class DefinitionLine ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , line , twoway = True ) : <EOL> """<STR_LIT>""" <EOL> self . left = None <EOL> self . tail = None <EOL> if line == None or len ( line ) == <NUM_LIT:0> : <EOL> return <EOL> k = line . find ( '<STR_LIT>' ) <EOL> if k < <NUM_LIT:0> : <EOL> if not twoway : return <EOL> k = line . find ( '<STR_LIT>' ) <EOL> if k < <NUM_LIT:0> : return <EOL> self . left = normalize ( line [ : k ] ) <EOL> self . tail = normalize ( line [ k + <NUM_LIT:2> : ] ) <EOL> def nextInTail ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . tail == None or len ( self . tail ) == <NUM_LIT:0> : <EOL> return None <EOL> k = self . tail . find ( spc ) <EOL> if k < <NUM_LIT:0> : <EOL> t = self . tail <EOL> self . tail = '<STR_LIT>' <EOL> else : <EOL> t = self . tail [ : k ] <EOL> self . tail = self . tail [ k + <NUM_LIT:1> : ] <EOL> return t <EOL> def isEmptyTail ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( self . tail == None or len ( self . tail ) == <NUM_LIT:0> ) <EOL> def isEmptyLeft ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( self . left == None or len ( self . left ) == <NUM_LIT:0> ) </s>
