Beispiel #1
0
def p_expression_string_f(t):
    '''expression_f : LENGTH PAR_ABRE expression PAR_CIERRA
                    | TRIM PAR_ABRE expression PAR_CIERRA
                    | MD5 PAR_ABRE expression PAR_CIERRA
                    | SHA256 PAR_ABRE expression PAR_CIERRA
                    | DECODE PAR_ABRE expression COMA expression PAR_CIERRA
                    | ENCODE PAR_ABRE expression CASTEO BYTEA COMA expression PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS DATE PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS INTEGER PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS BIGINT PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS DECIMAL PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS NUMERIC PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS REAL PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS MONEY PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS CHARACTER PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS CHAR PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS TEXT PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS TIME PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS VARCHAR PAR_CIERRA
                    | CONVERT PAR_ABRE expression AS TIMESTAMP PAR_CIERRA
                    | GET_BYTE PAR_ABRE expression CASTEO BYTEA COMA expression PAR_CIERRA
                    | SET_BYTE PAR_ABRE expression CASTEO BYTEA COMA expression COMA expression PAR_CIERRA'''
    global num_nodo
    try:
        if str(t[1]).lower() == "decode":
            t[0] = agrupar(t[1], t[3], t[5], t.lineno(1), t.lexpos(1), num_nodo)
        elif str(t[1]).lower() == "encode" or str(t[1]).lower() == "get_byte" or str(t[1]).lower() == "set_byte":
            t[0] = agrupar(t[1], t[3], t[7], t.lineno(1), t.lexpos(1), num_nodo)
        else:
            t[0] = agrupar(t[1], t[3], None, t.lineno(1), t.lexpos(1), num_nodo)
        num_nodo += 3
    except:
        print('No funciona la parte de agrupar')
Beispiel #2
0
def p_expression_trigonometric_f(t):
    '''expression_f : ACOS PAR_ABRE expression PAR_CIERRA
                    | ACOSD PAR_ABRE expression PAR_CIERRA
                    | ASIN PAR_ABRE expression PAR_CIERRA
                    | ASIND PAR_ABRE expression PAR_CIERRA
                    | ATAN PAR_ABRE expression PAR_CIERRA
                    | ATAND PAR_ABRE expression PAR_CIERRA
                    | ATAN2 PAR_ABRE expression COMA expression PAR_CIERRA
                    | ATAN2D PAR_ABRE expression COMA expression PAR_CIERRA
                    | COS PAR_ABRE expression PAR_CIERRA
                    | COSD PAR_ABRE expression PAR_CIERRA
                    | COT PAR_ABRE expression PAR_CIERRA
                    | COTD PAR_ABRE expression PAR_CIERRA
                    | SIN PAR_ABRE expression PAR_CIERRA
                    | SIND PAR_ABRE expression PAR_CIERRA
                    | TAN PAR_ABRE expression PAR_CIERRA
                    | TAND PAR_ABRE expression PAR_CIERRA
                    | SINH PAR_ABRE expression PAR_CIERRA
                    | COSH PAR_ABRE expression PAR_CIERRA
                    | TANH PAR_ABRE expression PAR_CIERRA
                    | ASINH PAR_ABRE expression PAR_CIERRA
                    | ACOSH PAR_ABRE expression PAR_CIERRA
                    | ATANH PAR_ABRE expression PAR_CIERRA '''

    global num_nodo
    try:
        if str(t[1]).lower() == "atan2" or str(t[1]).lower() == "atan2d":
            t[0]=agrupar(t[1],t[3],t[5],t.lineno(1),t.lexpos(1),num_nodo)
        else:
            t[0]=agrupar(t[1],t[3],None,t.lineno(1),t.lexpos(1),num_nodo)
        num_nodo+=3
    except:
        print('No funciona la parte de agrupar')
