def normalize_mapping_line(mapping_line, previous_source_column=<NUM_LIT:0>):
if not mapping_line:<EOL><INDENT>return [], previous_source_column<EOL><DEDENT>def regenerate(segment):<EOL><INDENT>if len(segment) == <NUM_LIT:5>:<EOL><INDENT>result = (record[<NUM_LIT:0>], segment[<NUM_LIT:1>], segment[<NUM_LIT:2>], record[<NUM_LIT:3>], segment[<NUM_LIT:4>])<EOL><DEDENT>else:<EOL><INDENT>result = (record[<NUM_LIT:0>], segment[<NUM_LIT:1>], segment[<NUM_LIT:2>], record[<NUM_LIT:3>])<EOL><DEDENT>record[:] = [<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>]<EOL>return result<EOL><DEDENT>record = [<NUM_LIT:0>, <NUM_LIT:0>, <NUM_LIT:0>, previous_source_column]<EOL>result = []<EOL>regen_next = True<EOL>for segment in mapping_line:<EOL><INDENT>if not segment:<EOL><INDENT>continue<EOL><DEDENT>record[<NUM_LIT:0>] += segment[<NUM_LIT:0>]<EOL>if len(segment) == <NUM_LIT:1>:<EOL><INDENT>if result and len(result[-<NUM_LIT:1>]) != <NUM_LIT:1>:<EOL><INDENT>result.append((record[<NUM_LIT:0>],))<EOL>record[<NUM_LIT:0>] = <NUM_LIT:0><EOL>regen_next = True<EOL><DEDENT>continue<EOL><DEDENT>record[<NUM_LIT:3>] += segment[<NUM_LIT:3>]<EOL>if len(segment) == <NUM_LIT:5> or regen_next or segment[<NUM_LIT:1>] or segment[<NUM_LIT:2>] or (<EOL>record[<NUM_LIT:0>] != record[<NUM_LIT:3>]):<EOL><INDENT>result.append(regenerate(segment))<EOL>regen_next = len(segment) == <NUM_LIT:5><EOL><DEDENT><DEDENT>return result, record[<NUM_LIT:3>]<EOL>
Often times the position will remain stable, such that the naive
process will end up with many redundant values; this function will
iterate through the line and remove all extra values.