diff options
-rw-r--r-- | main.c | 12 | ||||
-rw-r--r-- | module.c | 3 | ||||
-rw-r--r-- | repl.pl | 12 |
3 files changed, 21 insertions, 6 deletions
@@ -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); @@ -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; @@ -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('?- '), |