def _compress_tokens(tokens):
    recorder = None
    def _edge_case_stray_end_quoted(tokens, index):
        tokens[index] = Token(type=TokenType.UnquotedLiteral,
                              content=tokens[index].content,
                              line=tokens[index].line,
                              col=tokens[index].col)
    tokens_len = len(tokens)
    index = 0
    with _EdgeCaseStrayParens() as edge_case_stray_parens:
        edge_cases = [
            (_is_paren_type, edge_case_stray_parens),
            (_is_end_quoted_type, _edge_case_stray_end_quoted),
        ]
        while index < tokens_len:
            recorder = _find_recorder(recorder, tokens, index)
            if recorder is not None:
                result = recorder.consume_token(tokens, index, tokens_len)
                if result is not None:
                    (index, tokens_len, tokens) = result
                    recorder = None
            else:
                for matcher, handler in edge_cases:
                    if matcher(tokens[index].type):
                        handler(tokens, index)
            index += 1
    return tokens