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