Esempio n. 1
0
def getLimit(t):
    if t[3] != None:
        gramatica = '<instrlimit> ::= \"LIMIT\" \"'+str(t[2])+'\" <instroffset>'
        return Nodo(t[1], str(t[2]), [t[3]], t.lexer.lineno, 0, gramatica)
    else:
        gramatica = '<instrlimit> ::= \"LIMIT\" \"'+t[2]+'\"'
        return Nodo(t[1], str(t[2]), [], t.lexer.lineno, 0, gramatica)
Esempio n. 2
0
def getValorNumerico(t):
    if isinstance(t[1], float):
        gramatica = '<cualquiernumero> ::= \"' + str(t[1]) + '\"'
        return Nodo('DECIMAL', str(t[1]), [], t.lexer.lineno, 0, gramatica)
    else:
        gramatica = '<cualquiernumero> ::= \"' + str(t[1]) + '\"'
        return Nodo('ENTERO', str(t[1]), [], t.lexer.lineno, 0, gramatica)
Esempio n. 3
0
def getinstrcase2(t):
    childs = [Nodo('LISTA WHEN', '', t[2], t.lexer.lineno)]
    if t[3] != None:
        childs.append(t[3])
    n2 = Nodo('END CASE', '', [], t.lexer.lineno)
    childs.append(n2)
    return Nodo('CASE', '', childs, t.lexer.lineno)
Esempio n. 4
0
def getStringFunctionNode2(t):
    if len(t) == 9:
        g = '<func_bin_strings_2> ::= \"'+t[1]+'\" \"PARIZQ\" <cadena> \"COMA\" <cualquiernumero> \"COMA\" <cualquiernumero> \"PARDER\"\n'
        return Nodo('FUNCION STR',t[1],[t[3], t[5], t[7]],t.lexer.lineno,0,g)
    else:
        g = '<func_bin_strings_2> ::= \"TRIM\" \"PARIZQ\" <cadena> \"PARDER\"\n'
        return Nodo('FUNCION STR','TRIM',[t[3]],t.lexer.lineno,0,g)
Esempio n. 5
0
def getinstrif(t):
    g = '<instrif>   : IF <condiciones> THEN <instrlistabloque> END IF PTCOMA'
    childs = [Nodo('CONDICIONES', '', [t[2]], t.lexer.lineno)]
    if t[4] != None:
        childs.append(Nodo('THEN', '', t[4], t.lexer.lineno))
    childs.append(Nodo('END IF', '', []))
    return Nodo('IF', '', childs, t.lexer.lineno, 0, g)
Esempio n. 6
0
def getValOrder(t):
    if t[3] != None:
        gramatica = '<valororderby> ::= <cualquieridentificador> <ascdesc> <anular>'
        return Nodo('COLUMN', '', [t[1], t[2], t[3]], t.lexer.lineno, 0, gramatica)
    else : 
        gramatica = '<valororderby> ::= <cualquieridentificador> <ascdesc>'
        return Nodo('COLUMN', '', [t[1], t[2]], t.lexer.lineno, 0, gramatica)
Esempio n. 7
0
def getParamNode(t):
    g = '<parametroinsert> ::= '
    if str(t[1]).upper() == 'DEFAULT':
        g += '\"DEFAULT\"\n'
        return Nodo('Parametro','DEFAULT',[],t.lexer.lineno,0,g)
    else:
        g += '<expresion>\n'
        return Nodo('Parametro','',[t[1]],t.lexer.lineno,0,g) 
Esempio n. 8
0
def getDistinctFrom(t) :
    gramatica = '<condicionwhere> ::= <is_distinct_state>\n' 
    if len(t) == 6: 
        gramatica += '<is_distinct_state> ::= <valores> \"IS\" \"DISTINCT\" \"FROM\" <valores>'
        return Nodo('IS DISTINCT', '', [t[1], t[5]], t.lexer.lineno, 0, gramatica)
    else :
        gramatica += '<is_distinct_state> ::= <valores> \"IS\" \"NOT\" \"DISTINCT\" \"FROM\" <valores>'
        return Nodo('IS NOT DISTINCT', '', [t[1], t[6]], t.lexer.lineno, 0, gramatica)
Esempio n. 9
0
def getCuerpoFuncion(t):
    childs = []
    childs.append(Nodo('$$', '', []))
    if t[2] != None:
        childs.append(t[2])
    childs.append(t[3])
    childs.append(Nodo('$$', '', []))
    return Nodo('CUERPO', '', childs, t.lexer.lineno)
