Exemple #1
0
def p_expr_fromlist_first(t):
    'FromList : TCNAME COMMA FromList'
    t[1] = common_db.Node('TCNAME', [t[1]])
    t[2] = common_db.Node(',', None)
    t[0] = common_db.Node('FromList', [t[1], t[2], t[3]])

    return t
Exemple #2
0
def p_expr_sellist_second(t):
    'SelList : TCNAME'

    t[1] = common_db.Node('TCNAME', [t[1]])
    t[0] = common_db.Node('SelList', [t[1]])

    return t
Exemple #3
0
def p_expr_sellist_first(t):
    'SelList : TCNAME COMMA SelList'

    t[1] = common_db.Node('TCNAME', [t[1]])

    t[2] = common_db.Node(',', None)
    t[0] = common_db.Node('SelList', [t[1], t[2], t[3]])

    return t
Exemple #4
0
def p_expr_swf(t):
    'SFW : SELECT SelList FROM FromList WHERE Cond'
    t[1] = common_db.Node('SELECT', None)
    t[3] = common_db.Node('FROM', None)
    t[5] = common_db.Node('WHERE', None)

    t[0] = common_db.Node('SFW', [t[1], t[2], t[3], t[4], t[5], t[6]])

    return t
Exemple #5
0
def p_expr_condition(t):
    'Cond : TCNAME EQX CONSTANT'
    t[1] = common_db.Node('TCNAME', [t[1]])
    t[2] = common_db.Node('=', None)
    t[3] = common_db.Node('CONSTANT', [t[3]])

    t[0] = common_db.Node('Cond', [t[1], t[2], t[3]])

    return t
Exemple #6
0
def p_expr_query(t):
    'Query : SFW'

    t[0] = common_db.Node('Query', [t[1]])
    common_db.global_syn_tree = t[0]
    check_syn_tree(common_db.global_syn_tree)
    common_db.show(common_db.global_syn_tree)

    return t
Exemple #7
0
def construct_from_node(from_list):
    if from_list:
        if len(from_list) == 1:
            temp_node = common_db.Node(from_list[0], None)
            return common_db.Node('X', [temp_node])
        elif len(from_list) == 2:
            temp_node_first = common_db.Node(from_list[0], None)
            temp_node_second = common_db.Node(from_list[1], None)

            return common_db.Node('X', [temp_node_first, temp_node_second])

        elif len(from_list) > 2:

            right_node = common_db.Node(from_list[len(from_list) - 1], None)

            return common_db.Node('X', [
                construct_from_node(from_list[0:len(from_list) - 1]),
                right_node
            ])
Exemple #8
0
def construct_select_node(wf_node, sel_list):
    if wf_node and len(sel_list) > 0:
        return common_db.Node('Proj', [wf_node], sel_list)
Exemple #9
0
def construct_where_node(from_node, where_list):
    if from_node and len(where_list) > 0:
        return common_db.Node('Filter', [from_node], where_list)
    elif from_node and len(where_list) == 0:  # there is no where clause
        return from_node
Exemple #10
0
def p_expr_fromlist_second(t):
    'FromList : TCNAME'
    t[1] = common_db.Node('TCNAME', [t[1]])
    t[0] = common_db.Node('FromList', [t[1]])
    return t