From 8ef27e2fe652a8b29a8b57589863f2f2b45f9425 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Fri, 16 Jul 2021 15:36:42 +0000 Subject: Pass arguments to repl/1 --- main.c | 12 +++++++++--- module.c | 3 ++- repl.pl | 12 ++++++++++-- 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('?- '), -- cgit v1.2.3