Reorganized basically everything, making way for the compiler

This commit is contained in:
2025-11-15 13:06:16 +03:00
parent 27115ab4f2
commit 3f0a860a03
15 changed files with 84 additions and 25 deletions

31
bin/inter.ml Normal file
View File

@@ -0,0 +1,31 @@
open Interpreter.Ast;;
open Printf;;
open Interpreter;;
open Env;;
open Eval;;
let () = Stdlib.init_default_env ()
let rec repl env c =
let () = printf ">>> "; Out_channel.flush Out_channel.stdout; in
match In_channel.input_line c with
| None -> ()
| Some "exit" -> ()
| Some l ->
try
let vals = (read_from_str l) in
(* dbg_print_all vals; *)
pretty_print_all (eval_all env vals);
Out_channel.flush Out_channel.stdout;
repl env c
with
| Invalid_argument s ->
printf "%s\nResuming repl\n" s;
repl env c
| Parser.Parse.Error ->
printf "Expression '%s' couldn't be parsed, try again\n" l;
repl env c
;;
let () = repl (make_env ()) (In_channel.stdin)