YAP
7.1.0
hacks.yap
Go to the documentation of this file.
1
/*************************************************************************
2
* *
3
* YAP Prolog *
4
* *
5
* Yap Prolog was developed at NCCUP - Universidade do Porto *
6
* *
7
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
8
* *
9
**************************************************************************
10
* *
11
* File: utilities for messing around in YAP internals. *
12
* comments: error messages for YAP *
13
* *
14
* Last rev: $Date: 2008-03-24 23:48:47 $,$Author: vsc $ *
15
* *
16
* *
17
*************************************************************************/
18
19
/**
20
* @file hacks.yap
21
* @author VITOR SANTOS COSTA <vsc@VITORs-MBP-2.lan>
22
* @date Thu Oct 19 12:02:56 2017
23
*
24
* @brief Low-level access
25
*
26
* @defgroup Hacks Low-level access
27
* @ingroup builtins
28
*
29
*/
30
31
%% @file pl/hacks.yap
32
33
:- module(
'$hacks'
,
34
[
display_stack_info/4,
35
display_stack_info/6,
36
display_pc/4,
37
fully_strip_module/3,
38
code_location/3]).
39
40
/** hacks:context_variables(-NamedVariables)
41
Access variable names.
42
43
Unify NamedVariables with a list of terms _Name_=_V_
44
giving the names of the variables occurring in the last term read.
45
Notice that variable names option must have been on.
46
*/
47
48
hacks
:
context_variables(
NamedVariables
)
:-
49
'$context_variables'(
NamedVariables
).
50
51
52
clean_goal(
G
,
Mod
,
NG
)
:-
53
beautify_hidden_goal(
G
,
Mod
,[
NG
],[]),
beautify_hidden_goal.
54
clean_goal(
G
,
_
,
G
).
55
56
scratch_goal(
N
,
0
,
Mod
,
Mod
:
N
)
:-
57
scratch_goal.
58
scratch_goal(
N
,
A
,
Mod
,
NG
)
:-
59
list_of_qmarks(
A
,
L
),
60
G
=..[
N
|
L
],
61
(
62
beautify_hidden_goal(
G
,
Mod
,[
NG
],[])
63
;
64
G
=
NG
65
),
66
!.
67
68
list_of_qmarks(
0
,[])
:-
list_of_qmarks.
69
list_of_qmarks(
I
,[?
|
L
])
:-
70
I1
is
I
-
1
,
71
list_of_qmarks(
I1
,
L
).
72
73
fully_strip_module(
T
,
M
,
TF
)
:-
74
'$yap_strip_module'(
T
,
M
,
TF
).
75
76
77
beautify_hidden_goal(
'$yes_no'
(
G
,
_Query
), prolog)
-->
78
beautify_hidden_goal,
79
{
Call
=..
[(?),
G
] },
80
[
Call
].
81
beautify_hidden_goal(
'$do_yes_no'
(
G
,
Mod
), prolog)
-->
82
[
Mod
:
G
].
83
beautify_hidden_goal(query(
G
,
VarList
), prolog)
-->
84
[
query(
G
,
VarList
)].
85
beautify_hidden_goal(
'$enter_top_level'
, prolog)
-->
86
[
'TopLevel'
].
87
% The user should never know these exist.
88
beautify_hidden_goal(
'$csult'
(
Files
,
Mod
),prolog)
-->
89
[
reconsult
(
Mod
:
Files
)].
90
beautify_hidden_goal(
'$use_module'
(
Files
,
Mod
,
Is
),prolog)
-->
91
[
use_module
(
Mod
,
Files
,
Is
)].
92
beautify_hidden_goal(
'$continue_with_command'
(reconsult,
V
,
P
,
G
,
Source
),prolog)
-->
93
[
'Assert'(
G
,
V
,
P
,
Source
)].
94
beautify_hidden_goal(
'$continue_with_command'
(consult,
V
,
P
,
G
,
Source
),prolog)
-->
95
[
'Assert'(
G
,
V
,
P
,
Source
)].
96
beautify_hidden_goal(
'$continue_with_command'
(top,
V
,
P
,
G
,
_
),prolog)
-->
97
[
'Query'(
G
,
V
,
P
)].
98
beautify_hidden_goal(
'$continue_with_command'
(
Command
,
V
,
P
,
G
,
Source
),prolog)
-->
99
[
'TopLevel'(
Command
,
G
,
V
,
P
,
Source
)].
100
beautify_hidden_goal(
'$system_catch'
(
G
,
Mod
,
Exc
,
Handler
),prolog)
-->
101
[
catch
(
Mod
:
G
,
Exc
,
Handler
)].
102
beautify_hidden_goal(
'$catch'
(
G
,
Exc
,
Handler
),prolog)
-->
103
[
catch
(
G
,
Exc
,
Handler
)].
104
beautify_hidden_goal(
'$execute_command'
(
Query
,
M
,
V
,
P
,
Option
,
Source
),prolog)
-->
105
[
toplevel_query(
M
:
Query
,
V
,
P
,
Option
,
Source
)].
106
beautify_hidden_goal(
'$process_directive'
(
Gs
,
_Mode
,
_VL
),prolog)
-->
107
[(
:-
Gs
)].
108
beautify_hidden_goal(
'$loop'
(
Stream
,
Option
),prolog)
-->
109
[
execute_load_file(
Stream
, consult
=
Option
)].
110
beautify_hidden_goal(
'$load_files'
(
Files
,
Opts
,?),prolog)
-->
111
[
load_files
(
Files
,
Opts
)].
112
beautify_hidden_goal(
'$load_files'
(
_
,
_
,
Name
),prolog)
-->
113
[
Name
].
114
beautify_hidden_goal(
'$reconsult'
(
Files
,
Mod
),prolog)
-->
115
[
reconsult
(
Mod
:
Files
)].
116
beautify_hidden_goal(
'$undefp'
(
Mod
:
G
),prolog)
-->
117
[
'CallUndefined'(
Mod
:
G
)].
118
beautify_hidden_goal(
'$undefp'
(?),prolog)
-->
119
[
'CallUndefined'(?:?)].
120
beautify_hidden_goal(repeat,prolog)
-->
121
[repeat].
122
beautify_hidden_goal(
'$recorded_with_key'
(
A
,
B
,
C
),prolog)
-->
123
[
recorded
(
A
,
B
,
C
)].
124
beautify_hidden_goal(
'$findall_with_common_vars'
(
Templ
,
Gen
,
Answ
),prolog)
-->
125
[
findall
(
Templ
,
Gen
,
Answ
)].
126
beautify_hidden_goal(
'$bagof'
(
Templ
,
Gen
,
Answ
),prolog)
-->
127
[
bagof
(
Templ
,
Gen
,
Answ
)].
128
beautify_hidden_goal(
'$setof'
(
Templ
,
Gen
,
Answ
),prolog)
-->
129
[
setof
(
Templ
,
Gen
,
Answ
)].
130
beautify_hidden_goal(
'$findall'
(
T
,
G
,
S
,
A
),prolog)
-->
131
[
findall
(
T
,
G
,
S
,
A
)].
132
beautify_hidden_goal(
'$listing'
(
G
,
M
,
_Stream
),prolog)
-->
133
[
listing
(
M
:
G
)].
134
beautify_hidden_goal(
'$call'
(
G
,
_CP
,?,
M
),prolog)
-->
135
[
call
(
M
:
G
)].
136
beautify_hidden_goal(
'$call'
(
_G
,
_CP
,
G0
,
M
),prolog)
-->
137
[
call
(
M
:
G0
)].
138
beautify_hidden_goal(
'$current_predicate'
(
Na
,
M
,
S
,
_
),prolog)
-->
139
[
current_predicate
(
Na
,
M
:
S
)].
140
beautify_hidden_goal(
'$list_clauses'
(
Stream
,
M
,
Pred
),prolog)
-->
141
[
listing
(
Stream
,
M
:
Pred
)].
142
143
144
prolog
:
ctrace(
G
)
:-
145
gated_call(start_low_level_trace,
146
G
,
147
_
,
148
stop_low_level_trace).
149
150
catch/3
catch( : Goal,+ Exception,+ Action)
current_predicate/2
current_predicate( A, P)
recorded/3
Definition:
dbase.c:5369
listing/1
listing(+ P)
Definition:
listing.yap:73
listing/2
listing(Stream, + P)
use_module/3
use_module(? M,? F,+ L)
bagof/3
bagof( T,+ G,- L)
findall/3
findall( T,+ G,- L)
Definition:
setof.yap:70
findall/4
findall( ?Key, +Goal, +InitialSolutions, -Solutions )
setof/3
setof( X,+ P,- B)
call/1
call( 0:P )
load_files/2
load_files(+_Files_, +_Options_)
reconsult/1
reconsult(+ F )
pl
hacks.yap
Generated by
1.9.3