From 8a1e32e6a8c441f8358bd580c655d5ff48716fa0 Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Fri, 16 Jul 2021 20:30:26 +0000 Subject: Handle -d option in prolog --- repl.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'repl.pl') diff --git a/repl.pl b/repl.pl index 1a2087a..a936535 100644 --- a/repl.pl +++ b/repl.pl @@ -1,13 +1,24 @@ :- module(repl, []). -repl(Args) :- +repl([ProgName|Args]) :- write('Welcome to p-prolog version 1'), nl, write('Started with args: '), write(Args), nl, + handle_args(Args), repl_loop. +handle_arg('-d') :- + set_prolog_flag(debug, on). +handle_arg(Arg) :- + write('Unhandled command line argument: '), + writeq(Arg), + nl. + +handle_args([Arg|Rest]) :- handle_arg(Arg), !, handle_args(Rest). +handle_args([]). + repl_loop :- catch(read_eval_print, E, print_exception(E)), '$collect_garbage', -- cgit v1.2.3