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
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
def p_Texto(p): '''Texto : LA AP STR CP PC''' global void_val, cnst_void_val sub = 1 start = void_val - 1000 strDir = void_val + (avail.getBloque() * 10000) word = p[3] while sub < len(word)-1: if word[sub] not in cnst: cnst[word[sub]] = cnst_void_val cnst_void_val += 1 sC = ['101', cnst[word[sub]], -1, (void_val + (avail.getBloque() * 10000))] void_val += 1 avail.append_quad(sC) sub += 1 finish = void_val - 1000 -1 sC = ['208', strDir , start, finish] avail.append_quad(sC)
def p_Texto(p): '''Texto : LA AP STR CP PC''' global void_val, cnst_void_val sub = 1 start = void_val - 1000 strDir = void_val + (avail.getBloque() * 10000) word = p[3] while sub < len(word) - 1: if word[sub] not in cnst: cnst[word[sub]] = cnst_void_val cnst_void_val += 1 sC = [ '101', cnst[word[sub]], -1, (void_val + (avail.getBloque() * 10000)) ] void_val += 1 avail.append_quad(sC) sub += 1 finish = void_val - 1000 - 1 sC = ['208', strDir, start, finish] avail.append_quad(sC)
def p_varSalvar(p): '''varSalvar : ID ''' guardar_var(p[1]) global vD vD = dir_var(p[1]) + (avail.getBloque() * 10000) avail.IDPila_push(p[1])