| 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 2 | % |
|---|
| 3 | % Logtalk - Object oriented extension to Prolog |
|---|
| 4 | % Release 2.9.1 |
|---|
| 5 | % |
|---|
| 6 | % configuration file for CIAO Prolog 1.6p1 |
|---|
| 7 | % |
|---|
| 8 | % last updated: August 24, 2000 |
|---|
| 9 | % |
|---|
| 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | :- use_package(iso). |
|---|
| 14 | |
|---|
| 15 | :- use_package(runtime_ops). |
|---|
| 16 | |
|---|
| 17 | :- use_module(library(compiler)). |
|---|
| 18 | :- use_module(library(system)). |
|---|
| 19 | :- use_module(library(prolog_sys)). |
|---|
| 20 | :- use_module(library(sort)). |
|---|
| 21 | |
|---|
| 22 | :- include(engine(builtin_exports)). |
|---|
| 23 | |
|---|
| 24 | :- set_prolog_flag(multi_arity_warnings, off). |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 29 | % |
|---|
| 30 | % ISO Prolog Standard predicates that we must define because they are |
|---|
| 31 | % not built-in |
|---|
| 32 | % |
|---|
| 33 | % add a clause for lgt_iso_predicate/1 declaring each ISO predicate that |
|---|
| 34 | % we must define; there must be at least one clause for this predicate |
|---|
| 35 | % whose call should fail if we don't define any ISO predicates |
|---|
| 36 | % |
|---|
| 37 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | % lgt_iso_predicate(?callable). |
|---|
| 41 | |
|---|
| 42 | lgt_iso_predicate(_) :- |
|---|
| 43 | fail. |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 48 | % |
|---|
| 49 | % predicate properties |
|---|
| 50 | % |
|---|
| 51 | % this predicate must return at least static, dynamic and built_in |
|---|
| 52 | % properties for an existing predicate |
|---|
| 53 | % |
|---|
| 54 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | % lgt_predicate_property(+callable, ?predicate_property) |
|---|
| 58 | |
|---|
| 59 | lgt_predicate_property(Pred, built_in) :- |
|---|
| 60 | functor(Pred, Functor, Arity), |
|---|
| 61 | builtin_export(_, Functor, Arity, _). |
|---|
| 62 | |
|---|
| 63 | lgt_predicate_property(Pred, built_in) :- |
|---|
| 64 | lgt_ciao_iso_builtin(Pred). |
|---|
| 65 | |
|---|
| 66 | lgt_predicate_property(Pred, static) :- |
|---|
| 67 | predicate_property(Pred, compiled). |
|---|
| 68 | |
|---|
| 69 | lgt_predicate_property(Pred, static) :- |
|---|
| 70 | functor(Pred, Functor, Arity), |
|---|
| 71 | atom_concat('user:', Functor, Functor2), |
|---|
| 72 | functor(Pred2, Functor2, Arity), |
|---|
| 73 | predicate_property(Pred2, compiled). |
|---|
| 74 | |
|---|
| 75 | lgt_predicate_property(Pred, Prop) :- |
|---|
| 76 | predicate_property(Pred, Prop). |
|---|
| 77 | |
|---|
| 78 | lgt_predicate_property(Pred, Prop) :- |
|---|
| 79 | functor(Pred, Functor, Arity), |
|---|
| 80 | atom_concat('user:', Functor, Functor2), |
|---|
| 81 | functor(Pred2, Functor2, Arity), |
|---|
| 82 | predicate_property(Pred2, Prop). |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | lgt_ciao_iso_builtin(write(_)). |
|---|
| 86 | lgt_ciao_iso_builtin(write(_, _)). |
|---|
| 87 | lgt_ciao_iso_builtin(writeq(_)). |
|---|
| 88 | lgt_ciao_iso_builtin(writeq(_, _)). |
|---|
| 89 | lgt_ciao_iso_builtin(write_canonical(_)). |
|---|
| 90 | lgt_ciao_iso_builtin(write_canonical(_, _)). |
|---|
| 91 | lgt_ciao_iso_builtin(write_term(_, _)). |
|---|
| 92 | lgt_ciao_iso_builtin(write_term(_, _, _)). |
|---|
| 93 | |
|---|
| 94 | lgt_ciao_iso_builtin(read(_)). |
|---|
| 95 | lgt_ciao_iso_builtin(read(_, _)). |
|---|
| 96 | lgt_ciao_iso_builtin(read_term(_, _)). |
|---|
| 97 | lgt_ciao_iso_builtin(read_term(_, _, _)). |
|---|
| 98 | |
|---|
| 99 | lgt_ciao_iso_builtin(open(_, _, _, _)). |
|---|
| 100 | lgt_ciao_iso_builtin(close(_, _)). |
|---|
| 101 | lgt_ciao_iso_builtin(stream_property(_, _)). |
|---|
| 102 | |
|---|
| 103 | lgt_ciao_iso_builtin(op(_, _, _)). |
|---|
| 104 | lgt_ciao_iso_builtin(current_op(_, _, _)). |
|---|
| 105 | |
|---|
| 106 | lgt_ciao_iso_builtin(_ \= _). |
|---|
| 107 | lgt_ciao_iso_builtin(once(_)). |
|---|
| 108 | lgt_ciao_iso_builtin(compound(_)). |
|---|
| 109 | lgt_ciao_iso_builtin(sub_atom(_, _, _, _, _)). |
|---|
| 110 | lgt_ciao_iso_builtin(unify_with_occurs_check(_, _)). |
|---|
| 111 | |
|---|
| 112 | lgt_ciao_iso_builtin(char_code(_, _)). |
|---|
| 113 | lgt_ciao_iso_builtin(atom_chars(_, _)). |
|---|
| 114 | lgt_ciao_iso_builtin(number_chars(_, _)). |
|---|
| 115 | lgt_ciao_iso_builtin(get_byte(_)). |
|---|
| 116 | lgt_ciao_iso_builtin(get_byte(_, _)). |
|---|
| 117 | lgt_ciao_iso_builtin(peek_byte(_)). |
|---|
| 118 | lgt_ciao_iso_builtin(peek_byte(_, _)). |
|---|
| 119 | lgt_ciao_iso_builtin(put_byte(_)). |
|---|
| 120 | lgt_ciao_iso_builtin(put_byte(_, _)). |
|---|
| 121 | lgt_ciao_iso_builtin(get_char(_)). |
|---|
| 122 | lgt_ciao_iso_builtin(get_char(_, _)). |
|---|
| 123 | lgt_ciao_iso_builtin(peek_char(_)). |
|---|
| 124 | lgt_ciao_iso_builtin(peek_char(_, _)). |
|---|
| 125 | lgt_ciao_iso_builtin(put_char(_)). |
|---|
| 126 | lgt_ciao_iso_builtin(put_char(_, _)). |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 130 | % |
|---|
| 131 | % metapredicates |
|---|
| 132 | % |
|---|
| 133 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | % forall(+callable, +callble) |
|---|
| 137 | |
|---|
| 138 | forall(Generate, Test) :- |
|---|
| 139 | \+ call((Generate, \+ call(Test))). |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | % retractall(+callable) -- built-in |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | % lgt_call/2-8 |
|---|
| 146 | % |
|---|
| 147 | % if your compiler provides call/1-8 as built-in |
|---|
| 148 | % predicates rewrite these definitions using call(...). |
|---|
| 149 | |
|---|
| 150 | lgt_call(F, A) :- |
|---|
| 151 | call(F, A). |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | lgt_call(F, A1, A2) :- |
|---|
| 155 | call(F, A1, A2). |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | lgt_call(F, A1, A2, A3) :- |
|---|
| 159 | call(F, A1, A2, A3). |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | lgt_call(F, A1, A2, A3, A4) :- |
|---|
| 163 | call(F, A1, A2, A3, A4). |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | lgt_call(F, A1, A2, A3, A4, A5) :- |
|---|
| 167 | call(F, A1, A2, A3, A4, A5). |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | lgt_call(F, A1, A2, A3, A4, A5, A6) :- |
|---|
| 171 | call(F, A1, A2, A3, A4, A5, A6). |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | lgt_call(F, A1, A2, A3, A4, A5, A6, A7) :- |
|---|
| 175 | call(F, A1, A2, A3, A4, A5, A6, A7). |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | % lgt_once/2-8 |
|---|
| 179 | % |
|---|
| 180 | % if your compiler provides call/1-8 as built-in |
|---|
| 181 | % predicates rewrite these definitions using call(...), !. |
|---|
| 182 | |
|---|
| 183 | lgt_once(F, A) :- |
|---|
| 184 | call(F, A), |
|---|
| 185 | !. |
|---|
| 186 | |
|---|
| 187 | |
|---|
| 188 | lgt_once(F, A1, A2) :- |
|---|
| 189 | call(F, A1, A2), |
|---|
| 190 | !. |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | lgt_once(F, A1, A2, A3) :- |
|---|
| 194 | call(F, A1, A2, A3), |
|---|
| 195 | !. |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | lgt_once(F, A1, A2, A3, A4) :- |
|---|
| 199 | call(F, A1, A2, A3, A4), |
|---|
| 200 | !. |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | lgt_once(F, A1, A2, A3, A4, A5) :- |
|---|
| 204 | call(F, A1, A2, A3, A4, A5), |
|---|
| 205 | !. |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | lgt_once(F, A1, A2, A3, A4, A5, A6) :- |
|---|
| 209 | call(F, A1, A2, A3, A4, A5, A6), |
|---|
| 210 | !. |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | lgt_once(F, A1, A2, A3, A4, A5, A6, A7) :- |
|---|
| 214 | call(F, A1, A2, A3, A4, A5, A6, A7), |
|---|
| 215 | !. |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 220 | % |
|---|
| 221 | % file extension predicates |
|---|
| 222 | % |
|---|
| 223 | % these extensions are used by Logtalk load/compile predicates |
|---|
| 224 | % |
|---|
| 225 | % you may want to change the extension for Prolog files to match |
|---|
| 226 | % the one expected by your Prolog compiler |
|---|
| 227 | % |
|---|
| 228 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | % lgt_file_extension(?atom, ?atom) |
|---|
| 232 | |
|---|
| 233 | lgt_file_extension(logtalk, '.lgt'). |
|---|
| 234 | lgt_file_extension(prolog, '.pl'). |
|---|
| 235 | lgt_file_extension(xml, '.xml'). |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 240 | % |
|---|
| 241 | % default compiler options |
|---|
| 242 | % |
|---|
| 243 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 244 | |
|---|
| 245 | |
|---|
| 246 | % lgt_default_compiler_option(?atom, ?atom) |
|---|
| 247 | % |
|---|
| 248 | % default values for all compiler options |
|---|
| 249 | |
|---|
| 250 | lgt_default_compiler_option(iso_initialization_dir, true). |
|---|
| 251 | |
|---|
| 252 | lgt_default_compiler_option(xml, on). |
|---|
| 253 | lgt_default_compiler_option(xsl, 'lgtxml.xsl'). |
|---|
| 254 | |
|---|
| 255 | lgt_default_compiler_option(unknown, warning). |
|---|
| 256 | lgt_default_compiler_option(misspelt, warning). |
|---|
| 257 | lgt_default_compiler_option(singletons, warning). |
|---|
| 258 | lgt_default_compiler_option(lgtredef, warning). |
|---|
| 259 | lgt_default_compiler_option(plredef, silent). |
|---|
| 260 | |
|---|
| 261 | lgt_default_compiler_option(report, on). |
|---|
| 262 | |
|---|
| 263 | |
|---|
| 264 | |
|---|
| 265 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 266 | % |
|---|
| 267 | % list predicates |
|---|
| 268 | % |
|---|
| 269 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 270 | |
|---|
| 271 | |
|---|
| 272 | lgt_append([], List, List). |
|---|
| 273 | lgt_append([Head| Tail], List, [Head| Tail2]) :- |
|---|
| 274 | lgt_append(Tail, List, Tail2). |
|---|
| 275 | |
|---|
| 276 | |
|---|
| 277 | lgt_member(Head, [Head| _]). |
|---|
| 278 | lgt_member(Head, [_| Tail]) :- |
|---|
| 279 | lgt_member(Head, Tail). |
|---|
| 280 | |
|---|
| 281 | |
|---|
| 282 | lgt_member_var(V, [H| _]) :- |
|---|
| 283 | V == H. |
|---|
| 284 | lgt_member_var(V, [_| T]) :- |
|---|
| 285 | lgt_member_var(V, T). |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | lgt_proper_list([]). |
|---|
| 289 | lgt_proper_list([_| List]) :- |
|---|
| 290 | lgt_proper_list(List). |
|---|
| 291 | |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 295 | % |
|---|
| 296 | % file predicates |
|---|
| 297 | % |
|---|
| 298 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 299 | |
|---|
| 300 | |
|---|
| 301 | % lgt_file_exists(+atom) |
|---|
| 302 | % |
|---|
| 303 | % see if a file exist in the current directory |
|---|
| 304 | |
|---|
| 305 | lgt_file_exists(File) :- |
|---|
| 306 | file_exists(File). |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | % lgt_load_prolog_code(+atom) |
|---|
| 310 | % |
|---|
| 311 | % compile and load a Prolog file |
|---|
| 312 | |
|---|
| 313 | lgt_load_prolog_code(File) :- |
|---|
| 314 | set_prolog_flag(multi_arity_warnings, off), |
|---|
| 315 | ensure_loaded(File). |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | |
|---|
| 319 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 320 | % |
|---|
| 321 | % sorting predicate |
|---|
| 322 | % |
|---|
| 323 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | % lgt_keysort(+list, -list) |
|---|
| 327 | |
|---|
| 328 | lgt_keysort(List, Sorted) :- |
|---|
| 329 | keysort(List, Sorted). |
|---|
| 330 | |
|---|
| 331 | |
|---|
| 332 | % lgt_sort(+list, -list) |
|---|
| 333 | |
|---|
| 334 | lgt_sort(List, Sorted) :- |
|---|
| 335 | sort(List, Sorted). |
|---|
| 336 | |
|---|
| 337 | |
|---|
| 338 | |
|---|
| 339 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 340 | % |
|---|
| 341 | % time and date predicates |
|---|
| 342 | % |
|---|
| 343 | % if your Prolog compiler does not provide access to the operating system |
|---|
| 344 | % time and date just write dummy definitions |
|---|
| 345 | % |
|---|
| 346 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 347 | |
|---|
| 348 | |
|---|
| 349 | % lgt_current_date(?Year, ?Month, ?Day) |
|---|
| 350 | |
|---|
| 351 | lgt_current_date(Year, Month, Day) :- |
|---|
| 352 | datime(_, Year, Month, Day, _, _, _, _, _). |
|---|
| 353 | |
|---|
| 354 | |
|---|
| 355 | % lgt_current_time(?Hours, ?Mins, ?Secs) |
|---|
| 356 | |
|---|
| 357 | lgt_current_time(Hours, Mins, Secs) :- |
|---|
| 358 | datime(_, _, _, _, Hours, Mins, Secs, _, _). |
|---|
| 359 | |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 363 | % |
|---|
| 364 | % timing predicate |
|---|
| 365 | % |
|---|
| 366 | % if your Prolog compiler does not provide access to a timing predicate |
|---|
| 367 | % just write dummy definition |
|---|
| 368 | % |
|---|
| 369 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 370 | |
|---|
| 371 | |
|---|
| 372 | % lgt_cpu_time(-Seconds) |
|---|
| 373 | |
|---|
| 374 | lgt_cpu_time(Seconds) :- |
|---|
| 375 | statistics(runtime, [Miliseconds| _]), |
|---|
| 376 | Seconds is Miliseconds / 1000. |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | |
|---|
| 380 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 381 | % |
|---|
| 382 | % comparison predicate |
|---|
| 383 | % |
|---|
| 384 | % the usual compare/3 definition |
|---|
| 385 | % |
|---|
| 386 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | % compare(?atom, @term, @term) -- built-in |
|---|
| 390 | |
|---|
| 391 | |
|---|
| 392 | |
|---|
| 393 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|
| 394 | % |
|---|
| 395 | % end! |
|---|
| 396 | % |
|---|
| 397 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|---|