Added bind-function primitive that allows us to define functions, also changed evaluation to allow for a persistent environment

This commit is contained in:
Emin Arslan
2025-10-12 21:58:54 +03:00
committed by Emin Arslan
parent aa066f87d0
commit a905ab2b42
4 changed files with 50 additions and 16 deletions

View File

@@ -3,15 +3,15 @@ open Printf;;
open Lisp;;
open Eval;;
open Read;;
let rec repl c =
let rec repl env c =
let () = printf ">>> "; Out_channel.flush Out_channel.stdout; in
match In_channel.input_line c with
| None -> ()
| Some l ->
let vals = (parse_str l) in
(* dbg_print_all vals; *)
dbg_print_all (eval_all vals);
dbg_print_all (eval_all env vals);
Out_channel.flush Out_channel.stdout;
repl c;;
repl env c;;
let _ = repl (In_channel.stdin)
let _ = repl (make_env ()) (In_channel.stdin)