Esempio n. 1
0
def f_variable(operandos):
    global variables

    semantica.verificar_numero_de_operandos(operandos, 1)
    semantica.verificar_tipo_de_operando(operandos[0], 'identificador')

    variables[operandos[0]["valor"]] = None
Esempio n. 2
0
def f_variable(operandos):
    global variables

    semantica.verificar_numero_de_operandos(operandos, 2)
    semantica.verificar_tipo_de_operando(operandos[0], 'identificador')

    a = semantica.valor_real_del_operando(variables, operandos[1])

    variables[operandos[0]["valor"]] = a
Esempio n. 3
0
def f_entrada_numero(operandos):
    global variables

    semantica.verificar_numero_de_operandos(operandos, 2)

    semantica.verificar_tipo_de_operando(operandos[0], "cadena")
    semantica.verificar_tipo_de_operando(operandos[1], "identificador")

    a = int(raw_input(operandos[0]["valor"]))

    variables[operandos[1]["valor"]] = {"tipo": "numero", "valor": a}
Esempio n. 4
0
def f_comparar_diferencia(operandos):
    global variables

    semantica.verificar_numero_de_operandos(operandos, 3)

    a = semantica.valor_real_del_operando(variables, operandos[0])
    b = semantica.valor_real_del_operando(variables, operandos[1])

    semantica.verificar_tipo_de_operando(operandos[2], 'identificador')

    if not a["valor"] == b["valor"]:
        ejecutar_funcion(operandos[2]["valor"])
Esempio n. 5
0
def f_sumar(operandos):
    global variables

    semantica.verificar_numero_de_operandos(operandos, 3)

    a = semantica.valor_real_del_operando(variables, operandos[0])
    b = semantica.valor_real_del_operando(variables, operandos[1])

    semantica.verificar_tipo_de_operando(a, 'numero')
    semantica.verificar_tipo_de_operando(b, 'numero')
    semantica.verificar_tipo_de_operando(operandos[2], 'identificador')

    r = a["valor"] + b["valor"]

    variables[operandos[2]["valor"]] = {"tipo": "numero", "valor": r}
Esempio n. 6
0
def f_sumar(operandos):
    global variables

    semantica.verificar_numero_de_operandos(operandos, 3)

    # Si las operandos son variables hay que obtener su valor real
    a = semantica.valor_real_del_operando(variables, operandos[0])
    b = semantica.valor_real_del_operando(variables, operandos[1])

    # Se verifica que el tipo de operandos sea al correcto
    semantica.verificar_tipo_de_operando(a, 'numero')
    semantica.verificar_tipo_de_operando(b, 'numero')
    semantica.verificar_tipo_de_operando(operandos[2], 'identificador')

    r = a["valor"] + b["valor"]

    variables[operandos[2]["valor"]] = {"tipo": "numero", "valor": r}