예제 #1
0
def p_asignacion(p):
    '''asignacion : pN12 pN16 obtieneMemoriaVARS logical_expresion PUNTOYCOMA
        | pN12 obtieneMemoriaVARS array pN16 logical_expresion PUNTOYCOMA '''
    global nombreFunc

    #print('p_asignacion')
    #print(cuad.PTypes)
    #print(cuad.PilaO)

    if cuad.POper[len(cuad.POper) - 1] == '=':
        #print(cuad.PTypes)
        #print(cuad.PilaO)
        cuad.right_operand = cuad.PilaO.pop()
        cuad.right_type = cuad.PTypes.pop()
        cuad.left_operand = cuad.PilaO.pop()
        cuad.left_type = cuad.PTypes.pop()
        operator = cuad.POper.pop()
        result_type = cubo.sem_cubo[cuad.left_type][cuad.right_type][operator]
        if result_type != 'error':
            cuad.agregarCuad(operator, cuad.right_operand, '',
                             cuad.left_operand)
            cuad.PilaO.append(cuad.left_operand)
            cuad.PTypes.append(result_type)
            #print('asignacion',cuad.PTypes)
            #print('asignacion',cuad.PilaO)
            #print('asignacion',cuad.POper)
            #cuad.PilaO.clear()
            #cuad.PTypes.clear()
        else:
            print("HORROR DE TIPOS")
            sys.exit()
예제 #2
0
def p_pN23_LUCIA(p):
    ''' pN23_LUCIA : '''
    try:
        cuad.POper[len(cuad.POper) - 1]
    except IndexError:
        print("pila vacia")
    else:
        if cuad.POper[len(cuad.POper) - 1] == '>' or cuad.POper[
                len(cuad.POper) - 1] == '<' or cuad.POper[
                    len(cuad.POper) - 1] == '>=' or cuad.POper[
                        len(cuad.POper) - 1] == '<=' or cuad.POper[
                            len(cuad.POper) -
                            1] == '==' or cuad.POper[len(cuad.POper) -
                                                     1] == '!=':
            cuad.right_operand = cuad.PilaO.pop()
            cuad.right_type = cuad.PTypes.pop()
            cuad.left_operand = cuad.PilaO.pop()
            cuad.left_type = cuad.PTypes.pop()
            operator = cuad.POper.pop()
            result_type = cubo.sem_cubo[cuad.left_type][
                cuad.right_type][operator]
            if result_type != 'error':
                result = mem.generaDirTemporal(result_type)
                cuad.contCuad = cuad.contCuad + 1
                cuad.agregarCuad(operator, cuad.left_operand,
                                 cuad.right_operand, result)
                cuad.PilaO.append(result)
                cuad.PTypes.append(result_type)
            else:
                print("HORROR DE TIPOS")
                sys.exit()
예제 #3
0
def p_pN28_LUCIA(p):
    ''' pN28_LUCIA : '''
    falso = cuad.PJumps.pop()
    cuad.agregarCuad('GOTO', '', '', falso)
    cuad.PJumps.append(cuad.contQuadAux - 1)
    #fill
    cuad.PQuad[falso]['result'] = cuad.contQuadAux
예제 #4
0
def p_pN30(p):
    ''' pN30 : '''
    end = cuad.PJumps.pop()
    #print('end',end)
    retorna = cuad.PJumps.pop()
    cuad.agregarCuad('GOTO', '', '', retorna)
    #fill
    cuad.PQuad[end]['result'] = cuad.contQuadAux
예제 #5
0
def p_pN40(p):
    ''' pN40 : '''
    global nombre, contadorParametros
    #print(nombre)
    cuad.agregarCuad('ERA', nombre, '', '')
    contadorParametros = 1
    directorio.funcionLista[nombre]['paramDefinidos'][contadorParametros][
        'tipo']
예제 #6
0
def p_pN29(p):
    ''' pN29 : '''
    exp_type = cuad.PTypes.pop()
    if exp_type != 'BOOL':
        print("HORROR DE TIPOS EN EL WHILE")
    else:
        result = cuad.PilaO.pop()
        cuad.agregarCuad('GOTOF', result, '', '')
        cuad.PJumps.append(cuad.contQuadAux - 1)
예제 #7
0
def p_pN26_LUCIA(p):
    ''' pN26_LUCIA : '''
    exp_type = cuad.PTypes.pop()
    if exp_type != 'BOOL':
        print("Error if invalido")
        sys.exit()
    else:
        result = cuad.PilaO.pop()
        cuad.agregarCuad('GOTOF', result, '', '')
        cuad.PJumps.append(cuad.contQuadAux - 1)