Beispiel #3
0
def p_expression_agrupar(t):
    '''expression : SUM PAR_ABRE expression PAR_CIERRA
                    | COUNT PAR_ABRE expression PAR_CIERRA
                    | AVG PAR_ABRE expression PAR_CIERRA
                    | MAX PAR_ABRE expression PAR_CIERRA
                    | MIN PAR_ABRE expression PAR_CIERRA
                    | ABS PAR_ABRE expression PAR_CIERRA
                    | CBRT PAR_ABRE expression PAR_CIERRA
                    | CEIL PAR_ABRE expression PAR_CIERRA
                    | CEILING PAR_ABRE expression PAR_CIERRA 
                    | DEGREES PAR_ABRE expression PAR_CIERRA
                    | DIV PAR_ABRE expression PAR_CIERRA
                    | EXP PAR_ABRE expression PAR_CIERRA
                    | FACTORIAL PAR_ABRE expression PAR_CIERRA 
                    | FLOOR PAR_ABRE expression PAR_CIERRA
                    | GCD PAR_ABRE expression PAR_CIERRA
                    | LN PAR_ABRE expression PAR_CIERRA
                    | LOG PAR_ABRE expression PAR_CIERRA
                    | MOD PAR_ABRE expression PAR_CIERRA
                    | PI PAR_ABRE expression PAR_CIERRA
                    | POWER PAR_ABRE expression PAR_CIERRA
                    | RADIANS PAR_ABRE expression PAR_CIERRA
                    | ROUND PAR_ABRE expression PAR_CIERRA'''
    global num_nodo
    try:
        t[0] = agrupar(t[1], t[3], t.lineno, t.lexpos, num_nodo)
        num_nodo += 3
    except:
        print('No funciona la parte de agrupar')
Beispiel #4
0
def p_expression(t):
    '''expression_f : SUBSTRING PAR_ABRE expression COMA expression COMA expression PAR_CIERRA
                    | SUBSTR PAR_ABRE expression COMA expression COMA expression PAR_CIERRA'''
    global num_nodo
    try:
        t[0] = agrupar(t[1], t[3],t[7], t.lineno(1), t.lexpos(1), num_nodo)
        num_nodo += 8
    except:
        print('Problema con substring')
Beispiel #5
0
def p_expression_agrupar_f(t):
    '''expression_f : SUM PAR_ABRE expression PAR_CIERRA
                    | COUNT PAR_ABRE expression PAR_CIERRA
                    | AVG PAR_ABRE expression PAR_CIERRA
                    | MAX PAR_ABRE expression PAR_CIERRA
                    | MIN PAR_ABRE expression PAR_CIERRA
                    | ABS PAR_ABRE expression PAR_CIERRA
                    | CBRT PAR_ABRE expression PAR_CIERRA
                    | CEIL PAR_ABRE expression PAR_CIERRA
                    | CEILING PAR_ABRE expression PAR_CIERRA 
                    | DEGREES PAR_ABRE expression PAR_CIERRA
                    | DIV PAR_ABRE expression COMA expression PAR_CIERRA
                    | EXP PAR_ABRE expression PAR_CIERRA
                    | FACTORIAL PAR_ABRE expression PAR_CIERRA 
                    | FLOOR PAR_ABRE expression PAR_CIERRA
                    | GCD PAR_ABRE expression COMA expression PAR_CIERRA
                    | LN PAR_ABRE expression PAR_CIERRA
                    | LOG PAR_ABRE expression PAR_CIERRA
                    | MOD PAR_ABRE expression COMA expression PAR_CIERRA
                    | PI PAR_ABRE PAR_CIERRA
                    | POWER PAR_ABRE expression COMA expression PAR_CIERRA
                    | RADIANS PAR_ABRE expression PAR_CIERRA
                    | ROUND PAR_ABRE expression PAR_CIERRA
                    | SIGN PAR_ABRE expression PAR_CIERRA
                    | SQRT PAR_ABRE expression PAR_CIERRA
                    | WIDTH_BUCKET PAR_ABRE expression COMA expression COMA expression COMA expression PAR_CIERRA
                    | TRUNC PAR_ABRE expression PAR_CIERRA
                    | RANDOM PAR_ABRE PAR_CIERRA '''
    global num_nodo
    try:
        if str(t[1]).lower() == "div" or str(t[1]).lower() == "gcd" or str(t[1]).lower() == "mod" or str(t[1]).lower() == "power":
            t[0] = agrupar(t[1], t[3], t[5], t.lineno(1), t.lexpos(1), num_nodo)
        elif str(t[1]).lower() == "pi" or str(t[1]).lower() == "random":
            auxiliar = primitivo(t.lineno(1), t.lexpos(1), 0, tipo_primitivo.INTEGER, num_nodo)
            t[0] = agrupar(t[1], auxiliar, None, t.lineno(1), t.lexpos(1), num_nodo)
        else:
            t[0] = agrupar(t[1], t[3], None, t.lineno(1), t.lexpos(1), num_nodo)
        num_nodo += 3
    except:
        print('No funciona la parte de agrupar')
