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}')
def unopr_expression(env, opr, val): ans = unops[opr](val) if isAthValue(ans): return AthSymbol(left=ans) return ans
def biopr_expression(env, opr, lft, rht): ans = biops[opr](lft, rht) if isAthValue(ans): return AthSymbol(left=ans) return ans
def bool_not(val): if isAthValue(val): val = AthSymbol(bool(val), left=val) return AthSymbol(not val, val.left, val.right)
def cmp_opr(lval, rval, op): if isAthValue(lval): lval = AthSymbol(bool(lval), left=lval) return op(lval, rval)