예제 #1
0
def program_code(num):
    data_begin = find.attribute(num, "data_begin")
    index = data_begin
    obj_type, command = read.entity(index)
    while obj_type != "none":
        display.command_with_args(index)
        com_name, args = read.command_with_args(index)
        index += memory_control.determine_object_size("command_with_args", args)
        obj_type, command = read.entity(index)
예제 #2
0
def command_with_args(num):
    print(num, end=" ")
    entity(num)
    args = []
    obj_type, command_name = read.entity(num)
    index = num + 2
    for i in range(commands_args_number[commands_abbreviation[command_name]]):
        obj_type, value = read.entity(index)
        print("\t", end="")
        entity(index)
        index += memory_control.determine_object_size(obj_type, value)
예제 #3
0
def dictionary_item_part(num, part):
    if part == "dictionary":
        kind, result = read.entity(num + 2)
    elif part == "key":
        kind, result = read.entity(num + 4)
    elif part == "value":
        kind, result = read.entity(num + 6)
    else:
        raise LowerCommandError(f"Несуществующий атрибут элемента словаря "
                                f"{part}")
    return kind, result
예제 #4
0
def segment_body(num):
    data_begin, data_end = data_range(num)
    top = find.attribute(num, "first_empty_cell")
    index = data_begin
    obj_type, obj_value = read.entity(index)
    while index < top:
        print(index, end=" ")
        display.entity(index)
        index += memory_control.determine_object_size(obj_type, obj_value)
        if index < data_end:
            obj_type, obj_value = read.entity(index)
    print()
예제 #5
0
def namespace_items(num, last=False):
    data_begin, data_end = data_range(num)
    if last:
        top = find.attribute(num, "first_empty_cell")
        data_end = top
    for i in range(data_begin, data_end, 2):
        link_type, link = read.entity(i)
        draw.dictionary_item(link)
예제 #6
0
def entity(num):
    kind = read.kind(num)
    if kind == "segment":
        kind = seg_types[find.attribute(num, "type")]
        if kind not in read_segment_dictionary:
            raise LowerCommandError(f"Неподдерживаемый тип сегмента для чтения"
                                    f" {kind}")
        return kind, read_segment_dictionary[kind](num)
    else:
        return read.entity(num)
예제 #7
0
def namespace_key(num, key):
    data_begin, data_end = find.data_range(num)
    top = find.attribute(num, "first_empty_cell")
    need_key_type, need_key = key
    for i in range(data_begin, top, 2):
        item_type, item_value = read.entity(i)
        key_type, key_link = find.dictionary_item_key(item_value)
        key_value_type, key_value = entity(key_link)
        if key_value_type == need_key_type and key_value == need_key:
            return "link", item_value + 6
    return None, None
예제 #8
0
파일: change.py 프로젝트: gitter-badger/Yo
def relative_links(num):
    data_begin = find.attribute(num, "data_begin")
    data_end = find.attribute(num, "segment_end")
    index = data_begin
    while index < data_end:
        obj_type, obj_value = read.entity(index)
        if obj_type == "link":
            write.entity(index, "link", data_begin + obj_value)
            index += memory_control.determine_object_size(obj_type, obj_value)
        elif obj_type == "chars":
            index += memory_control.determine_object_size(obj_type, obj_value)
        else:
            index += 2
예제 #9
0
파일: objects.py 프로젝트: gitter-badger/Yo
def Sub_object(parent, index):
    par_type, par_value = parent
    ind_arg_type, ind_type, ind_value = link.unpack(index)
    if ind_type == "link":
        ind_type, ind_value = link.get_link(ind_value)
    if ind_type != "number":
        raise UndefinedBehaviour(f"Получение элемента командой Sob с индексом"
                                 f"типа {ind_type} не определено")
    if ind_value < 0:
        raise UndefinedBehaviour(f"Получение элемента командой Sob с "
                                 f"отрицательным индексом не определено")
    if ind_value == 0:
        raise UndefinedBehaviour(f"Получение элемента командой Sob с "
                                 f"нулевым индексом не определено")
    if par_type == "link":
        kind, link_value = read.entity(par_value)
        if kind == "link":
            kind = find.kind(link_value)
            par_value = link_value
        if kind == "string_segment":
            elem_type, elem_value = get.string_segment_element(
                par_value, ind_value)
        elif kind == "list_segment":
            elem_type, elem_value = get.list_segment_element(
                par_value, ind_value)
        else:
            raise UndefinedBehaviour(f"Получение элемента командой Sob для "
                                     f"типа {kind} не определено")
        if elem_type == "none":
            num = append.data_segment("none", 0)
            append.memory_stack("link", num)
        elif elem_type == "link":
            append.memory_stack("link", elem_value)
        else:
            raise LowerCommandError(f"Поиск элемента не может возращать объект"
                                    f"типа {elem_type}")
    else:
        raise UndefinedArgument(f"Поведение команды Sob с аргументом типа"
                                f"{par_type} не определено")
예제 #10
0
def attribute(num, name):
    index, kind = find_attribute(num, name)
    kind, value = read.entity(index)
    return value
예제 #11
0
def link_on_link(arg):
    link_type, link_value = arg
    link_type, str_link = read.entity(link_value)
    entity(str_link)