root/trunk/configs/amzi.config

Revision 4580, 12.4 KB (checked in by pmoura, 13 days ago)

Added a "prolog" read-only compiler flag whose value is the name of the back-end Prolog compiler (an atom). This flag can be used for conditional compilation of Prolog specific code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%
3%  Logtalk - Open source object-oriented logic programming language
4%  Release 2.33.3
5%
6%  Copyright (c) 1998-2008 Paulo Moura.        All Rights Reserved.
7%  Logtalk is free software.  You can redistribute it and/or modify
8%  it under the terms of the "Artistic License 2.0" as published by
9%  The Perl Foundation. Consult the "LICENSE.txt" file for details.
10%
11%
12%  configuration file for Amzi! Prolog 7.6.1 and later versions
13%
14%  last updated: November 7, 2008
15%
16%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17
18
19:- loadlsx('aosutils.lsx').
20
21
22
23%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24%
25%  ISO Prolog Standard predicates that we must define because they are
26%  not built-in
27%
28%  add a clause for lgt_iso_predicate/1 declaring each ISO predicate that
29%  we must define; there must be at least one clause for this predicate
30%  whose call should fail if we don't define any ISO predicates
31%
32%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33
34
35initialization(Goal) :-
36    call(Goal).
37
38
39% '$lgt_iso_predicate'(?callable).
40
41'$lgt_iso_predicate'(read_term(_, _, _)).
42'$lgt_iso_predicate'(write_canonical(_, _)).
43'$lgt_iso_predicate'(write_term(_, _, _)).
44
45
46read_term(Stream, Term, [singletons([])]) :-
47    !,
48    read(Stream, Term).
49
50read_term(Stream, Term, _) :-
51    read(Stream, Term).
52
53
54write_canonical(Stream, Term) :-
55    writeq(Stream, Term).
56
57
58write_term(Stream, Term, [quoted(true)]) :-
59    !,
60    writeq(Stream, Term).
61
62write_term(Stream, Term, _) :-
63    write(Stream, Term).
64
65
66
67%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68%
69%  predicate properties
70%
71%  this predicate must return at least static, dynamic, and built_in
72%  properties for an existing predicate
73%
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75
76
77% '$lgt_predicate_property'(+callable, ?predicate_property)
78
79'$lgt_predicate_property'(Predicate, Property) :-
80    functor(Predicate, Functor, Arity),
81    '$lgt_predicate_property_pi'(Functor/Arity, Property).
82
83
84'$lgt_predicate_property_pi'(Predicate, built_in) :-
85    predicate_property(Predicate, imported_from(amzi_system)),
86    \+ predicate_property(Predicate, built_in).
87
88'$lgt_predicate_property_pi'(Predicate, Property) :-
89    predicate_property(Predicate, Property).
90
91
92
93%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94%
95%  meta-predicates
96%
97%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98
99
100% call_cleanup(+callable, +callble)
101
102call_cleanup(_, _) :-
103    throw(not_supported(call_cleanup/2)).
104
105
106% forall(+callable, +callble) -- built-in
107
108forall(Generate, Test) :-
109    \+ (Generate, \+ Test).
110
111
112% retractall(+callable) -- built-in
113
114
115% call_with_args/2-9
116%
117% use these definitions only if your compiler does
118% not provide call_with_args/2-9 as built-in predicates
119
120call_with_args(F, A) :-
121    Call =.. [F, A],
122    call(Call).
123
124call_with_args(F, A1, A2) :-
125    Call =.. [F, A1, A2],
126    call(Call).
127
128call_with_args(F, A1, A2, A3) :-
129    Call =.. [F, A1, A2, A3],
130    call(Call).
131
132call_with_args(F, A1, A2, A3, A4) :-
133    Call =.. [F, A1, A2, A3, A4],
134    call(Call).
135
136call_with_args(F, A1, A2, A3, A4, A5) :-
137    Call =.. [F, A1, A2, A3, A4, A5],
138    call(Call).
139
140call_with_args(F, A1, A2, A3, A4, A5, A6) :-
141    Call =.. [F, A1, A2, A3, A4, A5, A6],
142    call(Call).
143
144call_with_args(F, A1, A2, A3, A4, A5, A6, A7) :-
145    Call =.. [F, A1, A2, A3, A4, A5, A6, A7],
146    call(Call).
147
148call_with_args(F, A1, A2, A3, A4, A5, A6, A7, A8) :-
149    Call =.. [F, A1, A2, A3, A4, A5, A6, A7, A8],
150    call(Call).
151
152
153
154%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155%
156%  Prolog built-in Prolog built-in meta-predicatess
157%
158%  (excluding ISO Prolog Standard meta-predicates)
159%
160%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161
162
163% '$lgt_pl_meta_predicate'(?callable, ?atom).
164
165'$lgt_pl_meta_predicate'(not(::), predicate).
166
167
168
169%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
170%
171%  file extension predicates
172%
173%  these extensions are used by Logtalk load/compile predicates
174%
175%  you may want to change the extension for Prolog files to match
176%  the one expected by your Prolog compiler
177%
178%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179
180
181% '$lgt_file_extension'(?atom, ?atom)
182
183'$lgt_file_extension'(logtalk, '.lgt').
184'$lgt_file_extension'(prolog, '.pro').
185'$lgt_file_extension'(xml, '.xml').
186
187
188
189%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
190%
191%  default flag values
192%
193%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
194
195
196% '$lgt_default_flag'(?atom, ?atom)
197%
198% default values for all flags
199
200'$lgt_default_flag'(prolog, amzi).
201
202'$lgt_default_flag'(xmldocs, on).
203'$lgt_default_flag'(xslfile, 'lgtxml.xsl').
204'$lgt_default_flag'(xmlspec, dtd).
205'$lgt_default_flag'(xmlsref, local).
206
207'$lgt_default_flag'(unknown, warning).
208'$lgt_default_flag'(misspelt, warning).
209'$lgt_default_flag'(singletons, warning).
210'$lgt_default_flag'(lgtredef, warning).
211'$lgt_default_flag'(plredef, silent).
212'$lgt_default_flag'(portability, silent).
213
214'$lgt_default_flag'(report, on).
215
216'$lgt_default_flag'(smart_compilation, off).
217'$lgt_default_flag'(reload, always).
218
219'$lgt_default_flag'(startup_message, flags(verbose)).
220
221'$lgt_default_flag'(underscore_variables, singletons).
222
223'$lgt_default_flag'(code_prefix, '').
224
225'$lgt_default_flag'(debug, off).
226'$lgt_default_flag'(break_predicate, unsupported).
227
228'$lgt_default_flag'(complements, off).
229'$lgt_default_flag'(dynamic_declarations, off).
230'$lgt_default_flag'(events, off).
231
232'$lgt_default_flag'(altdirs, off).
233'$lgt_default_flag'(tmpdir, 'lgt_tmp/').
234'$lgt_default_flag'(xmldir, 'xml_docs/').
235
236'$lgt_default_flag'(encoding_directive, unsupported).
237'$lgt_default_flag'(multifile_directive, unsupported).
238'$lgt_default_flag'(threads, unsupported).
239
240'$lgt_default_flag'(context_switching_calls, allow).
241
242
243
244%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245%
246%  list predicates
247%
248%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
249
250
251'$lgt_append'([], List, List).
252'$lgt_append'([Head| Tail], List, [Head| Tail2]) :-
253    '$lgt_append'(Tail, List, Tail2).
254
255
256'$lgt_member'(Head, [Head| _]).
257'$lgt_member'(Head, [_| Tail]) :-
258    '$lgt_member'(Head, Tail).
259
260
261'$lgt_member_var'(V, [H| _]) :-
262    V == H.
263'$lgt_member_var'(V, [_| T]) :-
264    '$lgt_member_var'(V, T).
265
266
267'$lgt_is_list'([]) :-
268    !.
269'$lgt_is_list'([_| Tail]) :-
270    '$lgt_is_list'(Tail).
271
272
273'$lgt_is_proper_list'(List) :-
274    List == [], !.
275'$lgt_is_proper_list'([_| Tail]) :-
276    nonvar(Tail),
277    '$lgt_is_proper_list'(Tail).
278
279
280
281%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282%
283%  file predicates
284%
285%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
286
287
288% '$lgt_file_exists'(+atom)
289%
290% see if a file exist in the current directory
291
292'$lgt_file_exists'(File) :-
293    file_exists(File).
294
295
296% '$lgt_directory_exists'(+atom)
297%
298% checks if a directory exists
299
300'$lgt_directory_exists'(Directory) :-
301    file_exists(Directory).
302
303
304% '$lgt_current_directory'(-atom)
305%
306% gets current working directory
307
308'$lgt_current_directory'(Directory) :-
309    curdir(Directory).
310
311
312% '$lgt_change_directory'(+atom)
313%
314% changes current working directory
315
316'$lgt_change_directory'(Directory) :-
317    chdir(Directory).
318
319
320% '$lgt_make_directory'(+atom)
321%
322% makes a new directory; succeeds if the directory already exists
323
324'$lgt_make_directory'(Directory) :-
325    (   file_exists(Directory) ->
326        true
327    ;   mkdir(Directory)
328    ).
329
330
331% '$lgt_load_prolog_code'(+atom, +atom, +list)
332%
333% compile and load a Prolog file, resulting from a
334% Logtalk source file, given a list of options
335
336'$lgt_load_prolog_code'(File, _, _) :-
337    reconsult(File).
338
339
340% '$lgt_compare_file_mtimes'(?atom, +atom, +atom)
341%
342% compare file modification times
343
344'$lgt_compare_file_mtimes'(_, _, _) :-
345    fail.
346
347
348
349%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
350%
351%  sorting predicates
352%
353%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
354
355
356% '$lgt_keysort'(+list, -list)
357
358'$lgt_keysort'(List, Sorted) :-
359    keysort(List, Sorted).
360
361
362% '$lgt_sort'(+list, -list)
363
364'$lgt_sort'(List, Sorted) :-
365    sort(List, Sorted).
366
367
368
369%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
370%
371%  time and date predicates
372%
373%  if your Prolog compiler does not provide access to the operating system
374%  time and date just write dummy definitions
375%
376%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
377
378
379% '$lgt_current_date'(?Year, ?Month, ?Day)
380
381'$lgt_current_date'(Year, Month, Day) :-
382    date(Month, Day, Year).
383
384
385% '$lgt_current_time'(?Hours, ?Mins, ?Secs)
386
387'$lgt_current_time'(Hours, Mins, Secs) :-
388    time(Hours, Mins, Secs).
389
390
391
392%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
393%
394%  timing predicate
395%
396%  if your Prolog compiler does not provide access to a timing predicate
397%  just write dummy definition
398%
399%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
400
401
402% '$lgt_cpu_time'(-Seconds)
403
404
405'$lgt_cpu_time'(Seconds) :-
406    Seconds is cputime.
407
408
409
410%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
411%
412%  comparison predicate
413%
414%  the usual compare/3 definition
415%
416%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
417
418
419% compare(Order, Term1, Term2) -- built-in
420
421
422
423%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
424%
425%  callable predicate
426%
427%  the usual callable/1 definition
428%
429%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
430
431
432% callable(@term)
433
434callable(Term) :-
435    nonvar(Term),
436    functor(Term, Functor, _),
437    atom(Functor).
438
439
440
441%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
442%
443%  read character predicate
444%
445%  read a single character echoing it and writing a newline after
446%
447%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
448
449
450'$lgt_read_single_char'(Char) :-
451    respkey(Code), nl, name(Char, [Code]).
452
453
454
455%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
456%
457%  pretty print a term by naming its free variables
458%  (avoid instantiating variables in term by using double negation if necessary)
459%
460%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
461
462
463'$lgt_pretty_print_vars'(Stream, Term) :-
464    \+ \+ (numbervars(Term, 1, _), write(Stream, Term)).
465
466
467'$lgt_pretty_print_vars_quoted'(Stream, Term) :-
468    \+ \+ (numbervars(Term, 1, _), writeq(Stream, Term)).
469
470
471
472%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473%
474%  getting stream current line number
475%  (needed for improved compiler error messages)
476%
477%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
478
479
480% '$lgt_stream_current_line_number'(@stream, -integer)
481
482'$lgt_stream_current_line_number'(_, _) :-
483    fail.
484
485
486
487%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
488%
489%  customized version of the read_term/3 predicate for returning the line
490%  where the term starts (needed for improved compiler error messages)
491%
492%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
493
494
495% '$lgt_read_term'(@stream, -term, +list, -integer)
496
497'$lgt_read_term'(Stream, Term, Options, -1) :-
498    read_term(Stream, Term, Options).
499
500
501
502%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
503%
504%  handling of Prolog-proprietary directives on Logtalk source files
505%
506%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507
508
509% '$lgt_ignore_pl_directive'(@callable)
510
511'$lgt_ignore_pl_directive'(_) :-
512    fail.
513
514
515% '$lgt_rewrite_and_copy_pl_directive'(@callable, -callable)
516
517'$lgt_rewrite_and_copy_pl_directive'(_, _) :-
518    fail.
519
520
521% '$lgt_rewrite_and_recompile_pl_directive'(@callable, -callable)
522
523'$lgt_rewrite_and_recompile_pl_directive'(_, _) :-
524    fail.
525
526
527
528%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
529%
530%  Shortcut to the Logtalk built-in predicate logtalk_load/1
531%
532%  defined in the config files in order to be able to comment it out in case
533%  of conflict with some Prolog native feature; it implies conformance with
534%  the ISO Prolog standard regarding the definition of the {}/1 syntax
535%
536%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
537
538{File, Files} :-
539    !,
540    logtalk_load(File),
541    {Files}.
542{File} :-
543    logtalk_load(File).
544
545
546
547%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
548%
549%  end!
550%
551%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note: See TracBrowser for help on using the browser.