shithub: pprolog

Download patch

ref: 8ef27e2fe652a8b29a8b57589863f2f2b45f9425
parent: 480de114963ecee700ece5b8793916726c04b9ab
author: Peter Mikkelsen <peter@pmikkelsen.com>
date: Fri Jul 16 11:36:42 EDT 2021

Pass arguments to repl/1

--- a/main.c
+++ b/main.c
@@ -38,10 +38,16 @@
 void
 repl(int argc, char *argv[])
 {
-	USED(argc);
-	USED(argv);
+	Term *args = nil;
+	while(argc > 0){
+		Term *arg = mkatom(runesmprint("%s", argv[argc-1]));
+		args = appendterm(arg, args);
+		argc--;
+	}
+	args = mklist(args);
 	Term *mod = mkatom(L"repl");
-	Term *pred = mkatom(L"repl");
+	Term *pred = mkcompound(L"repl", 1, args);
+
 	mod->next = pred;
 	Term *goal = mkcompound(L":", 2, mod);
 	evalquery(goal);	
--- a/module.c
+++ b/module.c
@@ -51,7 +51,8 @@
 				print("Module name should be an atom in: %S\n", prettyprint(directive, 0, 0, 0, nil));
 				return nil;
 			}
-			print("Public list for module '%S': %S\n", modulename->text, prettyprint(publiclist, 0, 0, 0, nil));
+			if(debug)
+				print("Public list for module '%S': %S\n", modulename->text, prettyprint(publiclist, 0, 0, 0, nil));
 			m = getmodule(modulename->text);
 		}
 		terms = terms->next;
--- a/repl.pl
+++ b/repl.pl
@@ -1,9 +1,17 @@
 :- module(repl, []).
 
-repl :-
+repl(Args) :-
+	write('Welcome to p-prolog version 1'),
+	nl,
+	write('Started with args: '),
+	write(Args),
+	nl,
+	repl_loop.
+
+repl_loop :-
 	catch(read_eval_print, E, print_exception(E)),
 	'$collect_garbage',
-	repl.
+	repl_loop.
 
 read_eval_print :-
 	write('?- '),