Cleans the received code (the parser does not like extra spaces not a VALUE
    statement). Returns the cleaned code as a list of lines.

    :param code: The COBOL code to clean

    :return The list of code lines (cleaned)

def _clean_code(code):
    """
    Cleans the received code (the parser does not like extra spaces not a VALUE
    statement). Returns the cleaned code as a list of lines.

    :param code: The COBOL code to clean

    :return The list of code lines (cleaned)
    """
    lines = []
    # cleanup lines, the parser is very sensitive to extra spaces,...
    for l in code.splitlines():
        # remove last .
        if l.endswith('.'):
            l = l[:-1]
        # the parser doe not like VALUE xxx.
        if "VALUE" in l:
            l = l[:l.find("VALUE")]
        # the parser does not like extra spaces between "PIC X(xxx)" and "."
        indent = len(l) - len(l.lstrip())
        tokens = l.split(" ")
        while "" in tokens:
            tokens.remove("")
        if tokens and not tokens[-1].endswith("."):
            tokens[-1] += "."
        lines.append(" " * indent + " ".join(tokens))

    return lines