root/trunk/configs/master.config

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