def parse_operand(string, location, tokens):
    """Parse instruction operand.
    """
    sizes = {
        "dqword"  : 128,
        "pointer" : 72,
        "qword"   : 64,
        "pointer" : 40,
        "dword"   : 32,
        "word"    : 16,
        "byte"    : 8,
        "bit"     : 1,
    }

    if "immediate" in tokens:
        imm_str = "".join(tokens["immediate"])
        base = 16 if imm_str.startswith("0x") or imm_str.startswith("-0x") else 10

        immediate = int(imm_str, base)

        oprnd = ReilImmediateOperand(immediate)

    if "register" in tokens:
        if tokens["register"] in ["e", "empty"]:
            oprnd = ReilEmptyOperand()

            oprnd.size = 0
        else:
            name = tokens["register"]

            oprnd = ReilRegisterOperand(name)

    if "size" in tokens:
        size = int(sizes[tokens["size"]])

        oprnd.size = size

    return [oprnd]
dataset/ETHPy150Open programa-stic/barf-project/barf/barf/core/reil/reilparser.py/parse_operand/original