Esempio n. 10
0
def getIdentificador(t):
    if len(t) == 2:
        gramatica = '<cualquieridentificador> ::= \"'+str(t[1])+'\"'
        return Nodo('ID', t[1], [], t.lexer.lineno,0, gramatica)
    else :
        gramatica = '<cualquieridentificador> ::= \"'+str(t[1])+'\" \"PUNTO\" \"'+str(t[3])+'\"'
        childs = [Nodo('ID', t[3], [], t.lexer.lineno)]
        return Nodo('AliasTabla', t[1], childs, t.lexer.lineno, 0, gramatica)
Esempio n. 11
0
def getOpRelacional(t):
    if t[2] == '<>':
        gramatica = '<condicion> ::= <expresion> \"DIFERENTE\" <expresion>'
        return Nodo('OPREL', '\\<\\>', [t[1], t[3]], t.lexer.lineno, 0,
                    gramatica)
    gramatica = '<condicion> ::= <expresion> \"' + t[2] + '\" <expresion>'
    return Nodo('OPREL', '\\' + str(t[2]), [t[1], t[3]], t.lexer.lineno, 0,
                gramatica)
Esempio n. 12
0
def getdeclaraciones1(t):
    childs = [Nodo('ID', t[1], [], t.lexer.lineno)]
    childs.append(Nodo('ALIAS FOR', '', [], t.lexer.lineno))
    if len(t) == 7:
        childs.append(Nodo('$', str(t[5]), [], t.lexer.lineno))
    else:
        childs.append(Nodo('ID', str(t[4]), [], t.lexer.lineno))
    return Nodo('Declaracion', '', childs, t.lexer.lineno)
Esempio n. 13
0
def getAlias(t):
    if t[1] == None:
        return t[1]
    elif t[1].lower() == 'as':
        gramatica = '<alias> ::= \"AS\" \"' + str(t[2]) + '\"'
        return Nodo('Alias', t[2], [], t.lexer.lineno, 0, gramatica)
    else:
        gramatica = '<alias> ::= \"' + str(t[1]) + '\"'
        return Nodo('Alias', t[1], [], t.lexer.lineno, 0, gramatica)
Esempio n. 14
0
def getBetween(t):
    if len(t) == 6:
        gramatica = '<condicionwhere> ::= <between_state>\n'
        gramatica += '<between_state> ::= <cualquiernumero> \"BETWEEN\" <valores> \"AND\" <valores>'
        return Nodo('BETWEEN', '', [t[1], t[3], t[5]], t.lexer.lineno, 0, gramatica)
    else: 
        gramatica = '<condicionwhere> ::= <not_between_state>\n'
        gramatica += '<between_state> ::= <cualquiernumero> \"NOT\" \"BETWEEN\" <valores> \"AND\" <valores>'
        return Nodo('NOT BETWEEN', '', [t[1], t[4], t[6]], t.lexer.lineno, 0, gramatica)
Esempio n. 15
0
def getparfunc(t):
    if len(t) == 4:
        g = '<parfunc> ::= OUT ID <type_column1>'
        return Nodo(t[1], t[2], [t[3]], t.lexer.lineno, g)
    elif len(t) == 3:
        g = '<parfunc> ::= ID <type_column1>'
        return Nodo('ID', t[1], [t[2]], t.lexer.lineno, g)
    else:
        return t[1]
Esempio n. 16
0
def getNullFieldNode(t):
    g = ''
    if len(t) == 3:
        g = '<null_field> ::= \"NOT\" \"NULL\"\n'
        return Nodo('NOT NULL', '', [], t.lexer.lineno, 0, g)
    elif t[1] != None:
        g = '<null_field> ::= \"NULL\"\n'
        return Nodo('NULL', '', [], t.lexer.lineno, 0, g)
    return None
Esempio n. 17
0
def getSubstring(t):
    childs = [t[3]]
    gramatica = '<condicionwhere> ::= <wheresubstring>\n'
    gramatica += '<wheresubstring> ::= \"SUBSTRING\" \"PARIZQ\" <cadenastodas> \"COMA\" \"ENTERO\" \"COMA\" \"ENTERO\" \"PARDER\" \"IGUAL\" \"CADENASIMPLE\"'
    childs.append(Nodo('DE', str(t[5]), [], t.lexer.lineno))
    childs.append(Nodo('HASTA', str(t[7]), [], t.lexer.lineno))
    childs.append(Nodo('IGUAL', t[9], [], t.lexer.lineno))
    childs.append(Nodo('CADENA', t[10], [], t.lexer.lineno))
    return Nodo("SUBSTRING", '', childs, t.lexer.lineno, 0, gramatica)