예제 #8
0
def p_pN21(p):
    ''' pN21 : '''
    cuad.agregarCuad('ENDPROC', '', '', '')
    cuad.contCuad = 0
    directorio.contParams = 1
    mem.contadorTemporalINT = mem.Tgi
    mem.contadorTemporalFLOAT = mem.Tgf
    mem.contadorTemporalCHAR = mem.Tgc
    mem.contadorTemporalBOOL = mem.Tgb
    mem.contadorTemporalDATASET = mem.Tgd
예제 #9
0
def p_pN36_LUCIA(p):
    ''' pN36_LUCIA : '''
    global pointerParamModuleCall, contadorParametros, nombre
    Argument = cuad.PilaO.pop()
    ArgumentType = cuad.PTypes.pop()

    if ArgumentType == directorio.funcionLista[nombre]['paramDefinidos'][
            contadorParametros]['tipo']:
        cuad.agregarCuad('PARAM', Argument, '',
                         'PARAM' + str(contadorParametros))
    else:
        print("Error de tipo en el", contadorParametros,
              "parametro en la llamade de", nombre)
        sys.exit()
예제 #10
0
def p_lectura(p):
    ''' lectura : REGLA_READ ABREPAR ID CIERRAPAR PUNTOYCOMA
        | REGLA_READ ABREPAR ID array CIERRAPAR PUNTOYCOMA
        '''
    global nombreFunc
    try:
        directorio.funcionLista[nombreFunc]['variables'][p[3]]
    except KeyError:
        print('La variable', p[3], 'no esta declarada')
        sys.exit()
    else:
        cuad.agregarCuad(
            'READ', '', '', directorio.funcionLista[nombreFunc]['variables'][
                p[3]]['dirMemoria'])
예제 #11
0
def p_pN44(p):
    ''' pN44 : '''
    global nombre, temTipoCTE
    #print('pN44')
    #print(nombre,directorio.funcionLista[nombre]['tipo'])
    #cuad.PilaO.append(nombre)
    result_type = directorio.funcionLista['MAIN']['variables'][nombre]['tipo']
    result = mem.generaDirTemporal(result_type)
    cuad.agregarCuad(
        '=',
        directorio.funcionLista['MAIN']['variables'][nombre]['dirMemoria'], '',
        result)
    cuad.contCuad += 1
    cuad.PilaO.append(result)
    temTipoCTE = directorio.funcionLista[nombre]['tipo']
예제 #12
0
def p_pN42(p):
    ''' pN42 : '''
    if cuad.POper[len(cuad.POper) - 1] == 'AND' or cuad.POper[len(cuad.POper) -
                                                              1] == 'OR':
        cuad.right_operand = cuad.PilaO.pop()
        cuad.right_type = cuad.PTypes.pop()
        cuad.left_operand = cuad.PilaO.pop()
        cuad.left_type = cuad.PTypes.pop()
        operator = cuad.POper.pop()
        result_type = cubo.sem_cubo[cuad.left_type][cuad.right_type][operator]
        if result_type != 'error':
            result = mem.generaDirTemporal(result_type)
            cuad.contCuad = cuad.contCuad + 1
            cuad.agregarCuad(operator, cuad.left_operand, cuad.right_operand,
                             result)
            cuad.PilaO.append(result)
            cuad.PTypes.append(result_type)
        else:
            print("HORROR DE TIPOS")
            sys.exit()
예제 #13
0
def p_pN56(p):
    ''' pN56 : '''
    global nombreFunc, idArray, temTipoCTE
    for x in directorio.funcionLista[nombreFunc]['variables']:
        if directorio.funcionLista[nombreFunc]['variables'][x][
                'dirMemoria'] == idArray:
            Li = directorio.funcionLista[nombreFunc]['variables'][x][
                'varsDim']['Li']
            Ls = directorio.funcionLista[nombreFunc]['variables'][x][
                'varsDim']['Ls']
            k = directorio.funcionLista[nombreFunc]['variables'][x]['varsDim'][
                '-k']
            BASE = directorio.funcionLista[nombreFunc]['variables'][x][
                'dirMemoria']
    cuad.agregarCuad('VER', cuad.PilaO[len(cuad.PilaO) - 1], Li, Ls)
    aux1 = cuad.PilaO.pop()
    #sacar el tipo que viene de exp
    cuad.PTypes.pop()

    temTipoCTE = tipo = cuad.PTypes.pop()
    T = mem.generaDirTemporal(tipo)
    cuad.agregarCuad('+k', aux1, k, T)
    T2 = mem.generaDirTemporal(tipo)
    cuad.agregarCuad('+DirBASE', T, BASE, T2)
    cuad.PilaO.append('(' + str(T2) + ')')
    cuad.PTypes.append(tipo)
    #print('56',cuad.PTypes)
    cuad.POper.pop()
