def str_location(loc):
    """
    This function takes a location from a clingo AST and transforms it into a
    readable format.
    """
    begin = loc["begin"]
    end   = loc["end"]
    ret = "{}:{}:{}".format(begin["filename"], begin["line"], begin["column"])
    dash = True
    eq = begin["filename"] == end["filename"]
    if not eq:
        ret += "{}{}".format("-" if dash else ":", end["filename"])
        dash = False
    eq = eq and begin["line"] == end["line"]
    if not eq:
        ret += "{}{}".format("-" if dash else ":", end["line"])
        dash = False
    eq = eq and begin["column"] == end["column"]
    if not eq:
        ret += "{}{}".format("-" if dash else ":", end["column"])
        dash = False
    return ret