1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
######
#
# HX-2014-08:
# for Python code translated from ATS
#
######
######
#beg of [basics_cats.py]
######
######
import sys
######
############################################
#
def ATSCKiseqz(x): return (x == 0)
def ATSCKisneqz(x): return (x != 0)
#
def ATSCKptrisnull(xs): return (xs == None)
def ATSCKptriscons(xs): return (xs != None)
#
def ATSCKpat_int(tmp, given): return (tmp == given)
def ATSCKpat_bool(tmp, given): return (tmp == given)
def ATSCKpat_char(tmp, given): return (tmp == given)
def ATSCKpat_float(tmp, given): return (tmp == given)
#
def ATSCKpat_con0 (con, tag): return (con == tag)
def ATSCKpat_con1 (con, tag): return (con[0] == tag)
#
############################################
#
def ats2pypre_list_nil(): return None
def ats2pypre_list_cons(x, xs): return (x, xs)
#
############################################
#
def ATSINScaseof_fail(em):
print("ATSINScaseof_fail:", em, file=sys.__stderr__); sys.exit(1)
return
#
def ATSINSdeadcode_fail():
print("ATSINSdeadcode_fail(", ")", file=sys.__stderr__); sys.exit(1)
return
#
############################################
def ATSPMVempty(): return
############################################
def ATSPMVlazyval_eval(lazyval):
flag = lazyval[0]
if (flag==0):
lazyval[0] = 1
mythunk = lazyval[1]
lazyval[1] = mythunk[0](mythunk)
else:
lazyval[0] = flag + 1
#endif
return lazyval[1]
#end-of-[ATSPMVlazyval_eval]
############################################
#
def ATSPMVllazyval_eval(llazyval):
return llazyval[0](llazyval, True)
def atspre_lazy_vt_free(llazyval):
return llazyval[0](llazyval, False)
#
############################################
def ats2pypre_tostring(x): return str(x)
def ats2pypre_toString(x): return str(x)
############################################
def ats2pypre_lazy2cloref(lazyval): return lazyval[1]
############################################
#
def ats2pypre_exit(ecode):
sys.exit(ecode); return
#
def ats2pypre_exit_errmsg(ecode, errmsg):
print(errmsg, file=sys.__stderr__); sys.exit(1); return
#
############################################
#
def ats2pypre_assert_bool0(tfv):
if not(tfv): sys.exit(1)
return
def ats2pypre_assert_bool1(tfv):
if not(tfv): sys.exit(1)
return
#
def ats2pypre_assert_errmsg_bool0(tfv, errmsg):
if not(tfv):
print(errmsg, file=sys.__stderr__); sys.exit(1)
return
def ats2pypre_assert_errmsg_bool1(tfv, errmsg):
if not(tfv):
print(errmsg, file=sys.__stderr__); sys.exit(1)
return
#
############################################
#
def ats2pypre_cloref0_app(cf): return cf[0](cf)
def ats2pypre_cloref1_app(cf, x): return cf[0](cf, x)
def ats2pypre_cloref2_app(cf, x1, x2): return cf[0](cf, x1, x2)
def ats2pypre_cloref3_app(cf, x1, x2, x3): return cf[0](cf, x1, x2, x3)
#
############################################
#
def ats2pypre_cloref2fun0(cf):
return lambda: ats2pypre_cloref0_app(cf)
def ats2pypre_cloref2fun1(cf):
return lambda x: ats2pypre_cloref1_app(cf, x)
def ats2pypre_cloref2fun2(cf):
return lambda x1, x2: ats2pypre_cloref2_app(cf, x1, x2)
def ats2pypre_cloref2fun3(cf):
return lambda x1, x2, x3: ats2pypre_cloref3_app(cf, x1, x2, x3)
#
############################################
###### end of [basics_cats.py] ######
|