예제 #14
0
def p_distN_agregarCuadCHAR(p):
    ''' distN_agregarCuadCHAR : pN51 obtieneMemoriaCTE_CHAR'''
    cuad.agregarCuad('DISTN', '', '', cuad.PilaO.pop())
예제 #15
0
def p_basicViolin_agregarCuadID(p):
    ''' basicViolin_agregarCuadID : pN20 obtieneMemoriaVARS '''
    cuad.agregarCuad('BASICV', '', '', cuad.PilaO.pop())
예제 #16
0
def p_desvEstandar_agregarCuadCHAR(p):
    ''' desvEstandar_agregarCuadCHAR : pN51 obtieneMemoriaCTE_CHAR'''
    cuad.agregarCuad('DESVT', '', '', cuad.PilaO.pop())
예제 #17
0
def p_distN_agregarCuadID(p):
    ''' distN_agregarCuadID : pN20 obtieneMemoriaVARS'''
    cuad.agregarCuad('DISTN', '', '', cuad.PilaO.pop())
예제 #18
0
def p_varianza_agregarCuadCHAR(p):
    ''' varianza_agregarCuadCHAR : pN51 obtieneMemoriaCTE_CHAR'''
    cuad.agregarCuad('VARIANZA', '', '', cuad.PilaO.pop())
예제 #19
0
def p_desvEstandar_agregarCuadID(p):
    ''' desvEstandar_agregarCuadID : pN20 obtieneMemoriaVARS'''
    cuad.agregarCuad('DESVT', '', '', cuad.PilaO.pop())
예제 #20
0
def p_piechart_agregarCuadCHAR(p):
    ''' piechart_agregarCuadCHAR : pN51 obtieneMemoriaCTE_CHAR'''
    cuad.agregarCuad('PIECHART', '', '', cuad.PilaO.pop())
예제 #21
0
def p_median_agregarCuadCHAR(p):
    ''' median_agregarCuadCHAR : pN51 obtieneMemoriaCTE_CHAR'''
    cuad.agregarCuad('MEDIAN', '', '', cuad.PilaO.pop())
예제 #22
0
def p_plot_agregarCuadCHAR(p):
    ''' plot_agregarCuadCHAR : pN51 obtieneMemoriaCTE_CHAR'''
    cuad.agregarCuad('PLOT', '', '', cuad.PilaO.pop())
예제 #23
0
def p_piechart_agregarCuadID(p):
    ''' piechart_agregarCuadID : pN20 obtieneMemoriaVARS'''
    cuad.agregarCuad('PIECHART', '', '', cuad.PilaO.pop())
예제 #24
0
def p_plot_agregarCuadID(p):
    ''' plot_agregarCuadID : pN20 obtieneMemoriaVARS'''
    cuad.agregarCuad('PLOT', '', '', cuad.PilaO.pop())
예제 #25
0
def p_moda_agregarCuadCHAR(p):
    ''' moda_agregarCuadCHAR : pN51 obtieneMemoriaCTE_CHAR'''
    cuad.agregarCuad('MODE', '', '', cuad.PilaO.pop())
예제 #26
0
def p_promedio_agregarCuadCHAR(p):
    ''' promedio_agregarCuadCHAR : pN51 obtieneMemoriaCTE_CHAR'''
    cuad.agregarCuad('AVERAGE', '', '', cuad.PilaO.pop())
예제 #27
0
def p_basicViolin_agregarCuadCHAR(p):
    ''' basicViolin_agregarCuadCHAR : pN51 obtieneMemoriaCTE_CHAR '''
    cuad.agregarCuad('BASICV', '', '', cuad.PilaO.pop())
예제 #28
0
def p_varianza_agregarCuadID(p):
    ''' varianza_agregarCuadID : pN20 obtieneMemoriaVARS'''
    cuad.agregarCuad('VARIANZA', '', '', cuad.PilaO.pop())
예제 #29
0
def p_moda_agregarCuadID(p):
    ''' moda_agregarCuadID : pN20 obtieneMemoriaVARS'''
    cuad.agregarCuad('MODE', '', '', cuad.PilaO.pop())
예제 #30
0
def p_median_agregarCuadID(p):
    ''' median_agregarCuadID : pN20 obtieneMemoriaVARS'''
    cuad.agregarCuad('MEDIAN', '', '', cuad.PilaO.pop())