#include "h.h" #include #include int od; // Number of primordial values uchar code[codesize]; // The compiled code static uchar false[] = {255, 0}; // (λx(λyy)) static uchar true [] = {255, 1}; // (λx(λyx)) static val increment(nis w){return (val){0, { .i = w+1}};} static val decrement(nis w){return (val){0, { .i = w-1}};} static val zeropred (nis w){return (val){1, { .f = {0, !w?true:false}}};} static val Putchar(nis w){putchar(w); return (val){0, { .i = w}};} static jmp_buf again; void Bye(char * d){loc(); printf("%s\n", d); tcflush(1, TCIFLUSH); longjmp(again, 42);} int main(){setjmp(again); {env * prime_env = 0; cd=0; {void makeVal(uchar nm, val v){env * p = gw(0); p->out = prime_env; prime_env = p; p->v = v; symbols[cd++] = nm;} {void make_prim_fun(uchar nm, pf f){makeVal(nm, (val){2, { .p = f}});} make_prim_fun('i', increment); make_prim_fun('d', decrement); make_prim_fun('P', Putchar); make_prim_fun('z', zeropred);} {void make_first_fun(uchar nm, cp f) {makeVal(nm, (val){1, { .f = {0, f}}});} make_first_fun('H', false); make_first_fun('K', true);}} while(1) {cx = code; od=cd; compile(); printf("code ="); {uchar * j; for(j = code; j