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