summaryrefslogtreecommitdiff
path: root/repl.pl
diff options
context:
space:
mode:
Diffstat (limited to 'repl.pl')
-rw-r--r--repl.pl15
1 files changed, 8 insertions, 7 deletions
diff --git a/repl.pl b/repl.pl
index 3706437..92cdffd 100644
--- a/repl.pl
+++ b/repl.pl
@@ -1,26 +1,27 @@
:- module(repl, []).
repl([ProgName|Args]) :-
- write('Welcome to p-prolog version 1'),
+ write('Welcome to p-prolog version 1.'),
nl,
write('Started with args: '),
write(Args),
nl,
+ flush_output,
handle_args(Args),
repl_loop.
handle_arg('-d') :-
set_prolog_flag(debug, on).
handle_arg(Arg) :-
- ( '$load_module_from_file'(Arg)
- -> write('Loaded module from file: ')
- ; write('Failed to load module from file: ')
- ),
- write(Arg), nl.
+ loader:load_module_from_file(Arg).
-handle_args([Arg|Rest]) :- handle_arg(Arg), !, handle_args(Rest).
+handle_args([Arg|Rest]) :- catch(handle_arg(Arg), E, handle_arg_error(E)), !, handle_args(Rest).
handle_args([]).
+handle_arg_error(E) :-
+ write('Could not handle arg: '),
+ print_exception(E).
+
repl_loop :-
catch(read_eval_print, E, print_exception(E)),
'$collect_garbage',