34
35:- module(yap,
36 [ gc/0,
37 depth_bound_call/2, 38 system/1, 39 exists/1, 40 assert_static/1, 41 source/0,
42 yap_flag/2, 43 yap_style_check/1 44 ]).
80 83
84:- multifile
85 user:goal_expansion/2,
86 user:file_search_path/2,
87 user:prolog_file_type/2,
88 yap_expansion/2. 89:- dynamic
90 user:goal_expansion/2,
91 user:file_search_path/2,
92 user:prolog_file_type/2. 93
94user:goal_expansion(In, Out) :-
95 prolog_load_context(dialect, yap),
96 yap_expansion(In, Out).
104yap_expansion(eval_arith(Expr, Result),
105 Result is Expr).
106yap_expansion(if(Goal, Then),
107 (Goal *-> Then; true)).
108yap_expansion(if(Goal, Then, Else),
109 (Goal *-> Then; Else)).
110yap_expansion(style_check(Style),
111 yap_style_check(Style)).
112
113
114
123push_yap_library :-
124 ( absolute_file_name(library(dialect/yap), Dir,
125 [ file_type(directory),
126 access(read),
127 solutions(all),
128 file_errors(fail)
129 ]),
130 asserta((user:file_search_path(library, Dir) :-
131 prolog_load_context(dialect, yap))),
132 fail
133 ; true
134 ).
142push_yap_file_extension :-
143 asserta((user:prolog_file_type(yap, prolog) :-
144 prolog_load_context(dialect, yap))).
145
146:- push_yap_library,
147 push_yap_file_extension. 148
149
150
160gc :-
161 garbage_collect.
169:- module_transparent
170 depth_bound_call/2. 171
172depth_bound_call(G, L) :-
173 call_with_depth_limit(G, L, _).
181system(Command) :-
182 shell(Command).
190exists(File) :-
191 exists_file(File).
204:- module_transparent
205 assert_static/1. 206
207assert_static(Term) :-
208 assert(Term).
216source.
228yap_flag(write_strings, OnOff) :- !,
229 map_bool(OnOff, Bool),
230 set_prolog_flag(write_strings, Bool).
231yap_flag(Flag, Value) :-
232 fixme_true(yap_flag(Flag, Value)).
233
234map_bool(on, true) :- !.
235map_bool(off, false) :- !.
236map_bool(Bool, Bool).
237
238:- multifile
239 user:portray/1. 240
241user:portray(String) :-
242 current_prolog_flag(write_strings, true),
243 is_list(String),
244 length(String, L),
245 L > 2,
246 maplist(printable, String),
247 format('"~s"', [String]).
248
249printable(C) :- code_type(C, graph), !.
250printable(C) :- code_type(C, space), !.
257yap_style_check(all) :- !,
258 system:style_check([ +singleton,
259 +discontiguous
260 ]).
261yap_style_check(Style) :-
262 fixme_true(yap_style_check(Style)).
263
264
265 268
269:- dynamic
270 fixme_reported/1. 271
272fixme_true(Goal) :-
273 fixme_reported(Goal), !.
274fixme_true(Goal) :-
275 print_message(warning, yap_unsupported(Goal)),
276 assert(fixme_reported(Goal)).
277
278
279:- multifile
280 prolog:message//1. 281
282prolog:message(yap_unsupported(Goal)) -->
283 [ 'YAP emulation (yap.pl): unsupported: ~p'-[Goal] ]
YAP Compatibility module
This module provides compatibility to YAP through the directive expects_dialect/1:
The task of this module is:
.yap
extension as extension for Prolog files. If both a.pl
and.yap
is present, the.yap
file is loaded if the current environment expects YAP.Current set is taken from http://www.david-reitter.com/compling/prolog/compat_swi.pl, written by David Reitter and Steve Moyle