summaryrefslogtreecommitdiff
path: root/repl.pl
diff options
context:
space:
mode:
authorPeter Mikkelsen <peter@pmikkelsen.com>2021-07-20 21:58:46 +0000
committerPeter Mikkelsen <peter@pmikkelsen.com>2021-07-20 21:58:46 +0000
commit24cdc7adf5611d536403ae625414bb10f3bc4f93 (patch)
tree1f9f906f758184770de5662c173d6dcb63fade73 /repl.pl
parent90664173e5c72d0b31bdfd2c467134b3cfb3623a (diff)
Add a new work in progress loader to load all user defined modules
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',