root/trunk/configs/cx.config

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