Esempio n. 18
0
def getSelectList(t):
    if t[1] == '*':
        gramatica = '<selectlist> ::= \"ASTERISCO\"'
        return Nodo('ASTERISCO', '*', [], t.lexer.lineno, 0, gramatica)
    else:
        gramatica = '<selectlist> ::= <listaselect> \n'
        gramatica += '<listaselect> ::= <listaselect> \"COMA\" <valselect> \n'
        gramatica += '<listaselect> ::= <valselect>'
        return Nodo('ROWS', '', t[1], t.lexer.lineno, 0, gramatica)
Esempio n. 19
0
def getCheckUnique(t):
    g = '<check_unique> ::= \"UNIQUE\"\n'
    g += '<check_unique> ::= \"CHECK\" \"PARIZQ\" <condiciones> \"PARDER\"\n'
    g += '<check_unique> ::= <empty>\n'
    if len(t) == 5:
        return Nodo('CHECK', '', [t[3]], t.lexer.lineno, 0, g)
    elif t[1] != None:
        return Nodo('UNIQUE', '', [], t.lexer.lineno, 0, g)
    return None
Esempio n. 20
0
def getfuncion_procedimiento(t):
    g = '<plsql_instr> : CREATE <procedfunct> ID PARIZQ <parametrosfunc> PARDER <tiporetorno> <cuerpofuncion>'
    childs = []
    if t[5] != None:
        childs.append(Nodo('PARAMETROS', '', t[5], t.lexer.lineno))
    if t[7] != None:
        childs.append(t[7])
    if t[8] != None:
        childs.append(t[8])
    return Nodo(t[2], t[3], childs, t.lexer.lineno, 0, g)
Esempio n. 21
0
def getFuncionMatematica(t):
    if len(t) == 4:
        gramatica = '<funcion_matematica_s> ::= \"'+str(t[1])+'\" \"PARIZQ\" \"PARDER\"'
        return Nodo('PI', '', [], t.lexer.lineno, 0, gramatica)
    elif len(t) == 5:
        gramatica = '<funcion_matematica_s> ::= \"'+str(t[1])+'\" \"PARIZQ\" <expresionaritmetica> \"PARDER\"'
        return Nodo('Matematica', t[1], [t[3]], t.lexer.lineno, 0, gramatica)
    else :
        gramatica = '<funcion_matematica_s> ::= \"'+str(t[1])+'\" \"PARIZQ\" <expresionaritmetica> \"COMA\" <expresionaritmetica>\"PARDER\"'
        return Nodo('Matematica', t[1], [t[3], t[5]], t.lexer.lineno, 0, gramatica)
Esempio n. 22
0
def getdeclaraciones(t):
    childs = [Nodo('ID', t[1], [], t.lexer.lineno)]
    if t[2] != None:
        childs.append(t[2])
    childs.append(t[3])
    if t[4] != None:
        childs.append(t[4])
    if t[5] != None:
        childs.append(t[5])
    return Nodo('Declaracion', '', childs, t.lexer.lineno)
Esempio n. 23
0
def getPredicates(t):
    gramatica = '<condicionwhere> ::= <predicates_state>\n'
    if len(t) == 3:
        gramatica += '<predicates_state> ::= <valores> \"' + t[2] + '\"'
        return Nodo(t[2], '', [t[1]], t.lexer.lineno, 0, gramatica)
    elif len(t) == 4:
        gramatica += '<predicates_state> ::= <valores> \"IS\" \"NULL\"'
        return Nodo('IS NULL', '', [t[1]], t.lexer.lineno, 0, gramatica)
    else:
        gramatica += '<predicates_state> ::= <valores> \"IS\" \"NOT\" \"NULL\"'
        return Nodo('IS NOT NULL', '', [t[1]], t.lexer.lineno, 0, gramatica)
