ref: b1f62daf95818858863af0cfe7138a0acac751b2
parent: 88841b194dc86c9392a813f9b8b0cf16857acb93
author: Peter Mikkelsen <peter@pmikkelsen.com>
date: Thu Jul 22 12:37:23 EDT 2021
Use the prolog loader to load the repl.
--- a/loader.pl
+++ b/loader.pl
@@ -1,9 +1,15 @@
:- module(loader, []).
+start(Args) :-
+ catch((load_module_from_file('/sys/lib/prolog/repl.pl'), ReplLoaded = true), E, (print_exception(E), ReplLoaded = false)),
+ ( ReplLoaded = true-> repl:repl(Args) ).
+
+print_exception(E) :-
+ write('Caught exception while loading /sys/lib/prolog/repl.pl: '),
+ write(E),
+ nl.
+
load_module_from_file(File) :-
- write('Loading file: '),
- write(File),
- nl,
( atom_concat(_, '.pl', File)
-> open(File, read, Stream)
; atom_concat(File, '.pl', File1),
@@ -10,10 +16,7 @@
open(File1, read, Stream)
),
read_and_handle_terms(Stream, user, _),
- close(Stream),
- write('Loaded file: '),
- write(File),
- nl.
+ close(Stream).
read_and_handle_terms(Stream, Module0, Module) :-
( read_one_term(Stream, Term)
--- a/main.c
+++ b/main.c
@@ -37,8 +37,8 @@
argc--;
}
args = mklist(args);
- Term *mod = mkatom(L"repl");
- Term *pred = mkcompound(L"repl", 1, args);
+ Term *mod = mkatom(L"loader");
+ Term *pred = mkcompound(L"start", 1, args);
mod->next = pred;
Term *goal = mkcompound(L":", 2, mod);