diff --git a/src/lisp/drawl.pla b/src/lisp/drawl.pla index 0c2099d..5530c58 100644 --- a/src/lisp/drawl.pla +++ b/src/lisp/drawl.pla @@ -65,7 +65,7 @@ byte quit = FALSE // quit interpreter flag def natv_bye(expr) quit = TRUE - return NULL // Quick exit from REPL + return new_sym("GOODBYE!") end def natv_memavail(expr) @@ -144,7 +144,7 @@ end def parse_cmdline#0 var filename - puts("DRAWL (LISP 1.5) symbolic processing") + puts("DRAWL (LISP 1.5) symbolic processor") readfn = @read_keybd filename = argNext(argFirst) if ^filename @@ -168,5 +168,5 @@ while not quit putln; print_expr(eval_expr(readfn())) gc_trigger--; if gc_trigger == 0; gc; gc_trigger = GC_RESET; fin loop -puts("\nGoodbye!\n") +putln done diff --git a/src/lisp/s-expr.pla b/src/lisp/s-expr.pla index 66b3655..6de61a9 100644 --- a/src/lisp/s-expr.pla +++ b/src/lisp/s-expr.pla @@ -497,16 +497,19 @@ def eval_lambda(expr, params) print_expr(expr) return NULL fin + // + // Build arg list before prepending to assoc_list + // assoc_org = assoc_list args = expr=>cdr=>car newlist = NULL while args - if !newlist - newlist = new_cons - pairlist = newlist - else + if newlist pairlist=>cdr = new_cons pairlist = pairlist=>cdr + else + newlist = new_cons + pairlist = newlist fin pair = new_cons pair=>car = args=>car @@ -678,58 +681,60 @@ export def eval_num(expr)#2 end def natv_add(expr) - var num[2] + var[2] sum, num - zero32 + sum[0] = 0 + sum[1] = 0 while expr num[0], num[1] = eval_num(expr) - add32(@num) + load32(@num) + add32(@sum) + store32(@sum) expr = expr=>cdr loop - store32(@num) - return new_int(num[0], num[1]) + return new_int(sum[0], sum[1]) end def natv_sub(expr) - var num[2] + var[2] dif, num num[0], num[1] = eval_num(expr) + dif[0], dif[1] = eval_num(expr=>cdr) load32(@num) - num[0], num[1] = eval_num(expr=>cdr) - sub32(@num) - store32(@num) - return new_int(num[0], num[1]) + sub32(@dif) + store32(@dif) + return new_int(dif[0], dif[1]) end def natv_mul(expr) - var num[2] + var[2] mul, num num[0], num[1] = eval_num(expr) + mul[0], mul[1] = eval_num(expr=>cdr) load32(@num) - num[0], num[1] = eval_num(expr=>cdr) - mul32(@num) - store32(@num) - return new_int(num[0], num[1]) + mul32(@mul) + store32(@mul) + return new_int(mul[0], mul[1]) end def natv_div(expr) - var num[2] + var[2] num, div num[0], num[1] = eval_num(expr) + div[0], div[1] = eval_num(expr=>cdr) load32(@num) - num[0], num[1] = eval_num(expr=>cdr) - div32(@num) - store32(@num) - return new_int(num[0], num[1]) + div32(@div) + store32(@div) + return new_int(div[0], div[1]) end def natv_rem(expr) - var num[2] + var[2] num, div num[0], num[1] = eval_num(expr) + div[0], div[1] = eval_num(expr=>cdr) load32(@num) - num[0], num[1] = eval_num(expr=>cdr) - num[1], num[0] = div32(@num) + num[1], num[0] = div32(@div) return new_int(num[0], num[1]) end @@ -744,21 +749,21 @@ def natv_neg(expr) end def natv_gt(expr) - var num[2] + var[2] num1, num2 - num[0], num[1] = eval_num(expr) - load32(@num) - num[0], num[1] = eval_num(expr=>cdr) - return bool_pred(isgt32(@num)) + num1[0], num1[1] = eval_num(expr) + num2[0], num2[1] = eval_num(expr=>cdr) + load32(@num1) + return bool_pred(isgt32(@num2)) end def natv_lt(expr) - var num[2] + var[2] num1, NUM2 - num[0], num[1] = eval_num(expr) - load32(@num) - num[0], num[1] = eval_num(expr=>cdr) - return bool_pred(islt32(@num)) + num1[0], num1[1] = eval_num(expr) + num2[0], num2[1] = eval_num(expr=>cdr) + load32(@num1) + return bool_pred(islt32(@num2)) end def natv_print(expr)