def parse_baxter(reading):
initial = '<STR_LIT>'<EOL>medial = '<STR_LIT>'<EOL>final = '<STR_LIT>'<EOL>tone = '<STR_LIT>'<EOL>inienv = True<EOL>medienv = False<EOL>finenv = False<EOL>tonenv = False<EOL>inichars = "<STR_LIT>"<EOL>chars = list(reading)<EOL>for char in chars:<EOL><INDENT>if char in '<STR_LIT>' and not finenv:<EOL><INDENT>inienv,medienv,finenv,tonenv = False,True,False,False<EOL><DEDENT>elif char not in inichars or finenv:<EOL><INDENT>if char in '<STR_LIT>':<EOL><INDENT>inienv,medienv,finenv,tonenv = False,False,False,True<EOL><DEDENT>else:<EOL><INDENT>inienv,medienv,finenv,tonenv = False,False,True,False<EOL><DEDENT><DEDENT>if inienv:<EOL><INDENT>initial += char<EOL><DEDENT>if medienv:<EOL><INDENT>medial += char<EOL><DEDENT>if finenv:<EOL><INDENT>final += char<EOL><DEDENT>if tonenv:<EOL><INDENT>tone += char<EOL><DEDENT><DEDENT>if not tone and final[-<NUM_LIT:1>] in '<STR_LIT>':<EOL><INDENT>tone = '<STR_LIT:R>'<EOL><DEDENT>elif not tone:<EOL><INDENT>tone = '<STR_LIT:P>'<EOL><DEDENT>if '<STR_LIT>' not in medial and '<STR_LIT:y>' in initial:<EOL><INDENT>medial += '<STR_LIT>'<EOL><DEDENT>if final[<NUM_LIT:0>] in '<STR_LIT:u>' and '<STR_LIT:w>' not in medial:<EOL><INDENT>medial = '<STR_LIT:w>' + medial<EOL><DEDENT>return initial,medial,final,tone<EOL>
Parse a Baxter string and render it with all its contents, namely
initial, medial, final, and tone.