root/trunk/configs/quintus.config

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