Example #1
0
def p_var4(p):
    '''var4 : exp
| LB AP exp C exp CP var41 RB
| AC exp var42 CC'''
    global vD, TipoV, DirQty
    if len(p) == 2:
        if (avail.OPila_peek() < 10000):
            dV = avail.OPila_pop() + (avail.getBloque() * 10000)
            avail.OPila_push(dV)
        avail.asign(vD)
    elif (len(p) == 5):
        if (avail.DPila_pop()):
            ID = avail.IDPila_pop()
            vDim = dimension(ID)
            while DirQty >= 0:
                avail.dmP(vD, DirQty, vDim)
                DirQty -= 1
            DirQty = 0
        else:
            print "error de tipos"
            sys.exit(0)
    else:
        if not avail.DPila_pop():
            print "error de tipos"
            sys.exit(0)
        else:
            ID = avail.IDPila_pop()
            vDim = dimension(ID)
            while DirQty >= 0:
                avail.dmTP(vD, DirQty, vDim)
                DirQty -= 1
            DirQty = 0
Example #2
0
def p_var4(p):
	'''var4 : exp
| LB AP exp C exp CP var41 RB
| AC exp var42 CC'''
	global vD, TipoV, DirQty
	if len(p) == 2: 
		if(avail.OPila_peek() < 10000):
			dV = avail.OPila_pop() + (avail.getBloque() * 10000)
			avail.OPila_push(dV)
		avail.asign(vD)
	elif(len(p) == 5):
		if(avail.DPila_pop()):
			ID = avail.IDPila_pop()
			vDim = dimension(ID)
			while DirQty >= 0 :
				avail.dmP(vD, DirQty, vDim)
				DirQty -= 1
			DirQty = 0
		else:
			print "error de tipos"
			sys.exit(0)
	else:
		if not avail.DPila_pop():
			print "error de tipos"
			sys.exit(0)
		else:
			ID = avail.IDPila_pop()
			vDim = dimension(ID)
			while DirQty >= 0:
				avail.dmTP(vD, DirQty, vDim)
				DirQty -= 1
			DirQty = 0
Example #3
0
def p_Asignacion(p):
    '''Asignacion : faID Factor5 Asignacion2'''
    ID = avail.IDPila_pop()
    if (idF == "asig"):
        TDim = avail.DPila_pop()
        variables_declaradas(ID)
        if (avail.DPila_pop()):
            if (TDim):
                par = avail.OPila_pop()
                par2 = avail.OPila_pop()
                avail.OPila_push(par)
                avail.TPila_push(tipo_variable(ID, "var"))
                avail.OPila_push(dir_var(ID))
                avail.OPila_push(par2)
                avail.dim(dimension(ID), avail.OPila_pop())
                avail.asign(avail.OPila_pop())
            else:
                par = avail.OPila_pop()
                par2 = avail.OPila_pop()
                par3 = avail.OPila_pop()
                avail.OPila_push(par)
                avail.OPila_push(par2)
                avail.TPila_push(tipo_variable(ID, "var"))
                avail.OPila_push(dir_var(ID))
                avail.OPila_push(par3)
                avail.dmT(dimension(ID), avail.OPila_pop())
                avail.asign(avail.OPila_pop())
                avail.asign(avail.OPila_pop())
        else:
            avail.asign(dir_var(ID))
    else:
        if (ID not in direc):
            print "Funcion no declarada", ID
            sys.exit(0)
        else:
            if ((len(direc[ID][0])) != len(CHF)):
                print "Error de llamada de funcion, ", ID
                sys.error(0)
            else:
                cont = 0
                for key in direc[ID][0]:
                    if (direc[ID][0][key][0] != CHF[cont]):

                        print "Error de tipo de llamada de funcion"
                        sys.error(0)
                    cont += 1
    CHF[:] = []
Example #4
0
def p_Asignacion(p):
	'''Asignacion : faID Factor5 Asignacion2'''
	ID = avail.IDPila_pop()
	if(idF == "asig"):
		TDim = avail.DPila_pop()		
		variables_declaradas(ID)
		if(avail.DPila_pop()):
			if(TDim):
				par = avail.OPila_pop()
				par2 = avail.OPila_pop()
				avail.OPila_push(par)
				avail.TPila_push(tipo_variable(ID, "var"))
				avail.OPila_push(dir_var(ID))
				avail.OPila_push(par2)
				avail.dim(dimension(ID), avail.OPila_pop())
				avail.asign(avail.OPila_pop())
			else:
				par = avail.OPila_pop()
				par2 = avail.OPila_pop()
				par3 = avail.OPila_pop()
				avail.OPila_push(par)
				avail.OPila_push(par2)
				avail.TPila_push(tipo_variable(ID, "var"))
				avail.OPila_push(dir_var(ID))
				avail.OPila_push(par3)
				avail.dmT(dimension(ID), avail.OPila_pop())
				avail.asign(avail.OPila_pop())
				avail.asign(avail.OPila_pop())
		else:
			avail.asign(dir_var(ID))
	else:
		if(ID not in direc):
			print "Funcion no declarada", ID
			sys.exit(0)	
		else:
			if((len(direc[ID][0])) != len(CHF)):
				print "Error de llamada de funcion, ", ID
				sys.error(0)
			else:
				cont = 0
				for key in direc[ID][0]:
					if(direc[ID][0][key][0] != CHF[cont]):
						
						print "Error de tipo de llamada de funcion"
						sys.error(0)
					cont += 1 
	CHF[:] = []