 def getInt ( i ) : <EOL> d = '<STR_LIT>' <EOL> for c in i : 
 if not c . isdigit ( ) : 
 def getInt ( i ) : <EOL> d = '<STR_LIT>' <EOL> for c in i : <EOL> if not c . isdigit ( ) : <EOL> return d , c <EOL> d = d + c <EOL> ss = '<STR_LIT>' <EOL> BEGIN , END , ADD , NUMBER , CHAR , ATTS , STR = range ( <NUM_LIT:7> ) <EOL> def tokenize ( s ) : <EOL> s = iter ( s ) <EOL> for c in s : <EOL> if c != '<STR_LIT>' : <EOL> yield CHAR , c <EOL> continue <EOL> c = s . next ( ) <EOL> if c != '<STR_LIT:[>' : <EOL> yield CHAR , '<STR_LIT>' <EOL> yield CHAR , c <EOL> continue <EOL> yield BEGIN , c <EOL> while <NUM_LIT:1> : <EOL> d , c = getInt ( s ) <EOL> yield NUMBER , d <EOL> if c == '<STR_LIT:m>' : <EOL> yield END , c <EOL> break <EOL> def parser ( tokens ) : <EOL> tokens = iter ( tokens ) <EOL> sofar = '<STR_LIT>' <EOL> for tp , token in tokens : <EOL> if tp == CHAR : <EOL> sofar += token <EOL> if tp == BEGIN : <EOL> if sofar : <EOL> yield STR , sofar <EOL> sofar = '<STR_LIT>' <EOL> atts = [ ] <EOL> for tp , token in tokens : <EOL> if tp == END : <EOL> break <EOL> atts . append ( int ( token ) ) <EOL> yield ATTS , atts <EOL> if sofar : <EOL> yield STR , sofar <EOL> sofar = '<STR_LIT>' <EOL> def prettylist ( l ) : <EOL> res = [ ] <EOL> for tp , data in l : <EOL> if tp == ATTS : <EOL> res . append ( '<STR_LIT>' + '<STR_LIT:U+002CU+0020>' . join ( map ( str , data ) ) + '<STR_LIT>' ) <EOL> else : <EOL> res . append ( repr ( data ) + '<STR_LIT:\n>' ) <EOL> return '<STR_LIT>' . join ( res ) <EOL> def prettystring ( s ) : <EOL> return prettylist ( ( parser ( tokenize ( s ) ) ) ) <EOL> def _test ( ) : <EOL> print prettystring ( ss ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> _test ( ) </s>
