13 Printer.display
Format.std_formatter obj
; print_flush
();;
15 let rec print_obj_list ol
=
18 | [one
] -> print_obj one
19 | more
::than
::one
-> print_obj more
; print_string
", "; print_obj_list (than
::one
);;
21 let rec repl lexbuf state
=
22 let ast = Parser.main
Lexer.token lexbuf
in
23 let next_state = Evaluator.eval
({ state
with Evaluator.cont
=[ast]; Evaluator.pending_results
=[[]] }) in
24 (match next_state.Evaluator.pending_results
with
25 [[res
]] -> print_obj res
27 | [] -> print_string
"empty"
29 print_string
"Multiple: ";
32 failwith
"Unknown result";
33 List.iter
print_obj_list lol
;
36 repl lexbuf
next_state;;
40 let lexbuf = Lexing.from_channel stdin
in
42 repl lexbuf { Evaluator.env
= Environment.initial_env
;
43 Evaluator.pending_results
= [[]];
49 | Scheme_user_error
(l
) ->
50 List.iter
(Printer.write
Format.std_formatter
) l
;