def untokenize(tokens):
    """
    Reverse of tokenize, turning a token stream into a string.
    """
    output = []
    last_was_id = False
    for token in tokens:
        if token.type == "identifier":
            if last_was_id:
                output.append(" ")
            last_was_id = True
        else:
            last_was_id = False
        output.append(token.value)
    return ''.join(output)