From 47ffeb4934133fab3047ff96561b1b06686307df Mon Sep 17 00:00:00 2001 From: Emin Arslan Date: Sun, 17 May 2026 20:36:21 +0300 Subject: [PATCH] repl: print errors encountered during compilation --- bin/comp.ml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/bin/comp.ml b/bin/comp.ml index f2690ba..6bc5ef6 100644 --- a/bin/comp.ml +++ b/bin/comp.ml @@ -1,4 +1,3 @@ -let ( let* ) = Result.bind;; @@ -7,10 +6,12 @@ let ( let* ) = Result.bind;; let rec interpret_loop () = let l = read_line () in - let* vm = Compiler.Emit.compile_src l in - print_endline "=== PROGRAM DISASSEMBLY"; - Vm.Types.print_instrs vm.instrs; - print_endline "=== PROGRAM OUTPUT"; - Vm.interpret vm; - interpret_loop () + let vm = Compiler.Emit.compile_src l in + match vm with + | Ok vm -> + print_endline "=== PROGRAM DISASSEMBLY"; + Vm.Types.print_instrs vm.instrs; + print_endline "=== PROGRAM OUTPUT"; + Vm.interpret vm; interpret_loop () + | Error s -> print_endline s let _ = interpret_loop ()