Beispiel #6
0
def p_expression_time_f(t):
    '''expression_f : NOW PAR_ABRE PAR_CIERRA
                    | TIMESTAMP CADENA
                    | CURRENT_TIME
                    | CURRENT_DATE 
                    | DATE_PART PAR_ABRE expression COMA INTERVAL expression PAR_CIERRA
                    | EXTRACT PAR_ABRE YEAR FROM TIMESTAMP expression PAR_CIERRA
                    | EXTRACT PAR_ABRE MONTH FROM TIMESTAMP expression PAR_CIERRA
                    | EXTRACT PAR_ABRE DAY FROM TIMESTAMP expression PAR_CIERRA
                    | EXTRACT PAR_ABRE HOUR FROM TIMESTAMP expression PAR_CIERRA
                    | EXTRACT PAR_ABRE MINUTE FROM TIMESTAMP expression PAR_CIERRA
                    | EXTRACT PAR_ABRE SECOND FROM TIMESTAMP expression PAR_CIERRA'''

    global num_nodo
    try:
        if str(t[1]).lower() == "date_part" or str(t[1]).lower() == "extract":
            if str(t[3]) == "YEAR":
                t[3] = primitivo(t.lineno(1), t.lexpos(1), "year", tipo_primitivo.CHAR, num_nodo)
            elif str(t[3]) == "MONTH":
                t[3] = primitivo(t.lineno(1), t.lexpos(1), "month", tipo_primitivo.CHAR, num_nodo)
            elif str(t[3]) == "DAY":
                t[3] = primitivo(t.lineno(1), t.lexpos(1), "day", tipo_primitivo.CHAR, num_nodo)
            elif str(t[3]) == "HOUR":
                t[3] = primitivo(t.lineno(1), t.lexpos(1), "hour", tipo_primitivo.CHAR, num_nodo)
            elif str(t[3]) == "MINUTE":
                t[3] = primitivo(t.lineno(1), t.lexpos(1), "minute", tipo_primitivo.CHAR, num_nodo)
            elif str(t[3]) == "SECOND":
                t[3] = primitivo(t.lineno(1), t.lexpos(1), "second", tipo_primitivo.CHAR, num_nodo)

            t[0] = agrupar(t[1], t[3], t[6], t.lineno(1), t.lexpos(1), num_nodo)
        elif str(t[1]).lower() == "now" or str(t[1]).lower() == "timestamp" or str(t[1]).lower() == "current_date" or str(t[1]).lower() == "current_time":
            auxiliar = primitivo(t.lineno(1), t.lexpos(1), 0, tipo_primitivo.INTEGER, num_nodo)
            t[0] = agrupar(t[1], auxiliar, None, t.lineno(1), t.lexpos(1), num_nodo)
        else:
            t[0] = agrupar(t[1], t[3], None, t.lineno(1), t.lexpos(1), num_nodo)
        num_nodo += 3
    except:
        print('No funciona la parte de agrupar')