示例#1
0
def bool_opr(lval, rval, op):
    if isAthValue(lval):
        lval = AthSymbol(bool(lval), left=lval)
    if isAthValue(rval):
        rval = AthSymbol(bool(rval), left=rval)
    if op == 'l&':
        return lval and rval
    elif op == 'l|':
        return lval or rval
    elif op == 'l^':
        return (lval if lval and not rval else
                rval if rval and not lval else AthSymbol(False))
    raise SyntaxError(f'Invalid comparison operator: {op}')
示例#2
0
def unopr_expression(env, opr, val):
    ans = unops[opr](val)
    if isAthValue(ans):
        return AthSymbol(left=ans)
    return ans
示例#3
0
def biopr_expression(env, opr, lft, rht):
    ans = biops[opr](lft, rht)
    if isAthValue(ans):
        return AthSymbol(left=ans)
    return ans
示例#4
0
def bool_not(val):
    if isAthValue(val):
        val = AthSymbol(bool(val), left=val)
    return AthSymbol(not val, val.left, val.right)
示例#5
0
def cmp_opr(lval, rval, op):
    if isAthValue(lval):
        lval = AthSymbol(bool(lval), left=lval)
    return op(lval, rval)