def get_mapvars(mapfile):
    """Read the sugar .map file and return a dictionary
    where the key is the variable name and the value is the (start,r0,r1)
    where r0 is the first ordinal and r1 is the last. Sugar uses uniary encoding."""
    mapvars = {}
    with open(mapfile,"r") as f:
        for line in f:
            (var,name,start,_) = line.strip().split(" ")
            if var=="int":
                if ".." in _:
                    (r0,r1) = _.split("..")
                else:
                    (r0,r1) = int(_),int(_)
            else:
                raise RuntimeError("Only variables of type {} are supported".format(var))
            start = int(start)
            r0 = int(r0)
            r1 = int(r1)
            mapvars[name] = (start,r0,r1)
    return mapvars