root/tags/lgt290/configs/lpamac.config

Revision 2, 7.9 KB (checked in by pmoura, 7 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%
3%  Logtalk - Object oriented extension to Prolog
4%  Release 2.9.0
5%
6%  initialization file for LPA MacProlog32 1.25
7%
8%  last updated: August 24, 2000
9%
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12
13:- prolog_flag(syntax_errors, _, error).
14
15
16
17%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18%
19%  ISO Prolog Standard predicates that we must define because they are
20%  not built-in
21%
22%  add a clause for lgt_iso_predicate/1 declaring each ISO predicate that
23%  we must define; there must be at least one clause for this predicate
24%  whose call should fail if we don't define any ISO predicates
25%
26%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28
29:- dynamic(lgt_exception_/1).
30
31
32% lgt_iso_predicate(?callable).
33
34lgt_iso_predicate(atom_codes(_, _)).
35lgt_iso_predicate(atom_concat(_, _, _)).
36lgt_iso_predicate(catch(_, _, _)).
37lgt_iso_predicate(nl(_)).
38lgt_iso_predicate(number_codes(_, _)).
39lgt_iso_predicate(once(_)).
40lgt_iso_predicate(open(_, _, _)).
41lgt_iso_predicate(read_term(_, _, _)).
42lgt_iso_predicate(throw(_)).
43lgt_iso_predicate(write_term(_, _, _)).
44
45
46atom_codes(Atom, Codes) :-
47    name(Atom, Codes).
48
49
50atom_concat(Atom1, Atom2, Atom3) :-
51    nonvar(Atom1), nonvar(Atom2),
52    !,
53    name(Atom1, Codes1),
54    name(Atom2, Codes2),
55    lgt_append(Codes1, Codes2, Codes3),
56    name(Atom3, Codes3).
57
58atom_concat(Atom1, Atom2, Atom3) :-
59    nonvar(Atom3),
60    !,
61    name(Atom3, Codes3),
62    lgt_append(Codes1, Codes2, Codes3),
63    name(Atom1, Codes1),
64    name(Atom2, Codes2).
65
66
67lpa_catch(Error, Goal) :-
68    catch(Error, Goal).
69
70
71:- hide(catch).
72
73
74catch(Error, Goal) :-
75    lpa_catch(Error, Goal).
76
77
78catch(Goal, Catcher, Recovery) :-
79    lpa_catch(Error, Goal),
80    (Error = 0 ->
81        true
82        ;
83        (Error = -1 ->
84            fail
85            ;
86            (Error = 999 ->
87                retract(lgt_exception_(Ball)),
88                !,
89                (Catcher = Ball ->
90                    call(Recovery)
91                    ;
92                    throw(Ball))
93                ;
94                error_message(Error, Message),
95                (Catcher = Message ->
96                    call(Recovery)
97                    ;
98                    write(Message), nl, abort)))).
99
100
101nl(Stream) :-
102    nl ~> Stream.
103
104
105number_codes(Number, Codes) :-
106    name(Number, Codes).
107
108
109once(Goal) :-
110    one(Goal).
111
112
113open(File, Mode, File) :-
114    open(File, Mode).
115
116
117read_term(Stream, Term, [singletons([])]) :-
118    !,
119    read(Term) <~ Stream.
120
121read_term(Stream, Term, _) :-
122    read(Term) <~ Stream.
123
124
125throw(Error) :-
126    asserta(lgt_exception_(Error)),
127    throw(999, Error).
128
129
130write_term(Stream, Term, [quoted(true)]) :-
131    !,
132    writeq(Term) ~> Stream.
133
134write_term(Stream, Term, _) :-
135    write(Term) ~> Stream.
136
137
138
139%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140%
141%  predicate properties
142%
143%  this predicate must return at least static, dynamic and built_in
144%  properties for an existing predicate
145%
146%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
147
148
149% lgt_predicate_property(+callable, ?predicate_property)
150
151lgt_predicate_property(Pred, Prop) :-
152    predicate_property(Pred, Prop).
153
154
155
156%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157%
158%  metapredicates
159%
160%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161
162
163% lgt_call/2-8
164%
165% use these definitions only if your compiler does
166% not provide call/1-8 as built-in predicates
167
168lgt_call(F, A) :-
169    F(A).
170
171
172lgt_call(F, A1, A2) :-
173    F(A1, A2).
174
175
176lgt_call(F, A1, A2, A3) :-
177    F(A1, A2, A3).
178
179
180lgt_call(F, A1, A2, A3, A4) :-
181    F(A1, A2, A3, A4).
182
183
184lgt_call(F, A1, A2, A3, A4, A5) :-
185    F(A1, A2, A3, A4, A5).
186
187
188lgt_call(F, A1, A2, A3, A4, A5, A6) :-
189    F(A1, A2, A3, A4, A5, A6).
190
191
192lgt_call(F, A1, A2, A3, A4, A5, A6, A7) :-
193    F(A1, A2, A3, A4, A5, A6, A7).
194
195
196% lgt_once/2-8
197%
198% if your compiler provides call/1-8 as built-in
199% predicates rewrite these definitions using call(...), !.
200
201lgt_once(F, A) :-
202    one(F(A)).
203
204
205lgt_once(F, A1, A2) :-
206    one(F(A1, A2)).
207
208
209lgt_once(F, A1, A2, A3) :-
210    one(F(A1, A2, A3)).
211
212
213lgt_once(F, A1, A2, A3, A4) :-
214    one(F(A1, A2, A3, A4)).
215
216
217lgt_once(F, A1, A2, A3, A4, A5) :-
218    one(F(A1, A2, A3, A4, A5)).
219
220
221lgt_once(F, A1, A2, A3, A4, A5, A6) :-
222    one(F(A1, A2, A3, A4, A5, A6)).
223
224
225lgt_once(F, A1, A2, A3, A4, A5, A6, A7) :-
226    one(F(A1, A2, A3, A4, A5, A6, A7)).
227
228
229
230%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231%
232%  file extension predicates
233%
234%  these extensions are used by Logtalk load/compile predicates
235%
236%  you may want to change the extension for Prolog files to match
237%  the one expected by your Prolog compiler
238%
239%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240
241
242% lgt_file_extension(?atom, ?atom)
243
244lgt_file_extension(logtalk, '.lgt').
245lgt_file_extension(prolog, '.pl').
246lgt_file_extension(xml, '.xml').
247
248
249
250%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251%
252%  default compiler options
253%
254%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
255
256
257% lgt_default_compiler_option(?atom, ?atom)
258%
259% default values for all compiler options
260
261lgt_default_compiler_option(iso_initialization_dir, true).
262
263lgt_default_compiler_option(xml, on).
264lgt_default_compiler_option(xsl, 'lgtxml.xsl').
265
266lgt_default_compiler_option(unknown, warning).
267lgt_default_compiler_option(misspelt, warning).
268lgt_default_compiler_option(singletons, warning).
269lgt_default_compiler_option(lgtredef, warning).
270lgt_default_compiler_option(plredef, silent).
271
272lgt_default_compiler_option(report, on).
273
274
275
276%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277%
278%  list predicates
279%
280%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
281
282
283lgt_append([], List, List).
284lgt_append([Head| Tail], List, [Head| Tail2]) :-
285    lgt_append(Tail, List, Tail2).
286
287
288lgt_member(Head, [Head| _]).
289lgt_member(Head, [_| Tail]) :-
290    lgt_member(Head, Tail).
291
292
293lgt_member_var(V, [H| _]) :-
294    V == H.
295lgt_member_var(V, [_| T]) :-
296    lgt_member_var(V, T).
297
298
299lgt_proper_list([]).
300lgt_proper_list([_| List]) :-
301    lgt_proper_list(List).
302
303
304
305%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306%
307%  file predicates
308%
309%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
310
311
312% lgt_file_exists(+atom)
313%
314% see if a file exist in the current directory
315
316lgt_file_exists(File) :-
317    catch(absolute_file_name(File, [access(exist)], _), _, fail).
318
319
320% lgt_load_prolog_code(+atom)
321%
322% compile and load a Prolog file
323
324lgt_load_prolog_code(File) :-
325    reconsult(File).
326
327
328
329%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330%
331%  sorting predicates
332%
333%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
334
335
336% lgt_keysort(+list, -list)
337
338lgt_keysort(List, Sorted) :-
339    keysort(List, Sorted).
340
341
342% lgt_sort(+list, -list)
343
344lgt_sort(List, Sorted) :-
345    sort(List, Sorted).
346
347
348
349%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
350%
351%  time and date predicates
352%
353%  if your Prolog compiler does not provide access to the operating system
354%  time and date just write dummy definitions
355%
356%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
357
358
359% lgt_current_date(?Year, ?Month, ?Day)
360
361lgt_current_date(Year, Month, Day) :-
362    date(Day, Month, Year).
363
364
365% lgt_current_time(?Hours, ?Mins, ?Secs)
366
367lgt_current_time(Hours, Mins, Secs) :-
368    time(Hours, Mins, Secs, _).
369
370
371
372%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
373%
374%  timing predicate
375%
376%  if your Prolog compiler does not provide access to a timing predicate
377%  just write dummy definition
378%
379%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380
381
382% lgt_cpu_time(-Seconds)
383
384lgt_cpu_time(Seconds) :-
385    ticks(Ticks),
386    Seconds is Ticks / 60.
387
388
389
390%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
391%
392%  comparison predicate
393%
394%  the usual compare/3 definition
395%
396%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
397
398
399% compare(?atom, @term, @term) -- built-in
400
401
402
403%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
404%
405%  end!
406%
407%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracBrowser for help on using the browser.