def generate_ast_nodes_from_assignments(assignments: list):

    all_ast_progs = []

    for a in assignments:
        ast = ASTNode('run', None, [
            ASTNode(a[0]),
            ASTNode(a[1]),
            ASTNode(a[2]),
            ASTNode(a[3]),
            ASTNode(a[4]),
            ASTNode('repeat', a[5], [
                ASTNode(a[6]),
                ASTNode(a[7]),
                ASTNode(a[8]),
                ASTNode(a[9]),
                ASTNode(a[10])
            ]),
            ASTNode(a[11]),
            ASTNode(a[12]),
            ASTNode(a[13]),
            ASTNode(a[14]),
            ASTNode(a[15])
        ])

        ast = remove_null_nodes(ast)

        ##### remove the asts with turn actions in the end
        if not is_last_child_turn(ast):
            ######## Remove the asts with blocks matching the block inside repeat
            if is_ast_repeat_valid(ast):
                all_ast_progs.append(ast)
        ####################################################

    return all_ast_progs
Пример #2
0
def generate_ast_nodes_from_assignments(assignments: list):

    all_ast_progs = []

    for a in assignments:
        ast = ASTNode('run', None, [
            ASTNode(a[12]),
            ASTNode(a[13]),
            ASTNode(a[14]),
            ASTNode(a[15]),
            ASTNode(a[16]),
            ASTNode('repeat_until_goal', 'bool_goal', [
                ASTNode(a[1]),
                ASTNode(a[2]),
                ASTNode(a[3]),
                ASTNode(a[4]),
                ASTNode(a[5]),
                ASTNode('if', a[6], [
                    ASTNode('do', a[6], [
                        ASTNode(a[7]),
                        ASTNode(a[8]),
                        ASTNode(a[9]),
                        ASTNode(a[10]),
                        ASTNode(a[11])
                    ])
                ])
            ])
        ])

        ast = remove_null_nodes(ast)
        all_ast_progs.append(ast)

    return all_ast_progs
Пример #3
0
def generate_ast_nodes_from_assignments(assignments: list):

    all_ast_progs = []

    for a in assignments:
        ast = ASTNode('run', None, [
            ASTNode(a[17]),
            ASTNode(a[18]),
            ASTNode(a[19]),
            ASTNode(a[20]),
            ASTNode(a[21]),
            ASTNode('repeat', a[0], [
                ASTNode('ifelse', a[1], [
                    ASTNode('do', a[1], [
                        ASTNode(a[2]),
                        ASTNode(a[3]),
                        ASTNode(a[4]),
                        ASTNode(a[5]),
                        ASTNode(a[6]),
                    ]),
                    ASTNode('else', a[1], [
                        ASTNode(a[7]),
                        ASTNode(a[8]),
                        ASTNode(a[9]),
                        ASTNode(a[10]),
                        ASTNode(a[11]),
                    ])
                ]),
                ASTNode(a[12]),
                ASTNode(a[13]),
                ASTNode(a[14]),
                ASTNode(a[15]),
                ASTNode(a[16]),
            ]),
            ASTNode(a[22]),
            ASTNode(a[23]),
            ASTNode(a[24]),
            ASTNode(a[25]),
            ASTNode(a[26]),
        ])

        ast = remove_null_nodes(ast)
        all_ast_progs.append(ast)

    return all_ast_progs
def generate_ast_nodes_from_assignments(assignments: list):

    all_ast_progs = []
    for a in assignments:
        ast = ASTNode('run', None, [
            ASTNode(a[0]), ASTNode(a[1]), ASTNode(a[2]), ASTNode(a[3]), ASTNode(a[4]), ASTNode(a[5]), ASTNode(a[6]),
            ASTNode(a[7]), ASTNode(a[8]), ASTNode(a[9]), ASTNode(a[10]),
            ASTNode(a[11]), ASTNode(a[12])

        ])
        # remove the nodes which are phi'
        ast = remove_null_nodes(ast)

        ##### remove the asts with turn actions in the end
        if not is_last_child_turn(ast):
            all_ast_progs.append(ast)
        ####################################################



    return all_ast_progs
def generate_ast_nodes_from_assignments(assignments: list):

    all_ast_progs = []

    for a in assignments:
        ast = ASTNode('run', None, [

            ASTNode(a[10]),  ASTNode(a[11]),
            ASTNode(a[12]),
            ASTNode(a[13]), ASTNode(a[14]),

            ASTNode('repeat', a[0], [
                ASTNode(a[1]), ASTNode(a[2]),
                ASTNode(a[3]),
                ASTNode(a[4]), ASTNode(a[5]), ASTNode(a[6]),
                ASTNode(a[7]),
                ASTNode(a[8]), ASTNode(a[9]),


            ]),


            ASTNode(a[15]), ASTNode(a[16]),
            ASTNode(a[17]),
            ASTNode(a[18]), ASTNode(a[19]),


        ])
        # remove the nodes which are phi'
        ast = remove_null_nodes(ast)

        ####### Allow asts with blocks of code NOT matching inner block of repeat
        if is_ast_repeat_valid(ast):
            all_ast_progs.append(ast)

    return all_ast_progs