root/trunk/configs/sicstus3.config

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