Esempio n. 24
0
def getraisenoticesubbloque(t):
    if len(t) == 5:
        g = '<raisenotice1> ::= RAISE NOTICE CADENASIMPLE PTCOMA'
        return Nodo('RAISE NOTICE', t[3], [], t.lexer.lineno, g)
    elif len(t) == 7:
        g = '<raisenotice1> ::= RAISE NOTICE CADENASIMPLE COMA ID PTCOMA'
        n1 = Nodo('ID', t[5], [], t.lexer.lineno)
        return Nodo('RAISE NOTICE', t[3], [n1], t.lexer.lineno, g)
    else:
        g = '<raisenotice1> ::= RAISE NOTICE CADENASIMPLE COMA OUTERBLOCK PUNTO ID PTCOMA'
        n1 = Nodo('OUTERBLOCK', t[7], [], t.lexer.lineno)
        return Nodo('RAISE NOTICE', t[3], [n1], t.lexer.lineno, g)
Esempio n. 25
0
def getasignavalor(t):
    if t[1] == None:
        return None
    elif t[1] == '=':
        g = '<asignavalor> ::= IGUAL <expresion>'
        return Nodo('IGUAL', '=', [t[2]], t.lexer.lineno, g)
    elif t[1] == ':=':
        g = '<asignavalor> ::= PTIGUAL <expresion>'
        return Nodo('PTIGUAL', ':=', [t[2]], t.lexer.lineno, g)
    else:
        g = '<asignavalor> ::= DEFAULT <expresion>'
        return Nodo('DEFAULT', '', [t[2]], t.lexer.lineno, g)
Esempio n. 26
0
def getTablaSelect(t) :
    if len(t) == 3:
        if t[2] != None:
            return Nodo('Tabla', t[1], [t[2]], t.lexer.lineno, 0, '<tablaselect> ::= \"'+str(t[1])+'\" <alias>')
        else :
            return Nodo('Tabla', t[1], [], t.lexer.lineno, 0, '<tablaselect> ::= \"'+str(t[1])+'\"')
    else:
        if t[4] != None :
            gramatica = '<tablaselect> ::= \"PARIZQ\" <select_instr1> \"PARDER\" <alias>'
            return Nodo('Subquery', '', [t[2], t[4]], t.lexer.lineno, 0, gramatica)
        else :
            gramatica = '<tablaselect> ::= \"PARIZQ\" <select_instr1> \"PARDER\"'
            return Nodo('Subquery', '', [t[2]], t.lexer.lineno, 0, gramatica)  
Esempio n. 27
0
def getretornofuncion(t):
    if t[1] == None:
        return None
    elif t[1].lower() == 'returns':
        g = '<tiporetorno> ::= RETURNS <type_columnn1> AS'
        return Nodo(t[1], '', [t[2]], t.lexer.lineno, g)
    elif t[1].lower() == 'language':
        g = '<tiporetorno> ::= LANGUAGE PLPGSQL AS'
        return Nodo(t[1], t[2], [], t.lexer.lineno, g)
    elif t[1].lower() == 'as':
        g = '<tiporetorno> ::= AS'
        return Nodo('AS', '', [], t.lexer.lineno)
    return None
Esempio n. 28
0
def gettypecolumn(t):
    if len(t) == 2:
        return Nodo('TYPE COLUMN', t[1], [], t.lexer.lineno)
    elif len(t) == 5:
        if t[1].lower() == 'table':
            n1 = Nodo('PARAMETROS', '', t[3])
            return Nodo('TYPE COLUMN', t[1], [n1], t.lexer.lineno)
        a = Nodo('ENTERO', str(t[3]), [], t.lexer.lineno)
        return Nodo('TYPE COLUMN', t[1], [a], t.lexer.lineno)
    elif len(t) == 6:
        a = Nodo('ENTERO', t[4], [], t.lexer.lineno)
        return Nodo('TYPE COLUMN', t[1], [a], t.lexer.lineno)
    else:
        a = Nodo('ENTERO', str(t[3]), [], t.lexer.lineno)
        b = Nodo('ENTERO', str(t[5]), [], t.lexer.lineno)
        return Nodo('TYPE COLUMN', t[1], [a, b], t.lexer.lineno)
Esempio n. 29
0
def getinstrexecute1(t):
    childs = [t[5]]
    if t[8] != None:
        childs.append(t[8])
    if t[9] != None:
        childs.append(t[9])
    return Nodo('EXECUTE FORMAT', '', childs, t.lexer.lineno)
Esempio n. 30
0
def getinstrexecute(t):
    childs = [t[3]]
    if t[5] != None:
        childs.append(t[5])
    if t[6] != None:
        childs.append(t[6])
    return Nodo('EXECUTE', '', childs, t.lexer.lineno)