%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Logtalk - Open source object-oriented logic programming language % Release 2.33.3 % % Copyright (c) 1998-2008 Paulo Moura. All Rights Reserved. % Logtalk is free software. You can redistribute it and/or modify % it under the terms of the "Artistic License 2.0" as published by % The Perl Foundation. Consult the "LICENSE.txt" file for details. % % % configuration file for CxProlog 0.97.2 or a later version % % last updated: November 7, 2008 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% :- set_prolog_flag(keep_source, false). :- set_prolog_flag(unknown, error). :- set_prolog_flag(file_name_variables, true). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ISO Prolog Standard predicates that we must define because they are % not built-in % % add a clause for lgt_iso_predicate/1 declaring each ISO predicate that % we must define; there must be at least one clause for this predicate % whose call should fail if we don't define any ISO predicates % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_iso_predicate'(?callable). % % table of definition for missing ISO predicates '$lgt_iso_predicate'(_) :- fail. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % predicate properties % % this predicate must return at least static, dynamic, and built_in % properties for an existing predicate % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_predicate_property'(+callable, ?predicate_property) '$lgt_predicate_property'(Pred, Prop) :- predicate_property(Pred, Prop). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % meta-predicates % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % call_cleanup(+callable, +callble) -- built-in % forall(+callable, +callble) -- built-in % retractall(+callable) -- built-in % lgt_call/2-9 % % if your compiler provides call/1-9 as built-in % predicates rewrite these definitions using call(...). call_with_args(F, A) :- call(F, A). call_with_args(F, A1, A2) :- call(F, A1, A2). call_with_args(F, A1, A2, A3) :- call(F, A1, A2, A3). call_with_args(F, A1, A2, A3, A4) :- call(F, A1, A2, A3, A4). call_with_args(F, A1, A2, A3, A4, A5) :- call(F, A1, A2, A3, A4, A5). call_with_args(F, A1, A2, A3, A4, A5, A6) :- call(F, A1, A2, A3, A4, A5, A6). call_with_args(F, A1, A2, A3, A4, A5, A6, A7) :- call(F, A1, A2, A3, A4, A5, A6, A7). call_with_args(F, A1, A2, A3, A4, A5, A6, A7, A8) :- call(F, A1, A2, A3, A4, A5, A6, A7, A8). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Prolog built-in meta-predicates % % (excluding ISO Prolog Standard meta-predicates) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_pl_meta_predicate'(?callable, ?atom). '$lgt_pl_meta_predicate'(catch(::, *, *, ::), predicate). '$lgt_pl_meta_predicate'(gen(::), predicate). '$lgt_pl_meta_predicate'(possible(::), predicate). '$lgt_pl_meta_predicate'(question(::, *), predicate). '$lgt_pl_meta_predicate'(not(::), predicate). '$lgt_pl_meta_predicate'(on_exception(*, ::, ::), predicate). '$lgt_pl_meta_predicate'(process_new(*, ::, ::), predicate). '$lgt_pl_meta_predicate'(thread_new(*, ::, ::), predicate). '$lgt_pl_meta_predicate'(try(::), predicate). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % file extension predicates % % these extensions are used by Logtalk load/compile predicates % % you may want to change the extension for Prolog files to match % the one expected by your Prolog compiler % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_file_extension'(?atom, ?atom) '$lgt_file_extension'(logtalk, '.lgt'). '$lgt_file_extension'(prolog, '.pl'). '$lgt_file_extension'(xml, '.xml'). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % default flag values % % if your Prolog compiler supports the ISO definition of the % initialization/1 then change the default value below to true % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_default_flag'(?atom, ?atom) % % default values for all flags '$lgt_default_flag'(prolog, cx). '$lgt_default_flag'(xmldocs, on). '$lgt_default_flag'(xslfile, 'lgtxml.xsl'). '$lgt_default_flag'(xmlspec, dtd). '$lgt_default_flag'(xmlsref, local). '$lgt_default_flag'(unknown, warning). '$lgt_default_flag'(misspelt, warning). '$lgt_default_flag'(singletons, warning). '$lgt_default_flag'(lgtredef, warning). '$lgt_default_flag'(plredef, silent). '$lgt_default_flag'(portability, silent). '$lgt_default_flag'(report, on). '$lgt_default_flag'(smart_compilation, off). '$lgt_default_flag'(reload, always). '$lgt_default_flag'(startup_message, flags(verbose)). '$lgt_default_flag'(underscore_variables, singletons). '$lgt_default_flag'(code_prefix, ''). '$lgt_default_flag'(debug, off). '$lgt_default_flag'(break_predicate, unsupported). '$lgt_default_flag'(complements, off). '$lgt_default_flag'(dynamic_declarations, off). '$lgt_default_flag'(events, off). '$lgt_default_flag'(altdirs, off). '$lgt_default_flag'(tmpdir, 'lgt_tmp/'). '$lgt_default_flag'(xmldir, 'xml_docs/'). '$lgt_default_flag'(encoding_directive, source). '$lgt_default_flag'(multifile_directive, supported). '$lgt_default_flag'(threads, unsupported). '$lgt_default_flag'(context_switching_calls, allow). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % list predicates % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% '$lgt_append'([], List, List). '$lgt_append'([Head| Tail], List, [Head| Tail2]) :- '$lgt_append'(Tail, List, Tail2). '$lgt_member'(Head, [Head| _]). '$lgt_member'(Head, [_| Tail]) :- '$lgt_member'(Head, Tail). '$lgt_member_var'(V, [H| _]) :- V == H. '$lgt_member_var'(V, [_| T]) :- '$lgt_member_var'(V, T). '$lgt_is_list'([]) :- !. '$lgt_is_list'([_| Tail]) :- '$lgt_is_list'(Tail). '$lgt_is_proper_list'(List) :- List == [], !. '$lgt_is_proper_list'([_| Tail]) :- nonvar(Tail), '$lgt_is_proper_list'(Tail). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % file predicates % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_file_exists'(+atom) % % see if a file exist in the current directory '$lgt_file_exists'(File) :- fs_exists_file(File). % '$lgt_directory_exists'(+atom) % % checks if a directory exists '$lgt_directory_exists'(Directory) :- fs_exists_dir(Directory). % '$lgt_current_directory'(-atom) % % gets current working directory '$lgt_current_directory'(Directory) :- fs_cwd(Directory). % '$lgt_change_directory'(+atom) % % changes current working directory '$lgt_change_directory'(Directory) :- fs_cwd(_, Directory). % '$lgt_make_directory'(+atom) % % makes a new directory; succeeds if the directory already exists '$lgt_make_directory'(Directory) :- ( fs_exists_dir(Directory) -> true ; fs_mkdir(Directory) ). % '$lgt_load_prolog_code'(+atom, +atom, +list) % % compile and load a Prolog file, resulting from a % Logtalk source file, given a list of options '$lgt_load_prolog_code'(File, _, [encoding(Encoding)]) :- !, current_prolog_flag(encoding, Default), set_prolog_flag(encoding, Encoding), catch(consult(File), Error, (set_prolog_flag(encoding, Default), throw(Error))), set_prolog_flag(encoding, Default). '$lgt_load_prolog_code'(File, _, _) :- consult(File). % '$lgt_compare_file_mtimes'(?atom, +atom, +atom) % % compare file modification times % % should fail if file modification times cannot be retrived % or if one of the files does not exist '$lgt_compare_file_mtimes'(Result, File1, File2) :- fs_property(File1, time, [_, Time1]), fs_property(File2, time, [_, Time2]), compare(Result, Time1, Time2). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % sorting predicates % % note that sort/2 and keysort/2 are buitl-in predicates in most Prolog % compilers % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_keysort'(+list, -list) '$lgt_keysort'(List, Sorted) :- keysort(List, Sorted). % '$lgt_sort'( +List, -Sorted ) '$lgt_sort'(List, Sorted) :- sort(List, Sorted). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % time and date predicates % % if your Prolog compiler does not provide access to the operating system % time and date just write dummy definitions % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_current_date'(?Year, ?Month, ?Day) '$lgt_current_date'(2006, 6, 25). % '$lgt_current_time'(?Hours, ?Mins, ?Secs) '$lgt_current_time'(10, 39, 12). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % timing predicate % % if your Prolog compiler does not provide access to a timing predicate % just write dummy definition % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_cpu_time'(-Seconds) '$lgt_cpu_time'(Seconds) :- Seconds is cputime. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % comparison predicate % % the usual compare/3 definition % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % compare(?atom, @term, @term) -- built-in %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % callable predicate % % the usual callable/1 definition % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % callable(@term) -- built-in %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % read character predicate % % read a single character echoing it and writing a newline after % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% '$lgt_read_single_char'(Char) :- get_single_char(Code), put_code(Code), char_code(Char, Code), ( Code =:= 10 -> true ; nl ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % pretty print a term by naming its free variables % (avoid instantiating variables in term by using double negation if necessary) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% '$lgt_pretty_print_vars'(Stream, Term) :- \+ \+ (numbervars(Term, 1, _), write(Stream, Term)). '$lgt_pretty_print_vars_quoted'(Stream, Term) :- \+ \+ (numbervars(Term, 1, _), writeq(Stream, Term)). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % getting stream current line number % (needed for improved compiler error messages) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_stream_current_line_number'(@stream, -integer) '$lgt_stream_current_line_number'(_, _) :- fail. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % customized version of the read_term/3 predicate for returning the line % where the term starts (needed for improved compiler error messages) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_read_term'(@stream, -term, +list, -integer) '$lgt_read_term'(Stream, Term, Options, -1) :- read_term(Stream, Term, Options). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % handling of Prolog-proprietary directives on Logtalk source files % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_ignore_pl_directive'(@callable) '$lgt_ignore_pl_directive'(_) :- fail. % '$lgt_rewrite_and_copy_pl_directive'(@callable, -callable) '$lgt_rewrite_and_copy_pl_directive'(_, _) :- fail. % '$lgt_rewrite_and_recompile_pl_directive'(@callable, -callable) '$lgt_rewrite_and_recompile_pl_directive'(_, _) :- fail. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Shortcut to the Logtalk built-in predicate logtalk_load/1 % % defined in the config files in order to be able to comment it out in case % of conflict with some Prolog native feature; it implies conformance with % the ISO Prolog standard regarding the definition of the {}/1 syntax % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% {File, Files} :- !, logtalk_load(File), {Files}. {File} :- logtalk_load(File). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % converts between Prolog stream encoding names and XML encoding names % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % '$lgt_logtalk_prolog_encoding'(?atom, ?atom, +stream) '$lgt_logtalk_prolog_encoding'('US-ASCII', ascii, _). '$lgt_logtalk_prolog_encoding'('ISO-8859-1', iso_latin_1, _). '$lgt_logtalk_prolog_encoding'('UTF-8', utf8, _). '$lgt_logtalk_prolog_encoding'('UCS-2', Encoding, Stream) :- % UTF-16 subsumes UCS-2 '$lgt_logtalk_prolog_encoding'('UTF-16', Encoding, Stream). '$lgt_logtalk_prolog_encoding'('UCS-2BE', unicode_be, _). '$lgt_logtalk_prolog_encoding'('UCS-2LE', unicode_le, _). '$lgt_logtalk_prolog_encoding'('UTF-16', Encoding, Stream) :- % BOM optional but strongly recommended ( stream_property(Stream, encoding(utf16be)) -> Encoding = utf16be ; stream_property(Stream, encoding(utf16le)) -> Encoding = utf16le ). '$lgt_logtalk_prolog_encoding'('UTF-16BE', utf16be, _). % BOM forbidden '$lgt_logtalk_prolog_encoding'('UTF-16LE', utf16le, _). '$lgt_logtalk_prolog_encoding'('UTF-32', Encoding, Stream) :- % BOM mandatory ( stream_property(Stream, encoding(utf32be)) -> Encoding = utf32be ; stream_property(Stream, encoding(utf32le)) -> Encoding = utf32le ). '$lgt_logtalk_prolog_encoding'('UTF-32BE', utf32be, _). % BOM forbidden '$lgt_logtalk_prolog_encoding'('UTF-32LE', utf32le, _). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % end! % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%