summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Mikkelsen <peter@pmikkelsen.com>2021-07-16 15:36:42 +0000
committerPeter Mikkelsen <peter@pmikkelsen.com>2021-07-16 15:36:42 +0000
commit8ef27e2fe652a8b29a8b57589863f2f2b45f9425 (patch)
tree94d0294034fb746796e771b6f7e538b2a0f2207c
parent480de114963ecee700ece5b8793916726c04b9ab (diff)
Pass arguments to repl/1
-rw-r--r--main.c12
-rw-r--r--module.c3
-rw-r--r--repl.pl12
3 files changed, 21 insertions, 6 deletions
diff --git a/main.c b/main.c
index 463e881..f546384 100644
--- a/main.c
+++ b/main.c
@@ -38,10 +38,16 @@ usage(void)
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);
diff --git a/module.c b/module.c
index 1ac931e..7d23f85 100644
--- a/module.c
+++ b/module.c
@@ -51,7 +51,8 @@ parsemodule(char *file)
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;
diff --git a/repl.pl b/repl.pl
index eb272a9..60521df 100644
--- 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('?- '),