コード例 #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
コード例 #2
0
ファイル: maquina_virtual.py プロジェクト: edo0xff/PyCompiler
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
コード例 #3
0
ファイル: maquina_virtual.py プロジェクト: edo0xff/PyCompiler
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}
コード例 #4
0
ファイル: maquina_virtual.py プロジェクト: edo0xff/PyCompiler
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"])
コード例 #5
0
ファイル: maquina_virtual.py プロジェクト: edo0xff/PyCompiler
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}
コード例 #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}