Exemplo n.º 1
0
def deter(cuad, i):
    dir1 = (cuad.dir1.split('['))
    result = apuntador(cuad.result)
    mat1 = createMat(dir1)
    res = np.linalg.det(mat1)
    memo.assign(glob, globTemp, local, localTemp, result, res)
    return i + 1
Exemplo n.º 2
0
def param(cuad, i):
    global numParams
    global intP
    global floatP
    global charP
    dir1 = apuntador(cuad.dir1)
    space = int(cuad.result) - 1
    memT = memo.indentifyType(dir1)
    if numParams > 0:
        if funcParams[space] == 'i' and memT == 1:
            dir = 13000 + intP
            intP += 1
        elif funcParams[space] == 'f' and memT == 2:
            dir = 14000 + floatP
            floatP += 1
        elif funcParams[space] == 'c' and memT == 3:
            dir = 15000 + charP
            charP += 1
        else:
            print('Error: Parametros no compatibles')
            sys.exit()
        if dir1 >= 8000 and dir1 < 13000:
            left_op = findCte(dir1)
        else:
            left_op = memo.get(glob, globTemp, local, localTemp, dir1)
        memo.assign(glob, globTemp, local2, localTemp2, dir, left_op)
        numParams -= 1
        if numParams == 0:
            intP = 0
            floatP = 0
            charP = 0
        return i + 1
    else:
        print('Error: Se esperaban menos parametros')
        sys.exit()
Exemplo n.º 3
0
def createMatRes(dir, res):
    dir1 = int(dir[0])
    lim1 = findCte(int(dir[1])) + 1
    if (len(dir) == 2):
        for c in range(lim1):
            space = dir1 + c
            memo.assign(glob, globTemp, local, localTemp, space, res[c])
    else:
        lim2 = findCte(int(dir[2])) + 1
        for r in range(lim1):
            for c in range(lim2):
                space = (r * lim1) + c + dir1
                memo.assign(glob, globTemp, local, localTemp, space, res[r][c])
Exemplo n.º 4
0
def mult(cuad, i):
    dir1 = (cuad.dir1.split('['))
    dir2 = (cuad.dir2.split('['))
    len1 = len(dir1)
    len2 = len(dir2)
    if (len1 < 2 and len2 < 2):
        dir1 = apuntador(cuad.dir1)
        dir2 = apuntador(cuad.dir2)
        result = apuntador(cuad.result)
        if dir1 >= 8000 and dir1 < 13000:
            left_op = findCte(dir1)
        else:
            left_op = memo.get(glob, globTemp, local, localTemp, dir1)
        if dir2 >= 8000 and dir2 < 13000:
            right_op = findCte(dir2)
        else:
            right_op = memo.get(glob, globTemp, local, localTemp, dir2)
        res = left_op * right_op
        memo.assign(glob, globTemp, local, localTemp, result, res)
        return i + 1
    else:
        result = (cuad.result.split('['))
        if (len1 < 2):
            dir1 = apuntador(cuad.dir1)
            if dir1 >= 8000 and dir1 < 13000:
                left_op = findCte(dir1)
            else:
                left_op = memo.get(glob, globTemp, local, localTemp, dir1)
            mat2 = createMat(dir2)
            res = np.multiply(left_op, mat2)
            createMatRes(result, res)
        elif (len2 < 2):
            mat1 = createMat(dir1)
            dir2 = apuntador(cuad.dir2)
            if dir2 >= 8000 and dir2 < 13000:
                right_op = findCte(dir2)
            else:
                right_op = memo.get(glob, globTemp, local, localTemp, dir2)
            res = np.multiply(mat1, right_op)
            createMatRes(result, res)
        else:
            mat1 = createMat(dir1)
            mat2 = createMat(dir2)
            res = np.dot(mat1, mat2)
            if (str(res)[0] != '['):
                result = apuntador(cuad.result)
                memo.assign(glob, globTemp, local, localTemp, result, res)
            else:
                createMatRes(result, res)
    return i + 1
Exemplo n.º 5
0
def div(cuad, i):
    dir1 = apuntador(cuad.dir1)
    dir2 = apuntador(cuad.dir2)
    result = apuntador(cuad.result)
    if dir1 >= 8000 and dir1 < 13000:
        left_op = findCte(dir1)
    else:
        left_op = memo.get(glob, globTemp, local, localTemp, dir1)
    if dir2 >= 8000 and dir2 < 13000:
        right_op = findCte(dir2)
    else:
        right_op = memo.get(glob, globTemp, local, localTemp, dir2)
    res = left_op / right_op
    memo.assign(glob, globTemp, local, localTemp, result, res)
    return i + 1
Exemplo n.º 6
0
def regresa(cuad, i):
    global local
    global localTemp
    dir1 = apuntador(cuad.result)
    reQuad = returnQuad.pop()
    dir = funcId.pop()
    if dir != None:
        dir = int(dir)
    if dir1 >= 8000 and dir1 < 13000:
        left_op = findCte(dir1)
    else:
        left_op = memo.get(glob, globTemp, local, localTemp, dir1)
    memo.assign(glob, globTemp, local, localTemp, dir, left_op)
    local = memo.memStack.pop()
    localTemp = memo.memTStack.pop()
    return reQuad + 1
Exemplo n.º 7
0
def lee(cuad, i):
    valor = input()
    try:
        valor = int(valor)
    except ValueError:
        try:
            valor = float(valor)
        except ValueError:
            pass
    tipo1 = gettipo(valor)
    result = apuntador(cuad.result)
    tipo2 = memo.indentifyType(result)
    if tipo1 != tipo2:
        print('Error: Valor ingresado no es valido')
        sys.exit()
    memo.assign(glob, globTemp, local, localTemp, result, valor)
    return i + 1
Exemplo n.º 8
0
def orOp(cuad, i):
    dir1 = int(cuad.dir1)
    dir2 = int(cuad.dir2)
    if dir1 >= 8000 and dir1 < 13000:
        left_op = findCte(dir1)
    else:
        left_op = memo.get(glob, globTemp, local, localTemp, dir1)
    if dir2 >= 8000 and dir2 < 13000:
        right_op = findCte(dir2)
    else:
        right_op = memo.get(glob, globTemp, local, localTemp, dir2)
    if (left_op or right_op):
        res = True
    else:
        res = False
    memo.assign(glob, globTemp, local, localTemp, int(cuad.result), res)
    return i + 1
Exemplo n.º 9
0
def asigna(cuad, i):
    dir1 = (cuad.dir1.split('['))
    result = (cuad.result.split('['))
    len1 = len(dir1)
    len2 = len(result)
    if (len1 < 2 and len2 < 2):
        dir1 = apuntador(cuad.dir1)
        result = apuntador(cuad.result)
        if dir1 >= 8000 and dir1 < 13000:
            right_op = findCte(dir1)
        else:
            right_op = memo.get(glob, globTemp, local, localTemp, dir1)
        memo.assign(glob, globTemp, local, localTemp, result, right_op)
        return i + 1
    else:
        mat1 = createMat(dir1)
        createMatRes(result, mat1)
        return i + 1