Handle parsing errors

This commit is contained in:
Neale Pickett 2009-03-03 21:13:09 -07:00
parent 33d30c694d
commit d8ae40d6a7
1 changed files with 12 additions and 10 deletions

22
bot.ml
View File

@ -17,18 +17,20 @@ let write iobuf command args text =
Iobuf.write iobuf cmd Iobuf.write iobuf cmd
let scheme_eval str = let scheme_eval str =
let thread = Ocs_top.make_thread () in try
let env = Ocs_top.make_env () in let thread = Ocs_top.make_thread () in
let inport = Ocs_port.open_input_string str in let env = Ocs_top.make_env () in
let outport = Ocs_port.open_output_string () in let inport = Ocs_port.open_input_string str in
let lexer = Ocs_lex.make_lexer inport "interactive" in let outport = Ocs_port.open_output_string () in
let v = Ocs_read.read_expr lexer in let lexer = Ocs_lex.make_lexer inport "interactive" in
let c = Ocs_compile.compile env v in let v = Ocs_read.read_expr lexer in
try let c = Ocs_compile.compile env v in
Ocs_eval.eval thread (Ocs_print.print outport false) c; Ocs_eval.eval thread (Ocs_print.print outport false) c;
Ocs_port.get_output_string outport Ocs_port.get_output_string outport
with Ocs_error.Error msg -> with
msg | Ocs_error.Error msg
| Ocs_error.ErrorL (_, msg) ->
"Error: " ^ msg
let handle_privmsg iobuf sender target text = let handle_privmsg iobuf sender target text =