<commit_before>import re

__all__ = ["recursively_remove_ltac"]

LTAC_REG = re.compile(r'^\s*(?:Local\s+|Global\s+)?Ltac\s+([^\s]+)', re.MULTILINE)

def recursively_remove_ltac(statements, exclude_n=3):
    """Removes any Ltac statement which is not used later in
    statements.  Does not remove any code in the last exclude_n
    statements."""
    rtn = list(reversed(statements))[:exclude_n]
    for statement in reversed(statements)[exclude_n:]:
        match = LTAC_REG.search(statement)
        if match:
            ltac_name = match.groups()[0]
            # search for the name of the tactic, by itself
            reg = re.compile('\b%s\b' % ltac_name, re.MULTILINE)
            if any(reg.search(other_statement) for other_statement in rtn):
                rtn.append(statement)
        else:
            rtn.append(statement)
    return list(reversed(rtn))<commit_msg>Add a comment with a TODO<commit_after>import re

__all__ = ["recursively_remove_ltac"]

LTAC_REG = re.compile(r'^\s*(?:Local\s+|Global\s+)?Ltac\s+([^\s]+)', re.MULTILINE)

def recursively_remove_ltac(statements, exclude_n=3):
    """Removes any Ltac statement which is not used later in
    statements.  Does not remove any code in the last exclude_n
    statements."""
    # TODO(jgross): Figure out what the optimal exclude_n is.  It's
    # probably 1 or 2, but I don't want to accidentally exclude the
    # line generating the bug, so I'm trying to be a bit safer
    rtn = list(reversed(statements))[:exclude_n]
    for statement in reversed(statements)[exclude_n:]:
        match = LTAC_REG.search(statement)
        if match:
            ltac_name = match.groups()[0]
            # search for the name of the tactic, by itself
            reg = re.compile('\b%s\b' % ltac_name, re.MULTILINE)
            if any(reg.search(other_statement) for other_statement in rtn):
                rtn.append(statement)
        else:
            rtn.append(statement)
    return list(reversed(rtn))
{'fraction_non_alphanumeric': 0.11443037974683544, 'fraction_numerical': 0.0030379746835443038, 'mean_word_length': 2.9838709677419355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1970068', 'n_tokens_mistral': 657, 'n_tokens_neox': 619, 'n_words': 171}