This repository has been archived on 2025-09-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2025LogProg-project-GhentPr.../examples/meta/interpreter.pl

27 lines
508 B
Prolog

interpreter :-
interpreter_prompt,
read(Goal),
interpreter(Goal).
interpreter_prompt :- write('Next Command ?-- ').
interpreter(exit) :- !.
interpreter(Goal) :-
ground(Goal), !,
solve_ground(Goal),
interpreter.
interpreter(Goal) :-
solve(Goal),
interpreter.
solve_ground(Goal) :-
call(Goal),
!,
writeln('True :)').
solve_ground(_) :- writeln('False :(').
solve(Goal) :-
call(Goal),
writeln(Goal),
fail.
solve(_) :- writeln('No more solutions :/').