예제 #1
0
def interpretVarType(_value):
    from run import howManyComparison
    from run import howManyOperator
    from run import Interpreter

    #if this is a comparison
    if howManyComparison(_value) == 1:
        return "BOOLEAN", comparison(_value)

    #if this is operation
    if howManyOperator(_value) == 1:
        _interpreter = Interpreter(_value)
        return "INTEGER", _interpreter.expr()

    #if this is plain integer
    if _value.isdigit():
        return "INTEGER", int(_value)

    #if this is plain boolean
    if _value == "true" or _value == "false":
        return "BOOLEAN", _value

    #if this is plain string
    if _value[0] == '"' and _value[len(_value)-1] == '"':
        return "STRING", _value

    #Only remaining possibility is that it is a variable
    #Go through list of variables
    var = getVariable(_value)
    if var is not None:
        return var['type'], var['value']

    printError("ERROR: Failed to set variable")
    return None
예제 #2
0
def calculateTwoExpressions(_expressions):
    from run import Interpreter
    interpreter1 = Interpreter(_expressions[0])
    result1 = interpreter1.expr()
    interpreter2 = Interpreter(_expressions[1])
    result2 = interpreter2.expr()

    return result1, result2