def parse_operand(string, location, tokens):

    if "immediate_operand" in tokens:
        size = arch_info.operand_size
        oprnd = ArmImmediateOperand("".join(tokens["immediate_operand"]), size)

    if "register_operand" in tokens:
        oprnd =  process_register(tokens["register_operand"])

        # TODO: Figure out where to really store this flag, instead of in the register class
        if "wb" in tokens["register_operand"]:
            oprnd.wb = True


    if "memory_operand" in tokens:
        mem_oprnd = tokens["memory_operand"]

        if "offset" in mem_oprnd:
            index_type = ARM_MEMORY_INDEX_OFFSET
            mem_oprnd = mem_oprnd["offset"]
        elif "pre" in mem_oprnd:
            index_type = ARM_MEMORY_INDEX_PRE
            mem_oprnd = mem_oprnd["pre"]
        elif "post" in mem_oprnd:
            index_type = ARM_MEMORY_INDEX_POST
            mem_oprnd = mem_oprnd["post"]
        else:
            raise Exception("Unknown index type.")

        reg_base = process_register(mem_oprnd["base"])
        disp = mem_oprnd.get("disp", None)
        disp_minus = True if mem_oprnd.get("minus") else False

        if disp:
            if "shift" in disp:
                displacement = process_shifted_register(disp["shift"])
            elif "reg" in disp:
                displacement = process_register(disp["reg"])
            elif "imm" in disp:
                displacement = ArmImmediateOperand("".join(disp["imm"]), arch_info.operand_size)
            else:
                raise Exception("Unknown displacement type.")
        else:
            displacement = None

        size = arch_info.operand_size
        # TODO: Add sizes for LDR/STR variations (half word, byte, double word)
        oprnd = ArmMemoryOperand(reg_base, index_type, displacement, disp_minus, size)

    if "shifted_register" in tokens:
        oprnd =  process_shifted_register(tokens["shifted_register"])

    if "register_list_operand" in tokens:
        parsed_reg_list = tokens["register_list_operand"]
        reg_list = []
        for reg_range in parsed_reg_list:
            start_reg = process_register(reg_range[0])
            if len(reg_range) > 1:
                end_reg = process_register(reg_range[1])
                reg_list.append([start_reg, end_reg])
            else:
                reg_list.append([start_reg])

        oprnd = ArmRegisterListOperand(reg_list, reg_list[0][0].size)

    return oprnd
Capitalize a value. The first character will be uppercase, all others
dataset/ETHPy150Open programa-stic/barf-project/barf/barf/arch/arm/armparser.py/parse_operand--crossover with--dataset/ETHPy150Open GoogleCloudPlatform/appengine-flask-skeleton/lib/jinja2/filters.py/do_capitalize