]> Repositorios git - scryer-prolog.git/commitdiff
Added library(debug)
authornotoria <[email protected]>
Fri, 19 Jun 2020 15:18:59 +0000 (17:18 +0200)
committernotoria <[email protected]>
Fri, 19 Jun 2020 15:18:59 +0000 (17:18 +0200)
src/lib/debug.pl [new file with mode: 0644]

diff --git a/src/lib/debug.pl b/src/lib/debug.pl
new file mode 100644 (file)
index 0000000..bc9f9df
--- /dev/null
@@ -0,0 +1,22 @@
+% Source: https://stackoverflow.com/a/30791637
+
+:- module(debug, [
+    op(900, fx, $),
+    op(900, fx, $-),
+    op(950, fy, *),
+    (*)/1,
+    ($)/1,
+    ($-)/1
+]).
+
+:- use_module(library(format), [portray_clause/1]).
+
+$-(G_0) :-
+   catch(G_0, Ex, ( portray_clause(exception:Ex:G_0), throw(Ex) ) ).
+
+$(G_0) :-
+   portray_clause(call:G_0),
+   $-G_0,
+   portray_clause(exit:G_0).
+
+*(_).