kibi-swipl-linux-x64-gnu 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/bin/swipl +0 -0
- package/bin/swipl-win +0 -0
- package/build-manifest.json +70 -0
- package/lib/cmake/swipl/SWIPLConfig.cmake +21 -0
- package/lib/cmake/swipl/SWIPLConfigVersion.cmake +65 -0
- package/lib/cmake/swipl/SWIPLTargets-release.cmake +28 -0
- package/lib/cmake/swipl/SWIPLTargets.cmake +109 -0
- package/lib/swipl/ABI +1 -0
- package/lib/swipl/LICENSE +41 -0
- package/lib/swipl/README.md +116 -0
- package/lib/swipl/app/README.md +25 -0
- package/lib/swipl/app/app.pl +87 -0
- package/lib/swipl/app/pack.pl +350 -0
- package/lib/swipl/app/qlf.pl +521 -0
- package/lib/swipl/app/splfr.pl +177 -0
- package/lib/swipl/app/sys.pl +310 -0
- package/lib/swipl/bin/swipl.home +1 -0
- package/lib/swipl/boot/apply.pl +73 -0
- package/lib/swipl/boot/attvar.pl +344 -0
- package/lib/swipl/boot/autoload.pl +1226 -0
- package/lib/swipl/boot/bags.pl +283 -0
- package/lib/swipl/boot/dcg.pl +388 -0
- package/lib/swipl/boot/dicts.pl +193 -0
- package/lib/swipl/boot/dwim.pl +485 -0
- package/lib/swipl/boot/engines.pl +152 -0
- package/lib/swipl/boot/expand.pl +1628 -0
- package/lib/swipl/boot/gc.pl +65 -0
- package/lib/swipl/boot/history.pl +304 -0
- package/lib/swipl/boot/init.pl +4682 -0
- package/lib/swipl/boot/iri.pl +64 -0
- package/lib/swipl/boot/license.pl +390 -0
- package/lib/swipl/boot/load.pl +81 -0
- package/lib/swipl/boot/messages.pl +2521 -0
- package/lib/swipl/boot/packs.pl +306 -0
- package/lib/swipl/boot/predopts.pl +154 -0
- package/lib/swipl/boot/qlf.pl +141 -0
- package/lib/swipl/boot/rc.pl +263 -0
- package/lib/swipl/boot/syspred.pl +1634 -0
- package/lib/swipl/boot/tabling.pl +2321 -0
- package/lib/swipl/boot/threads.pl +42 -0
- package/lib/swipl/boot/toplevel.pl +2248 -0
- package/lib/swipl/boot/topvars.pl +261 -0
- package/lib/swipl/boot.prc +0 -0
- package/lib/swipl/cmake/swipl.cmake +131 -0
- package/lib/swipl/customize/README.md +23 -0
- package/lib/swipl/customize/edit +101 -0
- package/lib/swipl/customize/init.pl +164 -0
- package/lib/swipl/demo/README.md +33 -0
- package/lib/swipl/demo/likes.pl +44 -0
- package/lib/swipl/doc/packages/examples/chr/bool.chr +281 -0
- package/lib/swipl/doc/packages/examples/chr/chrdif.chr +87 -0
- package/lib/swipl/doc/packages/examples/chr/chrfreeze.chr +6 -0
- package/lib/swipl/doc/packages/examples/chr/family.chr +116 -0
- package/lib/swipl/doc/packages/examples/chr/fib.chr +24 -0
- package/lib/swipl/doc/packages/examples/chr/fibonacci.chr +31 -0
- package/lib/swipl/doc/packages/examples/chr/gcd.chr +28 -0
- package/lib/swipl/doc/packages/examples/chr/leq.chr +34 -0
- package/lib/swipl/doc/packages/examples/chr/listdom.chr +138 -0
- package/lib/swipl/doc/packages/examples/chr/primes.chr +29 -0
- package/lib/swipl/doc/packages/examples/http/README.md +98 -0
- package/lib/swipl/doc/packages/examples/http/calc.pl +92 -0
- package/lib/swipl/doc/packages/examples/http/demo_body.pl +232 -0
- package/lib/swipl/doc/packages/examples/http/demo_client.pl +165 -0
- package/lib/swipl/doc/packages/examples/http/demo_daemon.pl +38 -0
- package/lib/swipl/doc/packages/examples/http/demo_files.pl +50 -0
- package/lib/swipl/doc/packages/examples/http/demo_hello.pl +15 -0
- package/lib/swipl/doc/packages/examples/http/demo_login.pl +280 -0
- package/lib/swipl/doc/packages/examples/http/demo_openid.pl +177 -0
- package/lib/swipl/doc/packages/examples/http/demo_pwp.pl +20 -0
- package/lib/swipl/doc/packages/examples/http/demo_rest.pl +56 -0
- package/lib/swipl/doc/packages/examples/http/demo_threads.pl +52 -0
- package/lib/swipl/doc/packages/examples/http/linux-init-script +126 -0
- package/lib/swipl/doc/packages/examples/http/pwp/context.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/index.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp1.pwp +12 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp2.pwp +10 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp3.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp4.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp5.pwp +11 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp6.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp7.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp8.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwpdb.pl +12 -0
- package/lib/swipl/doc/packages/examples/http/systemd-script.service +18 -0
- package/lib/swipl/doc/packages/examples/http/upstart-script.conf +20 -0
- package/lib/swipl/doc/packages/examples/plunit/read.pl +17 -0
- package/lib/swipl/doc/packages/examples/plunit/simple.pl +33 -0
- package/lib/swipl/doc/packages/examples/ssl/client.pl +83 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/README +52 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.p12 +0 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/cacert.pem +82 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/careq.pem +18 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/crlnumber +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt +3 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt.attr +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7C.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7D.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/private/cakey.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/serial +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/https.pl +267 -0
- package/lib/swipl/doc/packages/examples/ssl/server.pl +106 -0
- package/lib/swipl/include/SWI-Prolog.h +1544 -0
- package/lib/swipl/include/SWI-Stream.h +537 -0
- package/lib/swipl/include/Yap/YapInterface.h +283 -0
- package/lib/swipl/include/sicstus/sicstus.h +452 -0
- package/lib/swipl/lib/x86_64-linux/cgi.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypt.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypto4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/double_metaphone.so +0 -0
- package/lib/swipl/lib/x86_64-linux/files.so +0 -0
- package/lib/swipl/lib/x86_64-linux/hashstream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/http_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/isub.so +0 -0
- package/lib/swipl/lib/x86_64-linux/json.so +0 -0
- package/lib/swipl/lib/x86_64-linux/libswipl.so.10 +0 -0
- package/lib/swipl/lib/x86_64-linux/mallocinfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/md54pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/memfile.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ntriples.so +0 -0
- package/lib/swipl/lib/x86_64-linux/pcre4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/porter_stem.so +0 -0
- package/lib/swipl/lib/x86_64-linux/process.so +0 -0
- package/lib/swipl/lib/x86_64-linux/prolog_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rdf_db.so +0 -0
- package/lib/swipl/lib/x86_64-linux/readutil.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rlimit.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sched.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sgml2pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sha4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/snowball.so +0 -0
- package/lib/swipl/lib/x86_64-linux/socket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ssl4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/streaminfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/syslog.so +0 -0
- package/lib/swipl/lib/x86_64-linux/time.so +0 -0
- package/lib/swipl/lib/x86_64-linux/turtle.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uid.so +0 -0
- package/lib/swipl/lib/x86_64-linux/unix.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uri.so +0 -0
- package/lib/swipl/lib/x86_64-linux/websocket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/zlib4pl.so +0 -0
- package/lib/swipl/library/INDEX.pl +1020 -0
- package/lib/swipl/library/aggregate.pl +755 -0
- package/lib/swipl/library/ansi_term.pl +653 -0
- package/lib/swipl/library/apply.pl +426 -0
- package/lib/swipl/library/apply_macros.pl +497 -0
- package/lib/swipl/library/arithmetic.pl +320 -0
- package/lib/swipl/library/assoc.pl +522 -0
- package/lib/swipl/library/atom.pl +169 -0
- package/lib/swipl/library/backcomp.pl +688 -0
- package/lib/swipl/library/base32.pl +291 -0
- package/lib/swipl/library/base64.pl +441 -0
- package/lib/swipl/library/broadcast.pl +161 -0
- package/lib/swipl/library/build/cmake.pl +137 -0
- package/lib/swipl/library/build/conan.pl +232 -0
- package/lib/swipl/library/build/make.pl +168 -0
- package/lib/swipl/library/build/tools.pl +825 -0
- package/lib/swipl/library/charsio.pl +195 -0
- package/lib/swipl/library/check.pl +1097 -0
- package/lib/swipl/library/check_installation.pl +912 -0
- package/lib/swipl/library/clp/INDEX.pl +157 -0
- package/lib/swipl/library/clp/bounds.pl +2036 -0
- package/lib/swipl/library/clp/clp_distinct.pl +263 -0
- package/lib/swipl/library/clp/clp_events.pl +92 -0
- package/lib/swipl/library/clp/clpb.pl +1896 -0
- package/lib/swipl/library/clp/clpfd.pl +7906 -0
- package/lib/swipl/library/clp/simplex.pl +1580 -0
- package/lib/swipl/library/codesio.pl +182 -0
- package/lib/swipl/library/coinduction.pl +183 -0
- package/lib/swipl/library/console_input.pl +289 -0
- package/lib/swipl/library/csv.pl +611 -0
- package/lib/swipl/library/ctypes.pl +161 -0
- package/lib/swipl/library/date.pl +370 -0
- package/lib/swipl/library/dcg/INDEX.pl +35 -0
- package/lib/swipl/library/dcg/basics.pl +514 -0
- package/lib/swipl/library/dcg/high_order.pl +227 -0
- package/lib/swipl/library/debug.pl +499 -0
- package/lib/swipl/library/dialect/bim.pl +186 -0
- package/lib/swipl/library/dialect/commons.pl +77 -0
- package/lib/swipl/library/dialect/eclipse/test_util_iso.pl +355 -0
- package/lib/swipl/library/dialect/hprolog/format.pl +44 -0
- package/lib/swipl/library/dialect/hprolog.pl +314 -0
- package/lib/swipl/library/dialect/ifprolog.pl +1317 -0
- package/lib/swipl/library/dialect/iso/iso_predicates.pl +277 -0
- package/lib/swipl/library/dialect/sicstus/README.TXT +1 -0
- package/lib/swipl/library/dialect/sicstus/arrays.pl +121 -0
- package/lib/swipl/library/dialect/sicstus/block.pl +278 -0
- package/lib/swipl/library/dialect/sicstus/lists.pl +167 -0
- package/lib/swipl/library/dialect/sicstus/ordsets.pl +52 -0
- package/lib/swipl/library/dialect/sicstus/sockets.pl +174 -0
- package/lib/swipl/library/dialect/sicstus/system.pl +262 -0
- package/lib/swipl/library/dialect/sicstus/terms.pl +57 -0
- package/lib/swipl/library/dialect/sicstus/timeout.pl +92 -0
- package/lib/swipl/library/dialect/sicstus.pl +582 -0
- package/lib/swipl/library/dialect/sicstus4/aggregate.pl +60 -0
- package/lib/swipl/library/dialect/sicstus4/between.pl +62 -0
- package/lib/swipl/library/dialect/sicstus4/clpfd.pl +75 -0
- package/lib/swipl/library/dialect/sicstus4/file_systems.pl +413 -0
- package/lib/swipl/library/dialect/sicstus4/lists.pl +274 -0
- package/lib/swipl/library/dialect/sicstus4/ordsets.pl +54 -0
- package/lib/swipl/library/dialect/sicstus4/samsort.pl +86 -0
- package/lib/swipl/library/dialect/sicstus4/sets.pl +124 -0
- package/lib/swipl/library/dialect/sicstus4/sockets.pl +164 -0
- package/lib/swipl/library/dialect/sicstus4/system.pl +80 -0
- package/lib/swipl/library/dialect/sicstus4/terms.pl +89 -0
- package/lib/swipl/library/dialect/sicstus4/timeout.pl +43 -0
- package/lib/swipl/library/dialect/sicstus4/types.pl +103 -0
- package/lib/swipl/library/dialect/sicstus4.pl +200 -0
- package/lib/swipl/library/dialect/swi/syspred_options.pl +250 -0
- package/lib/swipl/library/dialect/xsb/README.md +20 -0
- package/lib/swipl/library/dialect/xsb/basics.pl +318 -0
- package/lib/swipl/library/dialect/xsb/consult.pl +87 -0
- package/lib/swipl/library/dialect/xsb/curr_sym.pl +57 -0
- package/lib/swipl/library/dialect/xsb/error_handler.pl +111 -0
- package/lib/swipl/library/dialect/xsb/gensym.pl +53 -0
- package/lib/swipl/library/dialect/xsb/gpp.pl +138 -0
- package/lib/swipl/library/dialect/xsb/intern.pl +48 -0
- package/lib/swipl/library/dialect/xsb/lists.pl +47 -0
- package/lib/swipl/library/dialect/xsb/machine.pl +295 -0
- package/lib/swipl/library/dialect/xsb/ordsets.pl +53 -0
- package/lib/swipl/library/dialect/xsb/setof.pl +54 -0
- package/lib/swipl/library/dialect/xsb/source.pl +308 -0
- package/lib/swipl/library/dialect/xsb/standard.pl +169 -0
- package/lib/swipl/library/dialect/xsb/storage.pl +70 -0
- package/lib/swipl/library/dialect/xsb/string.pl +76 -0
- package/lib/swipl/library/dialect/xsb/thread.pl +62 -0
- package/lib/swipl/library/dialect/xsb/timed_call.pl +158 -0
- package/lib/swipl/library/dialect/xsb.pl +688 -0
- package/lib/swipl/library/dialect/yap/README.TXT +8 -0
- package/lib/swipl/library/dialect/yap.pl +283 -0
- package/lib/swipl/library/dialect.pl +123 -0
- package/lib/swipl/library/dicts.pl +399 -0
- package/lib/swipl/library/dif.pl +426 -0
- package/lib/swipl/library/edinburgh.pl +138 -0
- package/lib/swipl/library/edit.pl +783 -0
- package/lib/swipl/library/error.pl +495 -0
- package/lib/swipl/library/exceptions.pl +231 -0
- package/lib/swipl/library/explain.pl +543 -0
- package/lib/swipl/library/ext/RDF/INDEX.pl +25 -0
- package/lib/swipl/library/ext/RDF/rdf.pl +450 -0
- package/lib/swipl/library/ext/RDF/rdf_parser.pl +649 -0
- package/lib/swipl/library/ext/RDF/rdf_triple.pl +448 -0
- package/lib/swipl/library/ext/RDF/rdf_write.pl +701 -0
- package/lib/swipl/library/ext/RDF/rewrite_term.pl +177 -0
- package/lib/swipl/library/ext/chr/chr/a_star.pl +80 -0
- package/lib/swipl/library/ext/chr/chr/binomialheap.pl +142 -0
- package/lib/swipl/library/ext/chr/chr/builtins.pl +629 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_errors.pl +179 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_options.pl +382 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_utility.pl +338 -0
- package/lib/swipl/library/ext/chr/chr/chr_debug.pl +59 -0
- package/lib/swipl/library/ext/chr/chr/chr_hashtable_store.pl +425 -0
- package/lib/swipl/library/ext/chr/chr/chr_integertable_store.pl +139 -0
- package/lib/swipl/library/ext/chr/chr/chr_messages.pl +176 -0
- package/lib/swipl/library/ext/chr/chr/chr_op.pl +53 -0
- package/lib/swipl/library/ext/chr/chr/chr_runtime.pl +1016 -0
- package/lib/swipl/library/ext/chr/chr/chr_translate.pl +25424 -0
- package/lib/swipl/library/ext/chr/chr/clean_code.pl +252 -0
- package/lib/swipl/library/ext/chr/chr/find.pl +78 -0
- package/lib/swipl/library/ext/chr/chr/guard_entailment.pl +19432 -0
- package/lib/swipl/library/ext/chr/chr/listmap.pl +108 -0
- package/lib/swipl/library/ext/chr/chr/pairlist.pl +78 -0
- package/lib/swipl/library/ext/chr/chr.pl +686 -0
- package/lib/swipl/library/ext/clib/INDEX.pl +158 -0
- package/lib/swipl/library/ext/clib/cgi.pl +86 -0
- package/lib/swipl/library/ext/clib/crypt.pl +44 -0
- package/lib/swipl/library/ext/clib/filesex.pl +644 -0
- package/lib/swipl/library/ext/clib/hash_stream.pl +119 -0
- package/lib/swipl/library/ext/clib/mallocinfo.pl +138 -0
- package/lib/swipl/library/ext/clib/md5.pl +68 -0
- package/lib/swipl/library/ext/clib/memfile.pl +61 -0
- package/lib/swipl/library/ext/clib/process.pl +573 -0
- package/lib/swipl/library/ext/clib/prolog_server.pl +157 -0
- package/lib/swipl/library/ext/clib/prolog_stream.pl +80 -0
- package/lib/swipl/library/ext/clib/rlimit.pl +54 -0
- package/lib/swipl/library/ext/clib/sched.pl +85 -0
- package/lib/swipl/library/ext/clib/sha.pl +162 -0
- package/lib/swipl/library/ext/clib/socket.pl +1102 -0
- package/lib/swipl/library/ext/clib/streaminfo.pl +103 -0
- package/lib/swipl/library/ext/clib/streampool.pl +136 -0
- package/lib/swipl/library/ext/clib/syslog.pl +180 -0
- package/lib/swipl/library/ext/clib/time.pl +194 -0
- package/lib/swipl/library/ext/clib/udp_broadcast.pl +975 -0
- package/lib/swipl/library/ext/clib/uid.pl +220 -0
- package/lib/swipl/library/ext/clib/unix.pl +317 -0
- package/lib/swipl/library/ext/clib/uri.pl +530 -0
- package/lib/swipl/library/ext/clib/uuid.pl +207 -0
- package/lib/swipl/library/ext/http/http/INDEX.pl +266 -0
- package/lib/swipl/library/ext/http/http/README.md +34 -0
- package/lib/swipl/library/ext/http/http/ax.pl +189 -0
- package/lib/swipl/library/ext/http/http/dcg_basics.pl +49 -0
- package/lib/swipl/library/ext/http/http/graphql.pl +1367 -0
- package/lib/swipl/library/ext/http/http/html_decl.pl +416 -0
- package/lib/swipl/library/ext/http/http/html_head.pl +654 -0
- package/lib/swipl/library/ext/http/http/html_quasiquotations.pl +120 -0
- package/lib/swipl/library/ext/http/http/html_write.pl +1425 -0
- package/lib/swipl/library/ext/http/http/htmx.pl +139 -0
- package/lib/swipl/library/ext/http/http/http_authenticate.pl +364 -0
- package/lib/swipl/library/ext/http/http/http_client.pl +412 -0
- package/lib/swipl/library/ext/http/http/http_cookie.pl +245 -0
- package/lib/swipl/library/ext/http/http/http_cors.pl +176 -0
- package/lib/swipl/library/ext/http/http/http_digest.pl +820 -0
- package/lib/swipl/library/ext/http/http/http_dirindex.pl +296 -0
- package/lib/swipl/library/ext/http/http/http_dispatch.pl +1552 -0
- package/lib/swipl/library/ext/http/http/http_dyn_workers.pl +214 -0
- package/lib/swipl/library/ext/http/http/http_error.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_exception.pl +225 -0
- package/lib/swipl/library/ext/http/http/http_files.pl +163 -0
- package/lib/swipl/library/ext/http/http/http_header.pl +2820 -0
- package/lib/swipl/library/ext/http/http/http_hook.pl +106 -0
- package/lib/swipl/library/ext/http/http/http_host.pl +204 -0
- package/lib/swipl/library/ext/http/http/http_load.pl +113 -0
- package/lib/swipl/library/ext/http/http/http_log.pl +738 -0
- package/lib/swipl/library/ext/http/http/http_multipart_plugin.pl +232 -0
- package/lib/swipl/library/ext/http/http/http_open.pl +1821 -0
- package/lib/swipl/library/ext/http/http/http_openid.pl +1561 -0
- package/lib/swipl/library/ext/http/http/http_parameters.pl +504 -0
- package/lib/swipl/library/ext/http/http/http_path.pl +380 -0
- package/lib/swipl/library/ext/http/http/http_proxy.pl +80 -0
- package/lib/swipl/library/ext/http/http/http_pwp.pl +351 -0
- package/lib/swipl/library/ext/http/http/http_redis_plugin.pl +332 -0
- package/lib/swipl/library/ext/http/http/http_server.pl +105 -0
- package/lib/swipl/library/ext/http/http/http_server_files.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_server_health.pl +186 -0
- package/lib/swipl/library/ext/http/http/http_session.pl +1040 -0
- package/lib/swipl/library/ext/http/http/http_sgml_plugin.pl +137 -0
- package/lib/swipl/library/ext/http/http/http_stream.pl +376 -0
- package/lib/swipl/library/ext/http/http/http_unix_daemon.pl +989 -0
- package/lib/swipl/library/ext/http/http/http_wrapper.pl +559 -0
- package/lib/swipl/library/ext/http/http/hub.pl +600 -0
- package/lib/swipl/library/ext/http/http/js_write.pl +461 -0
- package/lib/swipl/library/ext/http/http/mimepack.pl +224 -0
- package/lib/swipl/library/ext/http/http/mimetype.pl +276 -0
- package/lib/swipl/library/ext/http/http/term_html.pl +797 -0
- package/lib/swipl/library/ext/http/http/thread_httpd.pl +1181 -0
- package/lib/swipl/library/ext/http/http/web/css/dirindex.css +24 -0
- package/lib/swipl/library/ext/http/http/web/css/openid.css +57 -0
- package/lib/swipl/library/ext/http/http/web/icons/back.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/c.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/compressed.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/folder.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/generic.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/layout.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-square.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-tiny.png +0 -0
- package/lib/swipl/library/ext/http/http/websocket.pl +729 -0
- package/lib/swipl/library/ext/http/http/yadis.pl +205 -0
- package/lib/swipl/library/ext/json/INDEX.pl +36 -0
- package/lib/swipl/library/ext/json/http/INDEX.pl +16 -0
- package/lib/swipl/library/ext/json/http/http_json.pl +490 -0
- package/lib/swipl/library/ext/json/http/js_grammar.pl +53 -0
- package/lib/swipl/library/ext/json/http/json.pl +48 -0
- package/lib/swipl/library/ext/json/http/json_convert.pl +48 -0
- package/lib/swipl/library/ext/json/json.pl +1215 -0
- package/lib/swipl/library/ext/json/json_convert.pl +681 -0
- package/lib/swipl/library/ext/json/json_grammar.pl +349 -0
- package/lib/swipl/library/ext/json/json_rpc_client.pl +423 -0
- package/lib/swipl/library/ext/json/json_rpc_common.pl +104 -0
- package/lib/swipl/library/ext/json/json_rpc_server.pl +489 -0
- package/lib/swipl/library/ext/json/json_schema.pl +2111 -0
- package/lib/swipl/library/ext/nlp/INDEX.pl +15 -0
- package/lib/swipl/library/ext/nlp/double_metaphone.pl +86 -0
- package/lib/swipl/library/ext/nlp/isub.pl +162 -0
- package/lib/swipl/library/ext/nlp/porter_stem.pl +50 -0
- package/lib/swipl/library/ext/nlp/snowball.pl +97 -0
- package/lib/swipl/library/ext/pcre/INDEX.pl +17 -0
- package/lib/swipl/library/ext/pcre/pcre.pl +974 -0
- package/lib/swipl/library/ext/plunit/INDEX.pl +20 -0
- package/lib/swipl/library/ext/plunit/plunit.pl +2631 -0
- package/lib/swipl/library/ext/plunit/test_wizard.pl +249 -0
- package/lib/swipl/library/ext/semweb/semweb/INDEX.pl +288 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11.pl +2106 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11_containers.pl +299 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_cache.pl +278 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_compare.pl +132 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_db.pl +3468 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_edit.pl +1145 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_http_plugin.pl +274 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_library.pl +1021 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_litindex.pl +1035 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_ntriples.pl +422 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_persistency.pl +1576 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_portray.pl +182 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_prefixes.pl +681 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_sandbox.pl +153 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle.pl +54 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle_write.pl +1587 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_zlib_plugin.pl +52 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfa.pl +1510 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfs.pl +475 -0
- package/lib/swipl/library/ext/semweb/semweb/sparql_client.pl +643 -0
- package/lib/swipl/library/ext/semweb/semweb/turtle.pl +455 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dcl +88 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dtd +1092 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.soc +6 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML5.dtd +906 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLlat1.ent +195 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLspec.ent +77 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLsym.ent +241 -0
- package/lib/swipl/library/ext/sgml/INDEX.pl +64 -0
- package/lib/swipl/library/ext/sgml/c14n2.pl +203 -0
- package/lib/swipl/library/ext/sgml/iso_639.pl +631 -0
- package/lib/swipl/library/ext/sgml/pwp.pl +705 -0
- package/lib/swipl/library/ext/sgml/sgml.pl +815 -0
- package/lib/swipl/library/ext/sgml/sgml_write.pl +1003 -0
- package/lib/swipl/library/ext/sgml/xpath.pl +620 -0
- package/lib/swipl/library/ext/sgml/xsdp_types.pl +232 -0
- package/lib/swipl/library/ext/ssl/INDEX.pl +60 -0
- package/lib/swipl/library/ext/ssl/crypto.pl +1015 -0
- package/lib/swipl/library/ext/ssl/http/INDEX.pl +5 -0
- package/lib/swipl/library/ext/ssl/http/http_ssl_plugin.pl +296 -0
- package/lib/swipl/library/ext/ssl/saml.pl +609 -0
- package/lib/swipl/library/ext/ssl/ssl.pl +647 -0
- package/lib/swipl/library/ext/ssl/xmldsig.pl +391 -0
- package/lib/swipl/library/ext/ssl/xmlenc.pl +354 -0
- package/lib/swipl/library/ext/zlib/INDEX.pl +8 -0
- package/lib/swipl/library/ext/zlib/zlib.pl +112 -0
- package/lib/swipl/library/fastrw.pl +105 -0
- package/lib/swipl/library/files.pl +80 -0
- package/lib/swipl/library/gensym.pl +111 -0
- package/lib/swipl/library/git.pl +1027 -0
- package/lib/swipl/library/hashtable.pl +365 -0
- package/lib/swipl/library/heaps.pl +252 -0
- package/lib/swipl/library/hotfix.pl +239 -0
- package/lib/swipl/library/http/jquery.pl +103 -0
- package/lib/swipl/library/http/web/js/jquery-3.6.0.min.js +2 -0
- package/lib/swipl/library/increval.pl +217 -0
- package/lib/swipl/library/intercept.pl +263 -0
- package/lib/swipl/library/iostream.pl +237 -0
- package/lib/swipl/library/iri_scheme/file.pl +70 -0
- package/lib/swipl/library/lazy_lists.pl +481 -0
- package/lib/swipl/library/listing.pl +1362 -0
- package/lib/swipl/library/lists.pl +860 -0
- package/lib/swipl/library/lynx/INDEX.pl +14 -0
- package/lib/swipl/library/lynx/format.pl +380 -0
- package/lib/swipl/library/lynx/html_style.pl +129 -0
- package/lib/swipl/library/lynx/html_text.pl +865 -0
- package/lib/swipl/library/lynx/pldoc_style.pl +87 -0
- package/lib/swipl/library/macros.pl +451 -0
- package/lib/swipl/library/main.pl +1200 -0
- package/lib/swipl/library/make.pl +197 -0
- package/lib/swipl/library/modules.pl +129 -0
- package/lib/swipl/library/nb_rbtrees.pl +267 -0
- package/lib/swipl/library/nb_set.pl +203 -0
- package/lib/swipl/library/obfuscate.pl +115 -0
- package/lib/swipl/library/occurs.pl +241 -0
- package/lib/swipl/library/operators.pl +182 -0
- package/lib/swipl/library/option.pl +388 -0
- package/lib/swipl/library/optparse.pl +966 -0
- package/lib/swipl/library/ordsets.pl +518 -0
- package/lib/swipl/library/oset.pl +160 -0
- package/lib/swipl/library/pairs.pl +187 -0
- package/lib/swipl/library/persistency.pl +713 -0
- package/lib/swipl/library/pio.pl +47 -0
- package/lib/swipl/library/portray_text.pl +277 -0
- package/lib/swipl/library/pprint.pl +940 -0
- package/lib/swipl/library/predicate_options.pl +975 -0
- package/lib/swipl/library/prolog_autoload.pl +233 -0
- package/lib/swipl/library/prolog_breakpoints.pl +396 -0
- package/lib/swipl/library/prolog_clause.pl +1104 -0
- package/lib/swipl/library/prolog_code.pl +416 -0
- package/lib/swipl/library/prolog_codewalk.pl +1248 -0
- package/lib/swipl/library/prolog_colour.pl +3301 -0
- package/lib/swipl/library/prolog_colour.qlf +0 -0
- package/lib/swipl/library/prolog_config.pl +154 -0
- package/lib/swipl/library/prolog_coverage.pl +1333 -0
- package/lib/swipl/library/prolog_debug.pl +404 -0
- package/lib/swipl/library/prolog_deps.pl +675 -0
- package/lib/swipl/library/prolog_evaluable.pl +234 -0
- package/lib/swipl/library/prolog_format.pl +219 -0
- package/lib/swipl/library/prolog_history.pl +161 -0
- package/lib/swipl/library/prolog_jiti.pl +333 -0
- package/lib/swipl/library/prolog_locale.pl +61 -0
- package/lib/swipl/library/prolog_metainference.pl +307 -0
- package/lib/swipl/library/prolog_pack.pl +3906 -0
- package/lib/swipl/library/prolog_profile.pl +346 -0
- package/lib/swipl/library/prolog_qlfmake.pl +533 -0
- package/lib/swipl/library/prolog_source.pl +1188 -0
- package/lib/swipl/library/prolog_stack.pl +794 -0
- package/lib/swipl/library/prolog_trace.pl +365 -0
- package/lib/swipl/library/prolog_versions.pl +347 -0
- package/lib/swipl/library/prolog_wrap.pl +164 -0
- package/lib/swipl/library/prolog_xref.pl +3090 -0
- package/lib/swipl/library/prolog_xref.qlf +0 -0
- package/lib/swipl/library/pure_input.pl +266 -0
- package/lib/swipl/library/qpforeign.pl +695 -0
- package/lib/swipl/library/qsave.pl +1516 -0
- package/lib/swipl/library/quasi_quotations.pl +300 -0
- package/lib/swipl/library/quintus.pl +437 -0
- package/lib/swipl/library/random.pl +459 -0
- package/lib/swipl/library/rbtrees.pl +1153 -0
- package/lib/swipl/library/readln.pl +256 -0
- package/lib/swipl/library/readutil.pl +304 -0
- package/lib/swipl/library/record.pl +544 -0
- package/lib/swipl/library/rwlocks.pl +172 -0
- package/lib/swipl/library/sandbox.pl +1384 -0
- package/lib/swipl/library/semweb/dc.rdfs +198 -0
- package/lib/swipl/library/semweb/eor.rdfs +95 -0
- package/lib/swipl/library/semweb/owl.owl +287 -0
- package/lib/swipl/library/semweb/rdf_library.ttl +90 -0
- package/lib/swipl/library/semweb/rdfs.rdfs +251 -0
- package/lib/swipl/library/settings.pl +755 -0
- package/lib/swipl/library/shell.pl +462 -0
- package/lib/swipl/library/shlib.pl +670 -0
- package/lib/swipl/library/solution_sequences.pl +439 -0
- package/lib/swipl/library/sort.pl +119 -0
- package/lib/swipl/library/statistics.pl +541 -0
- package/lib/swipl/library/streams.pl +118 -0
- package/lib/swipl/library/strings.pl +469 -0
- package/lib/swipl/library/system.pl +95 -0
- package/lib/swipl/library/tables.pl +381 -0
- package/lib/swipl/library/tableutil.pl +771 -0
- package/lib/swipl/library/tabling.pl +42 -0
- package/lib/swipl/library/terms.pl +457 -0
- package/lib/swipl/library/theme/auto.pl +61 -0
- package/lib/swipl/library/theme/dark.pl +455 -0
- package/lib/swipl/library/theme/light.pl +45 -0
- package/lib/swipl/library/thread.pl +810 -0
- package/lib/swipl/library/thread_pool.pl +508 -0
- package/lib/swipl/library/threadutil.pl +574 -0
- package/lib/swipl/library/tty.pl +316 -0
- package/lib/swipl/library/ugraphs.pl +644 -0
- package/lib/swipl/library/unicode/INDEX.pl +6 -0
- package/lib/swipl/library/unicode/blocks.pl +414 -0
- package/lib/swipl/library/url.pl +1129 -0
- package/lib/swipl/library/utf8.pl +145 -0
- package/lib/swipl/library/varnumbers.pl +221 -0
- package/lib/swipl/library/vm.pl +251 -0
- package/lib/swipl/library/wfs.pl +205 -0
- package/lib/swipl/library/when.pl +263 -0
- package/lib/swipl/library/writef.pl +278 -0
- package/lib/swipl/library/www_browser.pl +251 -0
- package/lib/swipl/library/yall.pl +574 -0
- package/lib/swipl/library/zip.pl +211 -0
- package/lib/swipl/swipl.home +1 -0
- package/lib/vendor/libcrypto.so.3 +0 -0
- package/lib/vendor/libpcre2-8.so.0 +0 -0
- package/lib/vendor/libssl.so.3 +0 -0
- package/lib/vendor/libz.so.1 +0 -0
- package/licenses/OpenSSL-LICENSE.txt +177 -0
- package/licenses/PCRE2-COPYING +5 -0
- package/licenses/README.md +12 -0
- package/licenses/SWI-Prolog-LICENSE +41 -0
- package/licenses/zlib-LICENSE +22 -0
- package/package.json +27 -0
|
@@ -0,0 +1,2521 @@
|
|
|
1
|
+
/* Part of SWI-Prolog
|
|
2
|
+
|
|
3
|
+
Author: Jan Wielemaker
|
|
4
|
+
E-mail: jan@swi-prolog.org
|
|
5
|
+
WWW: https://www.swi-prolog.org
|
|
6
|
+
Copyright (c) 1997-2026, University of Amsterdam
|
|
7
|
+
VU University Amsterdam
|
|
8
|
+
CWI, Amsterdam
|
|
9
|
+
SWI-Prolog Solutions b.v.
|
|
10
|
+
All rights reserved.
|
|
11
|
+
|
|
12
|
+
Redistribution and use in source and binary forms, with or without
|
|
13
|
+
modification, are permitted provided that the following conditions
|
|
14
|
+
are met:
|
|
15
|
+
|
|
16
|
+
1. Redistributions of source code must retain the above copyright
|
|
17
|
+
notice, this list of conditions and the following disclaimer.
|
|
18
|
+
|
|
19
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
20
|
+
notice, this list of conditions and the following disclaimer in
|
|
21
|
+
the documentation and/or other materials provided with the
|
|
22
|
+
distribution.
|
|
23
|
+
|
|
24
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
25
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
26
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
27
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
28
|
+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
29
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
30
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
31
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
32
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
33
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
34
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
35
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
:- module('$messages',
|
|
39
|
+
[ print_message/2, % +Kind, +Term
|
|
40
|
+
print_message_lines/3, % +Stream, +Prefix, +Lines
|
|
41
|
+
message_to_string/2 % +Term, -String
|
|
42
|
+
]).
|
|
43
|
+
|
|
44
|
+
:- multifile
|
|
45
|
+
prolog:message//1, % entire message
|
|
46
|
+
prolog:error_message//1, % 1-st argument of error term
|
|
47
|
+
prolog:message_context//1, % Context of error messages
|
|
48
|
+
prolog:deprecated//1, % Deprecated features
|
|
49
|
+
prolog:message_location//1, % (File) location of error messages
|
|
50
|
+
prolog:message_line_element/2, % Extend printing
|
|
51
|
+
prolog:message_action/2. % Side effects (broadcast)
|
|
52
|
+
:- dynamic
|
|
53
|
+
prolog:message_action/2. % Allow overruling
|
|
54
|
+
:- '$hide'((
|
|
55
|
+
prolog:message//1,
|
|
56
|
+
prolog:error_message//1,
|
|
57
|
+
prolog:message_context//1,
|
|
58
|
+
prolog:deprecated//1,
|
|
59
|
+
prolog:message_location//1,
|
|
60
|
+
prolog:message_line_element/2)).
|
|
61
|
+
% Lang, Term versions
|
|
62
|
+
:- multifile
|
|
63
|
+
prolog:message//2, % entire message
|
|
64
|
+
prolog:error_message//2, % 1-st argument of error term
|
|
65
|
+
prolog:message_context//2, % Context of error messages
|
|
66
|
+
prolog:message_location//2, % (File) location of error messages
|
|
67
|
+
prolog:deprecated//2. % Deprecated features
|
|
68
|
+
:- '$hide'((
|
|
69
|
+
prolog:message//2,
|
|
70
|
+
prolog:error_message//2,
|
|
71
|
+
prolog:message_context//2,
|
|
72
|
+
prolog:deprecated//2,
|
|
73
|
+
prolog:message_location//2)).
|
|
74
|
+
|
|
75
|
+
:- discontiguous
|
|
76
|
+
prolog_message/3.
|
|
77
|
+
|
|
78
|
+
:- public
|
|
79
|
+
translate_message//1, % +Message (deprecated)
|
|
80
|
+
prolog:translate_message//1. % +Message
|
|
81
|
+
|
|
82
|
+
:- create_prolog_flag(message_context, [thread], []).
|
|
83
|
+
|
|
84
|
+
%! translate_message(+Term)// is det.
|
|
85
|
+
%
|
|
86
|
+
% Translate a message Term into message lines. The produced lines
|
|
87
|
+
% is a list of
|
|
88
|
+
%
|
|
89
|
+
% - nl
|
|
90
|
+
% Emit a newline
|
|
91
|
+
% - Fmt-Args
|
|
92
|
+
% Emit the result of format(Fmt, Args)
|
|
93
|
+
% - Fmt
|
|
94
|
+
% Emit the result of format(Fmt)
|
|
95
|
+
% - ansi(Code, Fmt, Args)
|
|
96
|
+
% Use ansi_format/3 for color output.
|
|
97
|
+
% - flush
|
|
98
|
+
% Used only as last element of the list. Simply flush the
|
|
99
|
+
% output instead of producing a final newline.
|
|
100
|
+
% - at_same_line
|
|
101
|
+
% Start the messages at the same line (instead of using ~N)
|
|
102
|
+
%
|
|
103
|
+
% @deprecated Use code for message translation should call
|
|
104
|
+
% prolog:translate_message//1.
|
|
105
|
+
|
|
106
|
+
prolog:translate_message(Term) -->
|
|
107
|
+
translate_message(Term).
|
|
108
|
+
|
|
109
|
+
%! translate_message(+Term)// is det.
|
|
110
|
+
%
|
|
111
|
+
% Translate a message term into message lines. This version may be
|
|
112
|
+
% called from user and library definitions for message translation.
|
|
113
|
+
|
|
114
|
+
translate_message(Term) -->
|
|
115
|
+
{ nonvar(Term) },
|
|
116
|
+
( { message_lang(Lang) },
|
|
117
|
+
prolog:message(Lang, Term)
|
|
118
|
+
; prolog:message(Term)
|
|
119
|
+
),
|
|
120
|
+
!.
|
|
121
|
+
translate_message(Term) -->
|
|
122
|
+
{ nonvar(Term) },
|
|
123
|
+
translate_message2(Term),
|
|
124
|
+
!.
|
|
125
|
+
translate_message(Term) -->
|
|
126
|
+
{ nonvar(Term),
|
|
127
|
+
Term = error(_, _)
|
|
128
|
+
},
|
|
129
|
+
[ 'Unknown exception: ~p'-[Term] ].
|
|
130
|
+
translate_message(Term) -->
|
|
131
|
+
[ 'Unknown message: ~p'-[Term] ].
|
|
132
|
+
|
|
133
|
+
translate_message2(Term) -->
|
|
134
|
+
prolog_message(Term).
|
|
135
|
+
translate_message2(error(resource_error(stack), Context)) -->
|
|
136
|
+
!,
|
|
137
|
+
out_of_stack(Context).
|
|
138
|
+
translate_message2(error(resource_error(tripwire(Wire, Context)), _)) -->
|
|
139
|
+
!,
|
|
140
|
+
tripwire_message(Wire, Context).
|
|
141
|
+
translate_message2(error(existence_error(reset, Ball), SWI)) -->
|
|
142
|
+
swi_location(SWI),
|
|
143
|
+
tabling_existence_error(Ball, SWI).
|
|
144
|
+
translate_message2(error(ISO, SWI)) -->
|
|
145
|
+
swi_location(SWI),
|
|
146
|
+
term_message(ISO),
|
|
147
|
+
swi_extra(SWI).
|
|
148
|
+
translate_message2(unwind(Term)) -->
|
|
149
|
+
unwind_message(Term).
|
|
150
|
+
translate_message2(message_lines(Lines), L, T) :- % deal with old C-warning()
|
|
151
|
+
make_message_lines(Lines, L, T).
|
|
152
|
+
translate_message2(format(Fmt, Args)) -->
|
|
153
|
+
[ Fmt-Args ].
|
|
154
|
+
|
|
155
|
+
make_message_lines([], T, T) :- !.
|
|
156
|
+
make_message_lines([Last], ['~w'-[Last]|T], T) :- !.
|
|
157
|
+
make_message_lines([L0|LT], ['~w'-[L0],nl|T0], T) :-
|
|
158
|
+
make_message_lines(LT, T0, T).
|
|
159
|
+
|
|
160
|
+
%! term_message(+Term)//
|
|
161
|
+
%
|
|
162
|
+
% Deal with the formal argument of error(Format, ImplDefined)
|
|
163
|
+
% exception terms. The `ImplDefined` argument is handled by
|
|
164
|
+
% swi_location//2.
|
|
165
|
+
|
|
166
|
+
:- public term_message//1.
|
|
167
|
+
term_message(Term) -->
|
|
168
|
+
{var(Term)},
|
|
169
|
+
!,
|
|
170
|
+
[ 'Unknown error term: ~p'-[Term] ].
|
|
171
|
+
term_message(Term) -->
|
|
172
|
+
{ message_lang(Lang) },
|
|
173
|
+
prolog:error_message(Lang, Term),
|
|
174
|
+
!.
|
|
175
|
+
term_message(Term) -->
|
|
176
|
+
prolog:error_message(Term),
|
|
177
|
+
!.
|
|
178
|
+
term_message(Term) -->
|
|
179
|
+
iso_message(Term).
|
|
180
|
+
term_message(Term) -->
|
|
181
|
+
swi_message(Term).
|
|
182
|
+
term_message(Term) -->
|
|
183
|
+
[ 'Unknown error term: ~p'-[Term] ].
|
|
184
|
+
|
|
185
|
+
iso_message(resource_error(c_stack)) -->
|
|
186
|
+
out_of_c_stack.
|
|
187
|
+
iso_message(resource_error(Missing)) -->
|
|
188
|
+
[ 'Not enough resources: ~w'-[Missing] ].
|
|
189
|
+
iso_message(type_error(evaluable, Actual)) -->
|
|
190
|
+
{ callable(Actual) },
|
|
191
|
+
[ 'Arithmetic: `~p'' is not a function'-[Actual] ].
|
|
192
|
+
iso_message(type_error(free_of_attvar, Actual)) -->
|
|
193
|
+
[ 'Type error: `~W'' contains attributed variables'-
|
|
194
|
+
[Actual,[portray(true), attributes(portray)]] ].
|
|
195
|
+
iso_message(type_error(Expected, Actual)) -->
|
|
196
|
+
[ 'Type error: `~w'' expected, found `~p'''-[Expected, Actual] ],
|
|
197
|
+
type_error_comment(Expected, Actual).
|
|
198
|
+
iso_message(domain_error(Domain, Actual)) -->
|
|
199
|
+
[ 'Domain error: '-[] ], domain(Domain),
|
|
200
|
+
[ ' expected, found `~p'''-[Actual] ].
|
|
201
|
+
iso_message(instantiation_error) -->
|
|
202
|
+
[ 'Arguments are not sufficiently instantiated' ].
|
|
203
|
+
iso_message(uninstantiation_error(Var)) -->
|
|
204
|
+
[ 'Uninstantiated argument expected, found ~p'-[Var] ].
|
|
205
|
+
iso_message(representation_error(What)) -->
|
|
206
|
+
[ 'Cannot represent due to `~w'''-[What] ].
|
|
207
|
+
iso_message(permission_error(Action, Type, Object)) -->
|
|
208
|
+
permission_error(Action, Type, Object).
|
|
209
|
+
iso_message(evaluation_error(Which)) -->
|
|
210
|
+
[ 'Arithmetic: evaluation error: `~p'''-[Which] ].
|
|
211
|
+
iso_message(existence_error(procedure, Proc)) -->
|
|
212
|
+
[ 'Unknown procedure: ~q'-[Proc] ],
|
|
213
|
+
unknown_proc_msg(Proc).
|
|
214
|
+
iso_message(existence_error(answer_variable, Var)) -->
|
|
215
|
+
[ '$~w was not bound by a previous query'-[Var] ].
|
|
216
|
+
iso_message(existence_error(matching_rule, Goal)) -->
|
|
217
|
+
[ 'No rule matches ~p'-[Goal] ].
|
|
218
|
+
iso_message(existence_error(Type, Object)) -->
|
|
219
|
+
[ '~w `~p'' does not exist'-[Type, Object] ].
|
|
220
|
+
iso_message(existence_error(export, PI, module(M))) --> % not ISO
|
|
221
|
+
[ 'Module ', ansi(code, '~q', [M]), ' does not export ',
|
|
222
|
+
ansi(code, '~q', [PI]) ].
|
|
223
|
+
iso_message(existence_error(Type, Object, In)) --> % not ISO
|
|
224
|
+
[ '~w `~p'' does not exist in ~p'-[Type, Object, In] ].
|
|
225
|
+
iso_message(busy(Type, Object)) -->
|
|
226
|
+
[ '~w `~p'' is busy'-[Type, Object] ].
|
|
227
|
+
iso_message(syntax_error(swi_backslash_newline)) -->
|
|
228
|
+
[ 'Deprecated: ... \\<newline><white>*. Use \\c' ].
|
|
229
|
+
iso_message(syntax_error(warning_var_tag)) -->
|
|
230
|
+
[ 'Deprecated: dict with unbound tag (_{...}). Mapped to #{...}.' ].
|
|
231
|
+
iso_message(syntax_error(var_tag)) -->
|
|
232
|
+
[ 'Syntax error: dict syntax with unbound tag (_{...}).' ].
|
|
233
|
+
iso_message(syntax_error(Id)) -->
|
|
234
|
+
[ 'Syntax error: ' ],
|
|
235
|
+
syntax_error(Id).
|
|
236
|
+
iso_message(occurs_check(Var, In)) -->
|
|
237
|
+
[ 'Cannot unify ~p with ~p: would create an infinite tree'-[Var, In] ].
|
|
238
|
+
|
|
239
|
+
%! permission_error(Action, Type, Object)//
|
|
240
|
+
%
|
|
241
|
+
% Translate permission errors. Most follow te pattern "No
|
|
242
|
+
% permission to Action Type Object", but some are a bit different.
|
|
243
|
+
|
|
244
|
+
permission_error(Action, built_in_procedure, Pred) -->
|
|
245
|
+
{ user_predicate_indicator(Pred, PI)
|
|
246
|
+
},
|
|
247
|
+
[ 'No permission to ~w built-in predicate `~p'''-[Action, PI] ],
|
|
248
|
+
( {Action \== export}
|
|
249
|
+
-> [ nl,
|
|
250
|
+
'Use :- redefine_system_predicate(+Head) if redefinition is intended'
|
|
251
|
+
]
|
|
252
|
+
; []
|
|
253
|
+
).
|
|
254
|
+
permission_error(import_into(Dest), procedure, Pred) -->
|
|
255
|
+
[ 'No permission to import ~p into ~w'-[Pred, Dest] ].
|
|
256
|
+
permission_error(Action, static_procedure, Proc) -->
|
|
257
|
+
[ 'No permission to ~w static procedure `~p'''-[Action, Proc] ],
|
|
258
|
+
defined_definition('Defined', Proc).
|
|
259
|
+
permission_error(input, stream, Stream) -->
|
|
260
|
+
[ 'No permission to read from output stream `~p'''-[Stream] ].
|
|
261
|
+
permission_error(output, stream, Stream) -->
|
|
262
|
+
[ 'No permission to write to input stream `~p'''-[Stream] ].
|
|
263
|
+
permission_error(input, text_stream, Stream) -->
|
|
264
|
+
[ 'No permission to read bytes from TEXT stream `~p'''-[Stream] ].
|
|
265
|
+
permission_error(output, text_stream, Stream) -->
|
|
266
|
+
[ 'No permission to write bytes to TEXT stream `~p'''-[Stream] ].
|
|
267
|
+
permission_error(input, binary_stream, Stream) -->
|
|
268
|
+
[ 'No permission to read characters from binary stream `~p'''-[Stream] ].
|
|
269
|
+
permission_error(output, binary_stream, Stream) -->
|
|
270
|
+
[ 'No permission to write characters to binary stream `~p'''-[Stream] ].
|
|
271
|
+
permission_error(open, source_sink, alias(Alias)) -->
|
|
272
|
+
[ 'No permission to reuse alias "~p": already taken'-[Alias] ].
|
|
273
|
+
permission_error(tnot, non_tabled_procedure, Pred) -->
|
|
274
|
+
[ 'The argument of tnot/1 is not tabled: ~p'-[Pred] ].
|
|
275
|
+
permission_error(assert, procedure, Pred) -->
|
|
276
|
+
{ '$pi_head'(Pred, Head),
|
|
277
|
+
predicate_property(Head, ssu)
|
|
278
|
+
},
|
|
279
|
+
[ '~p: an SSU (Head => Body) predicate cannot have normal Prolog clauses'-
|
|
280
|
+
[Pred] ].
|
|
281
|
+
permission_error(Action, Type, Object) -->
|
|
282
|
+
[ 'No permission to ~w ~w `~p'''-[Action, Type, Object] ].
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
unknown_proc_msg(_:(^)/2) -->
|
|
286
|
+
!,
|
|
287
|
+
unknown_proc_msg((^)/2).
|
|
288
|
+
unknown_proc_msg((^)/2) -->
|
|
289
|
+
!,
|
|
290
|
+
[nl, ' ^/2 can only appear as the 2nd argument of setof/3 and bagof/3'].
|
|
291
|
+
unknown_proc_msg((:-)/2) -->
|
|
292
|
+
!,
|
|
293
|
+
[nl, ' Rules must be loaded from a file'],
|
|
294
|
+
faq('ToplevelMode').
|
|
295
|
+
unknown_proc_msg((=>)/2) -->
|
|
296
|
+
!,
|
|
297
|
+
[nl, ' Rules must be loaded from a file'],
|
|
298
|
+
faq('ToplevelMode').
|
|
299
|
+
unknown_proc_msg((:-)/1) -->
|
|
300
|
+
!,
|
|
301
|
+
[nl, ' Directives must be loaded from a file'],
|
|
302
|
+
faq('ToplevelMode').
|
|
303
|
+
unknown_proc_msg((?-)/1) -->
|
|
304
|
+
!,
|
|
305
|
+
[nl, ' ?- is the Prolog prompt'],
|
|
306
|
+
faq('ToplevelMode').
|
|
307
|
+
unknown_proc_msg(Proc) -->
|
|
308
|
+
{ dwim_predicates(Proc, Dwims) },
|
|
309
|
+
( {Dwims \== []}
|
|
310
|
+
-> [nl, ' However, there are definitions for:', nl],
|
|
311
|
+
dwim_message(Dwims)
|
|
312
|
+
; []
|
|
313
|
+
).
|
|
314
|
+
|
|
315
|
+
dependency_error(shared(Shared), private(Private)) -->
|
|
316
|
+
[ 'Shared table for ~p may not depend on private ~p'-[Shared, Private] ].
|
|
317
|
+
dependency_error(Dep, monotonic(On)) -->
|
|
318
|
+
{ '$pi_head'(PI, Dep),
|
|
319
|
+
'$pi_head'(MPI, On)
|
|
320
|
+
},
|
|
321
|
+
[ 'Dependent ~p on monotonic predicate ~p is not monotonic or incremental'-
|
|
322
|
+
[PI, MPI]
|
|
323
|
+
].
|
|
324
|
+
|
|
325
|
+
faq(Page) -->
|
|
326
|
+
[nl, ' See FAQ at https://www.swi-prolog.org/FAQ/', Page, '.html' ].
|
|
327
|
+
|
|
328
|
+
type_error_comment(_Expected, Actual) -->
|
|
329
|
+
{ type_of(Actual, Type),
|
|
330
|
+
( sub_atom(Type, 0, 1, _, First),
|
|
331
|
+
memberchk(First, [a,e,i,o,u])
|
|
332
|
+
-> Article = an
|
|
333
|
+
; Article = a
|
|
334
|
+
)
|
|
335
|
+
},
|
|
336
|
+
[ ' (~w ~w)'-[Article, Type] ].
|
|
337
|
+
|
|
338
|
+
type_of(Term, Type) :-
|
|
339
|
+
( attvar(Term) -> Type = attvar
|
|
340
|
+
; var(Term) -> Type = var
|
|
341
|
+
; atom(Term) -> Type = atom
|
|
342
|
+
; integer(Term) -> Type = integer
|
|
343
|
+
; string(Term) -> Type = string
|
|
344
|
+
; Term == [] -> Type = empty_list
|
|
345
|
+
; blob(Term, BlobT) -> blob_type(BlobT, Type)
|
|
346
|
+
; rational(Term) -> Type = rational
|
|
347
|
+
; float(Term) -> Type = float
|
|
348
|
+
; is_stream(Term) -> Type = stream
|
|
349
|
+
; is_dict(Term) -> Type = dict
|
|
350
|
+
; is_list(Term) -> Type = list
|
|
351
|
+
; Term = [_|_] -> list_like(Term, Type)
|
|
352
|
+
; cyclic_term(Term) -> Type = cyclic
|
|
353
|
+
; compound(Term) -> Type = compound
|
|
354
|
+
; Type = unknown
|
|
355
|
+
).
|
|
356
|
+
|
|
357
|
+
list_like(Term, Type) :-
|
|
358
|
+
'$skip_list'(_, Term, Tail),
|
|
359
|
+
( var(Tail)
|
|
360
|
+
-> Type = partial_list
|
|
361
|
+
; Type = invalid_list % TBD: Better name?
|
|
362
|
+
).
|
|
363
|
+
|
|
364
|
+
blob_type(BlobT, Type) :-
|
|
365
|
+
atom_concat(BlobT, '_reference', Type).
|
|
366
|
+
|
|
367
|
+
syntax_error(end_of_clause) -->
|
|
368
|
+
[ 'Unexpected end of clause' ].
|
|
369
|
+
syntax_error(end_of_clause_expected) -->
|
|
370
|
+
[ 'End of clause expected' ].
|
|
371
|
+
syntax_error(end_of_file) -->
|
|
372
|
+
[ 'Unexpected end of file' ].
|
|
373
|
+
syntax_error(end_of_file_in_block_comment) -->
|
|
374
|
+
[ 'End of file in /* ... */ comment' ].
|
|
375
|
+
syntax_error(end_of_file_in_quoted(Quote)) -->
|
|
376
|
+
[ 'End of file in quoted ' ],
|
|
377
|
+
quoted_type(Quote).
|
|
378
|
+
syntax_error(illegal_number) -->
|
|
379
|
+
[ 'Illegal number' ].
|
|
380
|
+
syntax_error(long_atom) -->
|
|
381
|
+
[ 'Atom too long (see style_check/1)' ].
|
|
382
|
+
syntax_error(long_string) -->
|
|
383
|
+
[ 'String too long (see style_check/1)' ].
|
|
384
|
+
syntax_error(operator_clash) -->
|
|
385
|
+
[ 'Operator priority clash' ].
|
|
386
|
+
syntax_error(operator_expected) -->
|
|
387
|
+
[ 'Operator expected' ].
|
|
388
|
+
syntax_error(operator_balance) -->
|
|
389
|
+
[ 'Unbalanced operator' ].
|
|
390
|
+
syntax_error(quoted_punctuation) -->
|
|
391
|
+
[ 'Operand expected, unquoted comma or bar found' ].
|
|
392
|
+
syntax_error(list_rest) -->
|
|
393
|
+
[ 'Unexpected comma or bar in rest of list' ].
|
|
394
|
+
syntax_error(cannot_start_term) -->
|
|
395
|
+
[ 'Illegal start of term' ].
|
|
396
|
+
syntax_error(punct(Punct, End)) -->
|
|
397
|
+
[ 'Unexpected `~w\' before `~w\''-[Punct, End] ].
|
|
398
|
+
syntax_error(undefined_char_escape(C)) -->
|
|
399
|
+
[ 'Unknown character escape in quoted atom or string: `\\~w\''-[C] ].
|
|
400
|
+
syntax_error(void_not_allowed) -->
|
|
401
|
+
[ 'Empty argument list "()"' ].
|
|
402
|
+
syntax_error(Term) -->
|
|
403
|
+
{ compound(Term),
|
|
404
|
+
compound_name_arguments(Term, Syntax, [Text])
|
|
405
|
+
}, !,
|
|
406
|
+
[ '~w expected, found '-[Syntax], ansi(code, '"~w"', [Text]) ].
|
|
407
|
+
syntax_error(Message) -->
|
|
408
|
+
[ '~w'-[Message] ].
|
|
409
|
+
|
|
410
|
+
quoted_type('\'') --> [atom].
|
|
411
|
+
quoted_type('\"') --> { current_prolog_flag(double_quotes, Type) }, [Type-[]].
|
|
412
|
+
quoted_type('\`') --> { current_prolog_flag(back_quotes, Type) }, [Type-[]].
|
|
413
|
+
|
|
414
|
+
domain(range(Low,High)) -->
|
|
415
|
+
!,
|
|
416
|
+
['[~q..~q]'-[Low,High] ].
|
|
417
|
+
domain(Domain) -->
|
|
418
|
+
['`~w\''-[Domain] ].
|
|
419
|
+
|
|
420
|
+
%! tabling_existence_error(+Ball, +Context)//
|
|
421
|
+
%
|
|
422
|
+
% Called on invalid shift/1 calls. Track those that result from
|
|
423
|
+
% tabling errors.
|
|
424
|
+
|
|
425
|
+
tabling_existence_error(Ball, Context) -->
|
|
426
|
+
{ table_shift_ball(Ball) },
|
|
427
|
+
[ 'Tabling dependency error' ],
|
|
428
|
+
swi_extra(Context).
|
|
429
|
+
|
|
430
|
+
table_shift_ball(dependency(_Head)).
|
|
431
|
+
table_shift_ball(dependency(_Skeleton, _Trie, _Mono)).
|
|
432
|
+
table_shift_ball(call_info(_Skeleton, _Status)).
|
|
433
|
+
table_shift_ball(call_info(_GenSkeleton, _Skeleton, _Status)).
|
|
434
|
+
|
|
435
|
+
%! dwim_predicates(+PI, -Dwims)
|
|
436
|
+
%
|
|
437
|
+
% Find related predicate indicators.
|
|
438
|
+
|
|
439
|
+
dwim_predicates(Module:Name/_Arity, Dwims) :-
|
|
440
|
+
!,
|
|
441
|
+
findall(Dwim, dwim_predicate(Module:Name, Dwim), Dwims).
|
|
442
|
+
dwim_predicates(Name/_Arity, Dwims) :-
|
|
443
|
+
findall(Dwim, dwim_predicate(user:Name, Dwim), Dwims).
|
|
444
|
+
|
|
445
|
+
dwim_message([]) --> [].
|
|
446
|
+
dwim_message([M:Head|T]) -->
|
|
447
|
+
{ hidden_module(M),
|
|
448
|
+
!,
|
|
449
|
+
functor(Head, Name, Arity)
|
|
450
|
+
},
|
|
451
|
+
[ ' ~q'-[Name/Arity], nl ],
|
|
452
|
+
dwim_message(T).
|
|
453
|
+
dwim_message([Module:Head|T]) -->
|
|
454
|
+
!,
|
|
455
|
+
{ functor(Head, Name, Arity)
|
|
456
|
+
},
|
|
457
|
+
[ ' ~q'-[Module:Name/Arity], nl],
|
|
458
|
+
dwim_message(T).
|
|
459
|
+
dwim_message([Head|T]) -->
|
|
460
|
+
{functor(Head, Name, Arity)},
|
|
461
|
+
[ ' ~q'-[Name/Arity], nl],
|
|
462
|
+
dwim_message(T).
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
swi_message(io_error(Op, Stream)) -->
|
|
466
|
+
[ 'I/O error in ~w on stream ~p'-[Op, Stream] ].
|
|
467
|
+
swi_message(thread_error(TID, false)) -->
|
|
468
|
+
[ 'Thread ~p died due to failure:'-[TID] ].
|
|
469
|
+
swi_message(thread_error(TID, exception(Error))) -->
|
|
470
|
+
[ 'Thread ~p died abnormally:'-[TID], nl ],
|
|
471
|
+
translate_message(Error).
|
|
472
|
+
swi_message(dependency_error(Tabled, DependsOn)) -->
|
|
473
|
+
dependency_error(Tabled, DependsOn).
|
|
474
|
+
swi_message(shell(execute, Cmd)) -->
|
|
475
|
+
[ 'Could not execute `~w'''-[Cmd] ].
|
|
476
|
+
swi_message(shell(signal(Sig), Cmd)) -->
|
|
477
|
+
[ 'Caught signal ~d on `~w'''-[Sig, Cmd] ].
|
|
478
|
+
swi_message(format(Fmt, Args)) -->
|
|
479
|
+
[ Fmt-Args ].
|
|
480
|
+
swi_message(signal(Name, Num)) -->
|
|
481
|
+
[ 'Caught signal ~d (~w)'-[Num, Name] ].
|
|
482
|
+
swi_message(limit_exceeded(Limit, MaxVal)) -->
|
|
483
|
+
[ 'Exceeded ~w limit (~w)'-[Limit, MaxVal] ].
|
|
484
|
+
swi_message(goal_failed(Goal)) -->
|
|
485
|
+
[ 'goal unexpectedly failed: ~p'-[Goal] ].
|
|
486
|
+
swi_message(shared_object(_Action, Message)) --> % Message = dlerror()
|
|
487
|
+
[ '~w'-[Message] ].
|
|
488
|
+
swi_message(system_error(Error)) -->
|
|
489
|
+
[ 'error in system call: ~w'-[Error]
|
|
490
|
+
].
|
|
491
|
+
swi_message(system_error) -->
|
|
492
|
+
[ 'error in system call'
|
|
493
|
+
].
|
|
494
|
+
swi_message(failure_error(Goal)) -->
|
|
495
|
+
[ 'Goal failed: ~p'-[Goal] ].
|
|
496
|
+
swi_message(timeout_error(Op, Stream)) -->
|
|
497
|
+
[ 'Timeout in ~w from ~p'-[Op, Stream] ].
|
|
498
|
+
swi_message(not_implemented(Type, What)) -->
|
|
499
|
+
[ '~w `~p\' is not implemented in this version'-[Type, What] ].
|
|
500
|
+
swi_message(context_error(nodirective, Goal)) -->
|
|
501
|
+
{ goal_to_predicate_indicator(Goal, PI) },
|
|
502
|
+
[ 'Wrong context: ~p can only be used in a directive'-[PI] ].
|
|
503
|
+
swi_message(context_error(edit, no_default_file)) -->
|
|
504
|
+
( { current_prolog_flag(windows, true) }
|
|
505
|
+
-> [ 'Edit/0 can only be used after opening a \c
|
|
506
|
+
Prolog file by double-clicking it' ]
|
|
507
|
+
; [ 'Edit/0 can only be used with the "-s file" commandline option'
|
|
508
|
+
]
|
|
509
|
+
),
|
|
510
|
+
[ nl, 'Use "?- edit(Topic)." or "?- emacs."' ].
|
|
511
|
+
swi_message(context_error(function, meta_arg(S))) -->
|
|
512
|
+
[ 'Functions are not (yet) supported for meta-arguments of type ~q'-[S] ].
|
|
513
|
+
swi_message(format_argument_type(Fmt, Arg)) -->
|
|
514
|
+
[ 'Illegal argument to format sequence ~~~w: ~p'-[Fmt, Arg] ].
|
|
515
|
+
swi_message(format(Msg)) -->
|
|
516
|
+
[ 'Format error: ~w'-[Msg] ].
|
|
517
|
+
swi_message(conditional_compilation_error(unterminated, File:Line)) -->
|
|
518
|
+
[ 'Unterminated conditional compilation from '-[], url(File:Line) ].
|
|
519
|
+
swi_message(conditional_compilation_error(no_if, What)) -->
|
|
520
|
+
[ ':- ~w without :- if'-[What] ].
|
|
521
|
+
swi_message(duplicate_key(Key)) -->
|
|
522
|
+
[ 'Duplicate key: ~p'-[Key] ].
|
|
523
|
+
swi_message(determinism_error(PI, det, Found, property)) -->
|
|
524
|
+
( { '$pi_head'(user:PI, Head),
|
|
525
|
+
predicate_property(Head, det)
|
|
526
|
+
}
|
|
527
|
+
-> [ 'Deterministic procedure ~p'-[PI] ]
|
|
528
|
+
; [ 'Procedure ~p called from a deterministic procedure'-[PI] ]
|
|
529
|
+
),
|
|
530
|
+
det_error(Found).
|
|
531
|
+
swi_message(determinism_error(PI, det, fail, guard)) -->
|
|
532
|
+
[ 'Procedure ~p failed after $-guard'-[PI] ].
|
|
533
|
+
swi_message(determinism_error(PI, det, fail, guard_in_caller)) -->
|
|
534
|
+
[ 'Procedure ~p failed after $-guard in caller'-[PI] ].
|
|
535
|
+
swi_message(determinism_error(Goal, det, fail, goal)) -->
|
|
536
|
+
[ 'Goal ~p failed'-[Goal] ].
|
|
537
|
+
swi_message(determinism_error(Goal, det, nondet, goal)) -->
|
|
538
|
+
[ 'Goal ~p succeeded with a choice point'-[Goal] ].
|
|
539
|
+
swi_message(qlf_format_error(File, Message)) -->
|
|
540
|
+
[ '~w: Invalid QLF file: ~w'-[File, Message] ].
|
|
541
|
+
swi_message(goal_expansion_error(bound, Term)) -->
|
|
542
|
+
[ 'Goal expansion bound a variable to ~p'-[Term] ].
|
|
543
|
+
|
|
544
|
+
det_error(nondet) -->
|
|
545
|
+
[ ' succeeded with a choicepoint'- [] ].
|
|
546
|
+
det_error(fail) -->
|
|
547
|
+
[ ' failed'- [] ].
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
%! swi_location(+Term)// is det.
|
|
551
|
+
%
|
|
552
|
+
% Print location information for error(Formal, ImplDefined) from the
|
|
553
|
+
% ImplDefined term.
|
|
554
|
+
|
|
555
|
+
:- public swi_location//1.
|
|
556
|
+
swi_location(X) -->
|
|
557
|
+
{ var(X) },
|
|
558
|
+
!.
|
|
559
|
+
swi_location(Context) -->
|
|
560
|
+
{ message_lang(Lang) },
|
|
561
|
+
prolog:message_location(Lang, Context),
|
|
562
|
+
!.
|
|
563
|
+
swi_location(Context) -->
|
|
564
|
+
prolog:message_location(Context),
|
|
565
|
+
!.
|
|
566
|
+
swi_location(context(Caller, _Msg)) -->
|
|
567
|
+
{ ground(Caller) },
|
|
568
|
+
!,
|
|
569
|
+
caller(Caller).
|
|
570
|
+
swi_location(file(Path, Line, -1, _CharNo)) -->
|
|
571
|
+
!,
|
|
572
|
+
[ url(Path:Line), ': ' ].
|
|
573
|
+
swi_location(file(Path, Line, LinePos, _CharNo)) -->
|
|
574
|
+
[ url(Path:Line:LinePos), ': ' ].
|
|
575
|
+
swi_location(stream(Stream, Line, LinePos, CharNo)) -->
|
|
576
|
+
( { is_stream(Stream),
|
|
577
|
+
stream_property(Stream, file_name(File))
|
|
578
|
+
}
|
|
579
|
+
-> swi_location(file(File, Line, LinePos, CharNo))
|
|
580
|
+
; [ 'Stream ~w:~d:~d '-[Stream, Line, LinePos] ]
|
|
581
|
+
).
|
|
582
|
+
swi_location(autoload(File:Line)) -->
|
|
583
|
+
[ url(File:Line), ': ' ].
|
|
584
|
+
swi_location(_) -->
|
|
585
|
+
[].
|
|
586
|
+
|
|
587
|
+
caller(system:'$record_clause'/3) -->
|
|
588
|
+
!,
|
|
589
|
+
[].
|
|
590
|
+
caller(Module:Name/Arity) -->
|
|
591
|
+
!,
|
|
592
|
+
( { \+ hidden_module(Module) }
|
|
593
|
+
-> [ '~q:~q/~w: '-[Module, Name, Arity] ]
|
|
594
|
+
; [ '~q/~w: '-[Name, Arity] ]
|
|
595
|
+
).
|
|
596
|
+
caller(Name/Arity) -->
|
|
597
|
+
[ '~q/~w: '-[Name, Arity] ].
|
|
598
|
+
caller(Caller) -->
|
|
599
|
+
[ '~p: '-[Caller] ].
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
%! swi_extra(+Term)// is det.
|
|
603
|
+
%
|
|
604
|
+
% Extract information from the second argument of an error(Formal,
|
|
605
|
+
% ImplDefined) that is printed _after_ the core of the message.
|
|
606
|
+
%
|
|
607
|
+
% @see swi_location//1 uses the same term to insert context _before_
|
|
608
|
+
% the core of the message.
|
|
609
|
+
|
|
610
|
+
swi_extra(X) -->
|
|
611
|
+
{ var(X) },
|
|
612
|
+
!,
|
|
613
|
+
[].
|
|
614
|
+
swi_extra(Context) -->
|
|
615
|
+
{ message_lang(Lang) },
|
|
616
|
+
prolog:message_context(Lang, Context),
|
|
617
|
+
!.
|
|
618
|
+
swi_extra(Context) -->
|
|
619
|
+
prolog:message_context(Context).
|
|
620
|
+
swi_extra(context(_, Msg)) -->
|
|
621
|
+
{ nonvar(Msg),
|
|
622
|
+
Msg \== ''
|
|
623
|
+
},
|
|
624
|
+
!,
|
|
625
|
+
swi_comment(Msg).
|
|
626
|
+
swi_extra(string(String, CharPos)) -->
|
|
627
|
+
{ sub_string(String, 0, CharPos, _, Before),
|
|
628
|
+
sub_string(String, CharPos, _, 0, After)
|
|
629
|
+
},
|
|
630
|
+
[ nl, '~w'-[Before], nl, '** here **', nl, '~w'-[After] ].
|
|
631
|
+
swi_extra(_) -->
|
|
632
|
+
[].
|
|
633
|
+
|
|
634
|
+
swi_comment(already_from(Module)) -->
|
|
635
|
+
!,
|
|
636
|
+
[ ' (already imported from ~q)'-[Module] ].
|
|
637
|
+
swi_comment(directory(_Dir)) -->
|
|
638
|
+
!,
|
|
639
|
+
[ ' (is a directory)' ].
|
|
640
|
+
swi_comment(not_a_directory(_Dir)) -->
|
|
641
|
+
!,
|
|
642
|
+
[ ' (is not a directory)' ].
|
|
643
|
+
swi_comment(Msg) -->
|
|
644
|
+
[ ' (~w)'-[Msg] ].
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
thread_context -->
|
|
648
|
+
{ \+ current_prolog_flag(toplevel_thread, true),
|
|
649
|
+
thread_self(Id)
|
|
650
|
+
},
|
|
651
|
+
!,
|
|
652
|
+
['[Thread ~w] '-[Id]].
|
|
653
|
+
thread_context -->
|
|
654
|
+
[].
|
|
655
|
+
|
|
656
|
+
/*******************************
|
|
657
|
+
* UNWIND MESSAGES *
|
|
658
|
+
*******************************/
|
|
659
|
+
|
|
660
|
+
unwind_message(Var) -->
|
|
661
|
+
{ var(Var) }, !,
|
|
662
|
+
[ 'Unknown unwind message: ~p'-[Var] ].
|
|
663
|
+
unwind_message(abort) -->
|
|
664
|
+
[ 'Execution Aborted' ].
|
|
665
|
+
unwind_message(halt(_)) -->
|
|
666
|
+
[].
|
|
667
|
+
unwind_message(thread_exit(Term)) -->
|
|
668
|
+
[ 'Invalid thread_exit/1. Payload: ~p'-[Term] ].
|
|
669
|
+
unwind_message(Term) -->
|
|
670
|
+
[ 'Unknown "unwind" exception: ~p'-[Term] ].
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
/*******************************
|
|
674
|
+
* NORMAL MESSAGES *
|
|
675
|
+
*******************************/
|
|
676
|
+
|
|
677
|
+
:- dynamic prolog:version_msg/1.
|
|
678
|
+
:- multifile prolog:version_msg/1.
|
|
679
|
+
|
|
680
|
+
prolog_message(welcome) -->
|
|
681
|
+
[ 'Welcome to SWI-Prolog (' ],
|
|
682
|
+
prolog_message(threads),
|
|
683
|
+
prolog_message(address_bits),
|
|
684
|
+
['version ' ],
|
|
685
|
+
prolog_message(version),
|
|
686
|
+
[ ')', nl ],
|
|
687
|
+
prolog_message(copyright),
|
|
688
|
+
[ nl ],
|
|
689
|
+
translate_message(user_versions),
|
|
690
|
+
[ nl ],
|
|
691
|
+
prolog_message(documentaton),
|
|
692
|
+
[ nl, nl ].
|
|
693
|
+
prolog_message(user_versions) -->
|
|
694
|
+
( { findall(Msg, prolog:version_msg(Msg), Msgs),
|
|
695
|
+
Msgs \== []
|
|
696
|
+
}
|
|
697
|
+
-> [nl],
|
|
698
|
+
user_version_messages(Msgs)
|
|
699
|
+
; []
|
|
700
|
+
).
|
|
701
|
+
prolog_message(deprecated(Term)) -->
|
|
702
|
+
{ nonvar(Term) },
|
|
703
|
+
( { message_lang(Lang) },
|
|
704
|
+
prolog:deprecated(Lang, Term)
|
|
705
|
+
-> []
|
|
706
|
+
; prolog:deprecated(Term)
|
|
707
|
+
-> []
|
|
708
|
+
; deprecated(Term)
|
|
709
|
+
).
|
|
710
|
+
prolog_message(unhandled_exception(E)) -->
|
|
711
|
+
{ nonvar(E) },
|
|
712
|
+
[ 'Unhandled exception: ' ],
|
|
713
|
+
( translate_message(E)
|
|
714
|
+
-> []
|
|
715
|
+
; [ '~p'-[E] ]
|
|
716
|
+
).
|
|
717
|
+
|
|
718
|
+
%! prolog_message(+Term)//
|
|
719
|
+
|
|
720
|
+
prolog_message(initialization_error(_, E, File:Line)) -->
|
|
721
|
+
!,
|
|
722
|
+
[ url(File:Line),
|
|
723
|
+
': Initialization goal raised exception:', nl
|
|
724
|
+
],
|
|
725
|
+
translate_message(E).
|
|
726
|
+
prolog_message(initialization_error(Goal, E, _)) -->
|
|
727
|
+
[ 'Initialization goal ~p raised exception:'-[Goal], nl ],
|
|
728
|
+
translate_message(E).
|
|
729
|
+
prolog_message(initialization_failure(_Goal, File:Line)) -->
|
|
730
|
+
!,
|
|
731
|
+
[ url(File:Line),
|
|
732
|
+
': Initialization goal failed'-[]
|
|
733
|
+
].
|
|
734
|
+
prolog_message(initialization_failure(Goal, _)) -->
|
|
735
|
+
[ 'Initialization goal failed: ~p'-[Goal]
|
|
736
|
+
].
|
|
737
|
+
prolog_message(initialization_exception(E)) -->
|
|
738
|
+
[ 'Prolog initialisation failed:', nl ],
|
|
739
|
+
translate_message(E).
|
|
740
|
+
prolog_message(initialization(halt(Status), Goal, File:Line)) -->
|
|
741
|
+
[ url(File:Line), ': '], goal(Goal), [nl,
|
|
742
|
+
' Initialization goal called ', ansi(code, '~p', [halt(Status)]),
|
|
743
|
+
'.', nl,
|
|
744
|
+
' The program entry point should be called using ',
|
|
745
|
+
ansi(code, 'initialization/2', []), '.', nl,
|
|
746
|
+
' Consider using ', ansi(code, 'library(main)', []), '.'
|
|
747
|
+
].
|
|
748
|
+
prolog_message(init_goal_syntax(Error, Text)) -->
|
|
749
|
+
!,
|
|
750
|
+
[ '-g ~w: '-[Text] ],
|
|
751
|
+
translate_message(Error).
|
|
752
|
+
prolog_message(init_goal_failed(failed, @(Goal,File:Line))) -->
|
|
753
|
+
!,
|
|
754
|
+
[ url(File:Line), ': ~p: false'-[Goal] ].
|
|
755
|
+
prolog_message(init_goal_failed(Error, @(Goal,File:Line))) -->
|
|
756
|
+
!,
|
|
757
|
+
[ url(File:Line), ': ~p '-[Goal] ],
|
|
758
|
+
translate_message(Error).
|
|
759
|
+
prolog_message(init_goal_failed(failed, Text)) -->
|
|
760
|
+
!,
|
|
761
|
+
[ '-g ~w: false'-[Text] ].
|
|
762
|
+
prolog_message(init_goal_failed(Error, Text)) -->
|
|
763
|
+
!,
|
|
764
|
+
[ '-g ~w: '-[Text] ],
|
|
765
|
+
translate_message(Error).
|
|
766
|
+
prolog_message(goal_failed(Context, Goal)) -->
|
|
767
|
+
[ 'Goal (~w) failed: ~p'-[Context, Goal] ].
|
|
768
|
+
prolog_message(no_current_module(Module)) -->
|
|
769
|
+
[ '~w is not a current module (created)'-[Module] ].
|
|
770
|
+
prolog_message(commandline_arg_type(Flag, Arg)) -->
|
|
771
|
+
[ 'Bad argument to commandline option -~w: ~w'-[Flag, Arg] ].
|
|
772
|
+
prolog_message(missing_feature(Name)) -->
|
|
773
|
+
[ 'This version of SWI-Prolog does not support ~w'-[Name] ].
|
|
774
|
+
prolog_message(singletons(_Term, List)) -->
|
|
775
|
+
[ 'Singleton variables: ~w'-[List] ].
|
|
776
|
+
prolog_message(multitons(_Term, List)) -->
|
|
777
|
+
[ 'Singleton-marked variables appearing more than once: ~w'-[List] ].
|
|
778
|
+
prolog_message(profile_no_cpu_time) -->
|
|
779
|
+
[ 'No CPU-time info. Check the SWI-Prolog manual for details' ].
|
|
780
|
+
prolog_message(non_ascii(Text, Type)) -->
|
|
781
|
+
[ 'Unquoted ~w with non-portable characters: ~w'-[Type, Text] ].
|
|
782
|
+
prolog_message(io_warning(Stream, Message)) -->
|
|
783
|
+
{ stream_property(Stream, position(Position)),
|
|
784
|
+
!,
|
|
785
|
+
stream_position_data(line_count, Position, LineNo),
|
|
786
|
+
stream_position_data(line_position, Position, LinePos),
|
|
787
|
+
( stream_property(Stream, file_name(File))
|
|
788
|
+
-> Obj = File
|
|
789
|
+
; Obj = Stream
|
|
790
|
+
)
|
|
791
|
+
},
|
|
792
|
+
[ '~p:~d:~d: ~w'-[Obj, LineNo, LinePos, Message] ].
|
|
793
|
+
prolog_message(io_warning(Stream, Message)) -->
|
|
794
|
+
[ 'stream ~p: ~w'-[Stream, Message] ].
|
|
795
|
+
prolog_message(option_usage(pldoc)) -->
|
|
796
|
+
[ 'Usage: --pldoc[=port]' ].
|
|
797
|
+
prolog_message(interrupt(begin)) -->
|
|
798
|
+
[ 'Action (h for help) ? ', flush ].
|
|
799
|
+
prolog_message(interrupt(end)) -->
|
|
800
|
+
[ 'continue' ].
|
|
801
|
+
prolog_message(interrupt(trace)) -->
|
|
802
|
+
[ 'continue (trace mode)' ].
|
|
803
|
+
prolog_message(unknown_in_module_user) -->
|
|
804
|
+
[ 'Using a non-error value for unknown in the global module', nl,
|
|
805
|
+
'causes most of the development environment to stop working.', nl,
|
|
806
|
+
'Please use :- dynamic or limit usage of unknown to a module.', nl,
|
|
807
|
+
'See https://www.swi-prolog.org/howto/database.html'
|
|
808
|
+
].
|
|
809
|
+
prolog_message(untable(PI)) -->
|
|
810
|
+
[ 'Reconsult: removed tabling for ~p'-[PI] ].
|
|
811
|
+
prolog_message(unknown_option(Set, Opt)) -->
|
|
812
|
+
[ 'Unknown ~w option: ~p'-[Set, Opt] ].
|
|
813
|
+
|
|
814
|
+
|
|
815
|
+
/*******************************
|
|
816
|
+
* LOADING FILES *
|
|
817
|
+
*******************************/
|
|
818
|
+
|
|
819
|
+
prolog_message(modify_active_procedure(Who, What)) -->
|
|
820
|
+
[ '~p: modified active procedure ~p'-[Who, What] ].
|
|
821
|
+
prolog_message(load_file(failed(user:File))) -->
|
|
822
|
+
[ 'Failed to load ~p'-[File] ].
|
|
823
|
+
prolog_message(load_file(failed(Module:File))) -->
|
|
824
|
+
[ 'Failed to load ~p into module ~p'-[File, Module] ].
|
|
825
|
+
prolog_message(load_file(failed(File))) -->
|
|
826
|
+
[ 'Failed to load ~p'-[File] ].
|
|
827
|
+
prolog_message(mixed_directive(Goal)) -->
|
|
828
|
+
[ 'Cannot pre-compile mixed load/call directive: ~p'-[Goal] ].
|
|
829
|
+
prolog_message(cannot_redefine_comma) -->
|
|
830
|
+
[ 'Full stop in clause-body? Cannot redefine ,/2' ].
|
|
831
|
+
prolog_message(illegal_autoload_index(Dir, Term)) -->
|
|
832
|
+
[ 'Illegal term in INDEX file of directory ~w: ~w'-[Dir, Term] ].
|
|
833
|
+
prolog_message(redefined_procedure(Type, Proc)) -->
|
|
834
|
+
[ 'Redefined ~w procedure ~p'-[Type, Proc] ],
|
|
835
|
+
defined_definition('Previously defined', Proc).
|
|
836
|
+
prolog_message(declare_module(Module, abolish(Predicates))) -->
|
|
837
|
+
[ 'Loading module ~w abolished: ~p'-[Module, Predicates] ].
|
|
838
|
+
prolog_message(import_private(Module, Private)) -->
|
|
839
|
+
[ 'import/1: ~p is not exported (still imported into ~q)'-
|
|
840
|
+
[Private, Module]
|
|
841
|
+
].
|
|
842
|
+
prolog_message(ignored_weak_import(Into, From:PI)) -->
|
|
843
|
+
[ 'Local definition of ~p overrides weak import from ~q'-
|
|
844
|
+
[Into:PI, From]
|
|
845
|
+
].
|
|
846
|
+
prolog_message(undefined_export(Module, PI)) -->
|
|
847
|
+
[ 'Exported procedure ~q:~q is not defined'-[Module, PI] ].
|
|
848
|
+
prolog_message(no_exported_op(Module, Op)) -->
|
|
849
|
+
[ 'Operator ~q:~q is not exported (still defined)'-[Module, Op] ].
|
|
850
|
+
prolog_message(discontiguous((-)/2,_)) -->
|
|
851
|
+
prolog_message(minus_in_identifier).
|
|
852
|
+
prolog_message(discontiguous(Proc,Current)) -->
|
|
853
|
+
[ 'Clauses of ', ansi(code, '~p', [Proc]),
|
|
854
|
+
' are not together in the source-file', nl ],
|
|
855
|
+
current_definition(Proc, 'Earlier definition at '),
|
|
856
|
+
[ 'Current predicate: ', ansi(code, '~p', [Current]), nl,
|
|
857
|
+
'Use ', ansi(code, ':- discontiguous ~p.', [Proc]),
|
|
858
|
+
' to suppress this message'
|
|
859
|
+
].
|
|
860
|
+
prolog_message(decl_no_effect(Goal)) -->
|
|
861
|
+
[ 'Deprecated declaration has no effect: ~p'-[Goal] ].
|
|
862
|
+
prolog_message(load_file(start(Level, File))) -->
|
|
863
|
+
[ '~|~t~*+Loading '-[Level] ],
|
|
864
|
+
load_file(File),
|
|
865
|
+
[ ' ...' ].
|
|
866
|
+
prolog_message(include_file(start(Level, File))) -->
|
|
867
|
+
[ '~|~t~*+include '-[Level] ],
|
|
868
|
+
load_file(File),
|
|
869
|
+
[ ' ...' ].
|
|
870
|
+
prolog_message(include_file(done(Level, File))) -->
|
|
871
|
+
[ '~|~t~*+included '-[Level] ],
|
|
872
|
+
load_file(File).
|
|
873
|
+
prolog_message(load_file(done(Level, File, Action, Module, Time, Clauses))) -->
|
|
874
|
+
[ '~|~t~*+'-[Level] ],
|
|
875
|
+
load_file(File),
|
|
876
|
+
[ ' ~w'-[Action] ],
|
|
877
|
+
load_module(Module),
|
|
878
|
+
[ ' ~2f sec, ~D clauses'-[Time, Clauses] ].
|
|
879
|
+
prolog_message(dwim_undefined(Goal, Alternatives)) -->
|
|
880
|
+
{ goal_to_predicate_indicator(Goal, Pred)
|
|
881
|
+
},
|
|
882
|
+
[ 'Unknown procedure: ~q'-[Pred], nl,
|
|
883
|
+
' However, there are definitions for:', nl
|
|
884
|
+
],
|
|
885
|
+
dwim_message(Alternatives).
|
|
886
|
+
prolog_message(dwim_correct(Into)) -->
|
|
887
|
+
[ 'Correct to: ~q? '-[Into], flush ].
|
|
888
|
+
prolog_message(error(loop_error(Spec), file_search(Used))) -->
|
|
889
|
+
[ 'File search: too many levels of indirections on: ~p'-[Spec], nl,
|
|
890
|
+
' Used alias expansions:', nl
|
|
891
|
+
],
|
|
892
|
+
used_search(Used).
|
|
893
|
+
prolog_message(minus_in_identifier) -->
|
|
894
|
+
[ 'The "-" character should not be used to separate words in an', nl,
|
|
895
|
+
'identifier. Check the SWI-Prolog FAQ for details.'
|
|
896
|
+
].
|
|
897
|
+
prolog_message(qlf(removed_after_error(File))) -->
|
|
898
|
+
[ 'Removed incomplete QLF file ~w'-[File] ].
|
|
899
|
+
prolog_message(qlf(recompile(Spec,_Pl,_Qlf,Reason))) -->
|
|
900
|
+
[ '~p: recompiling QLF file'-[Spec] ],
|
|
901
|
+
qlf_recompile_reason(Reason).
|
|
902
|
+
prolog_message(qlf(can_not_recompile(Spec,QlfFile,_Reason))) -->
|
|
903
|
+
[ '~p: can not recompile "~w" (access denied)'-[Spec, QlfFile], nl,
|
|
904
|
+
'\tLoading from source'-[]
|
|
905
|
+
].
|
|
906
|
+
prolog_message(qlf(system_lib_out_of_date(Spec,QlfFile))) -->
|
|
907
|
+
[ '~p: can not recompile "~w" (access denied)'-[Spec, QlfFile], nl,
|
|
908
|
+
'\tLoading QlfFile'-[]
|
|
909
|
+
].
|
|
910
|
+
prolog_message(redefine_module(Module, OldFile, File)) -->
|
|
911
|
+
[ 'Module "~q" already loaded from ~w.'-[Module, OldFile], nl,
|
|
912
|
+
'Wipe and reload from ~w? '-[File], flush
|
|
913
|
+
].
|
|
914
|
+
prolog_message(redefine_module_reply) -->
|
|
915
|
+
[ 'Please answer y(es), n(o) or a(bort)' ].
|
|
916
|
+
prolog_message(reloaded_in_module(Absolute, OldContext, LM)) -->
|
|
917
|
+
[ '~w was previously loaded in module ~w'-[Absolute, OldContext], nl,
|
|
918
|
+
'\tnow it is reloaded into module ~w'-[LM] ].
|
|
919
|
+
prolog_message(expected_layout(Expected, Pos)) -->
|
|
920
|
+
[ 'Layout data: expected ~w, found: ~p'-[Expected, Pos] ].
|
|
921
|
+
|
|
922
|
+
defined_definition(Message, Spec) -->
|
|
923
|
+
{ strip_module(user:Spec, M, Name/Arity),
|
|
924
|
+
functor(Head, Name, Arity),
|
|
925
|
+
predicate_property(M:Head, file(File)),
|
|
926
|
+
predicate_property(M:Head, line_count(Line))
|
|
927
|
+
},
|
|
928
|
+
!,
|
|
929
|
+
[ nl, '~w at '-[Message], url(File:Line) ].
|
|
930
|
+
defined_definition(_, _) --> [].
|
|
931
|
+
|
|
932
|
+
used_search([]) -->
|
|
933
|
+
[].
|
|
934
|
+
used_search([Alias=Expanded|T]) -->
|
|
935
|
+
[ ' file_search_path(~p, ~p)'-[Alias, Expanded], nl ],
|
|
936
|
+
used_search(T).
|
|
937
|
+
|
|
938
|
+
load_file(file(Spec, _Path)) -->
|
|
939
|
+
( {atomic(Spec)}
|
|
940
|
+
-> [ '~w'-[Spec] ]
|
|
941
|
+
; [ '~p'-[Spec] ]
|
|
942
|
+
).
|
|
943
|
+
%load_file(file(_, Path)) -->
|
|
944
|
+
% [ '~w'-[Path] ].
|
|
945
|
+
|
|
946
|
+
load_module(user) --> !.
|
|
947
|
+
load_module(system) --> !.
|
|
948
|
+
load_module(Module) -->
|
|
949
|
+
[ ' into ~w'-[Module] ].
|
|
950
|
+
|
|
951
|
+
goal_to_predicate_indicator(Goal, PI) :-
|
|
952
|
+
strip_module(Goal, Module, Head),
|
|
953
|
+
'$pi_head'(PI0, Module:Head),
|
|
954
|
+
( current_predicate(PI0),
|
|
955
|
+
predicate_property(Module:Head, non_terminal)
|
|
956
|
+
-> dcg_pi(PI0, PI)
|
|
957
|
+
; PI = PI0
|
|
958
|
+
),
|
|
959
|
+
user_predicate_indicator(PI, PI).
|
|
960
|
+
|
|
961
|
+
dcg_pi(Module:Name/Arity, Module:Name//DCGArity) :-
|
|
962
|
+
DCGArity is Arity-2.
|
|
963
|
+
|
|
964
|
+
user_predicate_indicator(Module:PI, PI) :-
|
|
965
|
+
hidden_module(Module),
|
|
966
|
+
!.
|
|
967
|
+
user_predicate_indicator(PI, PI).
|
|
968
|
+
|
|
969
|
+
hidden_module(user) :- !.
|
|
970
|
+
hidden_module(system) :- !.
|
|
971
|
+
hidden_module(M) :-
|
|
972
|
+
sub_atom(M, 0, _, _, $).
|
|
973
|
+
|
|
974
|
+
current_definition(Proc, Prefix) -->
|
|
975
|
+
{ pi_uhead(Proc, Head),
|
|
976
|
+
predicate_property(Head, file(File)),
|
|
977
|
+
predicate_property(Head, line_count(Line))
|
|
978
|
+
},
|
|
979
|
+
[ '~w'-[Prefix], url(File:Line), nl ].
|
|
980
|
+
current_definition(_, _) --> [].
|
|
981
|
+
|
|
982
|
+
pi_uhead(Module:Name/Arity, Module:Head) :-
|
|
983
|
+
!,
|
|
984
|
+
atom(Module), atom(Name), integer(Arity),
|
|
985
|
+
functor(Head, Name, Arity).
|
|
986
|
+
pi_uhead(Name/Arity, user:Head) :-
|
|
987
|
+
atom(Name), integer(Arity),
|
|
988
|
+
functor(Head, Name, Arity).
|
|
989
|
+
|
|
990
|
+
qlf_recompile_reason(old) -->
|
|
991
|
+
!,
|
|
992
|
+
[ ' (out of date)'-[] ].
|
|
993
|
+
qlf_recompile_reason(_) -->
|
|
994
|
+
[ ' (incompatible with current Prolog version)'-[] ].
|
|
995
|
+
|
|
996
|
+
prolog_message(file_search(cache(Spec, _Cond), Path)) -->
|
|
997
|
+
[ 'File search: ~p --> ~p (cache)'-[Spec, Path] ].
|
|
998
|
+
prolog_message(file_search(found(Spec, Cond), Path)) -->
|
|
999
|
+
[ 'File search: ~p --> ~p OK ~p'-[Spec, Path, Cond] ].
|
|
1000
|
+
prolog_message(file_search(tried(Spec, Cond), Path)) -->
|
|
1001
|
+
[ 'File search: ~p --> ~p NO ~p'-[Spec, Path, Cond] ].
|
|
1002
|
+
|
|
1003
|
+
/*******************************
|
|
1004
|
+
* GC *
|
|
1005
|
+
*******************************/
|
|
1006
|
+
|
|
1007
|
+
prolog_message(agc(start)) -->
|
|
1008
|
+
thread_context,
|
|
1009
|
+
[ 'AGC: ', flush ].
|
|
1010
|
+
prolog_message(agc(done(Collected, Remaining, Time))) -->
|
|
1011
|
+
[ at_same_line,
|
|
1012
|
+
'reclaimed ~D atoms in ~3f sec. (remaining: ~D)'-
|
|
1013
|
+
[Collected, Time, Remaining]
|
|
1014
|
+
].
|
|
1015
|
+
prolog_message(cgc(start)) -->
|
|
1016
|
+
thread_context,
|
|
1017
|
+
[ 'CGC: ', flush ].
|
|
1018
|
+
prolog_message(cgc(done(CollectedClauses, _CollectedBytes,
|
|
1019
|
+
RemainingBytes, Time))) -->
|
|
1020
|
+
[ at_same_line,
|
|
1021
|
+
'reclaimed ~D clauses in ~3f sec. (pending: ~D bytes)'-
|
|
1022
|
+
[CollectedClauses, Time, RemainingBytes]
|
|
1023
|
+
].
|
|
1024
|
+
|
|
1025
|
+
/*******************************
|
|
1026
|
+
* STACK OVERFLOW *
|
|
1027
|
+
*******************************/
|
|
1028
|
+
|
|
1029
|
+
out_of_stack(Context) -->
|
|
1030
|
+
{ human_stack_size(Context.localused, Local),
|
|
1031
|
+
human_stack_size(Context.globalused, Global),
|
|
1032
|
+
human_stack_size(Context.trailused, Trail),
|
|
1033
|
+
human_stack_size(Context.stack_limit, Limit),
|
|
1034
|
+
LCO is (100*(Context.depth - Context.environments))/Context.depth
|
|
1035
|
+
},
|
|
1036
|
+
[ 'Stack limit (~s) exceeded'-[Limit], nl,
|
|
1037
|
+
' Stack sizes: local: ~s, global: ~s, trail: ~s'-[Local,Global,Trail], nl,
|
|
1038
|
+
' Stack depth: ~D, last-call: ~0f%, Choice points: ~D'-
|
|
1039
|
+
[Context.depth, LCO, Context.choicepoints], nl
|
|
1040
|
+
],
|
|
1041
|
+
overflow_reason(Context, Resolve),
|
|
1042
|
+
resolve_overflow(Resolve).
|
|
1043
|
+
|
|
1044
|
+
human_stack_size(Size, String) :-
|
|
1045
|
+
Size < 100,
|
|
1046
|
+
format(string(String), '~dKb', [Size]).
|
|
1047
|
+
human_stack_size(Size, String) :-
|
|
1048
|
+
Size < 100 000,
|
|
1049
|
+
Value is Size / 1024,
|
|
1050
|
+
format(string(String), '~1fMb', [Value]).
|
|
1051
|
+
human_stack_size(Size, String) :-
|
|
1052
|
+
Value is Size / (1024*1024),
|
|
1053
|
+
format(string(String), '~1fGb', [Value]).
|
|
1054
|
+
|
|
1055
|
+
overflow_reason(Context, fix) -->
|
|
1056
|
+
show_non_termination(Context),
|
|
1057
|
+
!.
|
|
1058
|
+
overflow_reason(Context, enlarge) -->
|
|
1059
|
+
{ Stack = Context.get(stack) },
|
|
1060
|
+
!,
|
|
1061
|
+
[ ' In:'-[], nl ],
|
|
1062
|
+
stack(Stack).
|
|
1063
|
+
overflow_reason(_Context, enlarge) -->
|
|
1064
|
+
[ ' Insufficient global stack'-[] ].
|
|
1065
|
+
|
|
1066
|
+
show_non_termination(Context) -->
|
|
1067
|
+
( { Stack = Context.get(cycle) }
|
|
1068
|
+
-> [ ' Probable infinite recursion (cycle):'-[], nl ]
|
|
1069
|
+
; { Stack = Context.get(non_terminating) }
|
|
1070
|
+
-> [ ' Possible non-terminating recursion:'-[], nl ]
|
|
1071
|
+
),
|
|
1072
|
+
stack(Stack).
|
|
1073
|
+
|
|
1074
|
+
stack([]) --> [].
|
|
1075
|
+
stack([frame(Depth, M:Goal, _)|T]) -->
|
|
1076
|
+
[ ' [~D] ~q:'-[Depth, M] ],
|
|
1077
|
+
stack_goal(Goal),
|
|
1078
|
+
[ nl ],
|
|
1079
|
+
stack(T).
|
|
1080
|
+
|
|
1081
|
+
stack_goal(Goal) -->
|
|
1082
|
+
{ compound(Goal),
|
|
1083
|
+
!,
|
|
1084
|
+
compound_name_arity(Goal, Name, Arity)
|
|
1085
|
+
},
|
|
1086
|
+
[ '~q('-[Name] ],
|
|
1087
|
+
stack_goal_args(1, Arity, Goal),
|
|
1088
|
+
[ ')'-[] ].
|
|
1089
|
+
stack_goal(Goal) -->
|
|
1090
|
+
[ '~q'-[Goal] ].
|
|
1091
|
+
|
|
1092
|
+
stack_goal_args(I, Arity, Goal) -->
|
|
1093
|
+
{ I =< Arity,
|
|
1094
|
+
!,
|
|
1095
|
+
arg(I, Goal, A),
|
|
1096
|
+
I2 is I + 1
|
|
1097
|
+
},
|
|
1098
|
+
stack_goal_arg(A),
|
|
1099
|
+
( { I2 =< Arity }
|
|
1100
|
+
-> [ ', '-[] ],
|
|
1101
|
+
stack_goal_args(I2, Arity, Goal)
|
|
1102
|
+
; []
|
|
1103
|
+
).
|
|
1104
|
+
stack_goal_args(_, _, _) -->
|
|
1105
|
+
[].
|
|
1106
|
+
|
|
1107
|
+
stack_goal_arg(A) -->
|
|
1108
|
+
{ nonvar(A),
|
|
1109
|
+
A = [Len|T],
|
|
1110
|
+
!
|
|
1111
|
+
},
|
|
1112
|
+
( {Len == cyclic_term}
|
|
1113
|
+
-> [ '[cyclic list]'-[] ]
|
|
1114
|
+
; {T == []}
|
|
1115
|
+
-> [ '[length:~D]'-[Len] ]
|
|
1116
|
+
; [ '[length:~D|~p]'-[Len, T] ]
|
|
1117
|
+
).
|
|
1118
|
+
stack_goal_arg(A) -->
|
|
1119
|
+
{ nonvar(A),
|
|
1120
|
+
A = _/_,
|
|
1121
|
+
!
|
|
1122
|
+
},
|
|
1123
|
+
[ '<compound ~p>'-[A] ].
|
|
1124
|
+
stack_goal_arg(A) -->
|
|
1125
|
+
[ '~p'-[A] ].
|
|
1126
|
+
|
|
1127
|
+
resolve_overflow(fix) -->
|
|
1128
|
+
[].
|
|
1129
|
+
resolve_overflow(enlarge) -->
|
|
1130
|
+
{ current_prolog_flag(stack_limit, LimitBytes),
|
|
1131
|
+
NewLimit is LimitBytes * 2
|
|
1132
|
+
},
|
|
1133
|
+
[ nl,
|
|
1134
|
+
'Use the --stack_limit=size[KMG] command line option or'-[], nl,
|
|
1135
|
+
'?- set_prolog_flag(stack_limit, ~I). to double the limit.'-[NewLimit]
|
|
1136
|
+
].
|
|
1137
|
+
|
|
1138
|
+
%! out_of_c_stack
|
|
1139
|
+
%
|
|
1140
|
+
% The thread's C-stack limit was exceeded. Give some advice on how to
|
|
1141
|
+
% resolve this.
|
|
1142
|
+
|
|
1143
|
+
out_of_c_stack -->
|
|
1144
|
+
{ statistics(c_stack, Limit), Limit > 0 },
|
|
1145
|
+
!,
|
|
1146
|
+
[ 'C-stack limit (~D bytes) exceeded.'-[Limit], nl ],
|
|
1147
|
+
resolve_c_stack_overflow(Limit).
|
|
1148
|
+
out_of_c_stack -->
|
|
1149
|
+
{ statistics(c_stack, Limit), Limit > 0 },
|
|
1150
|
+
[ 'C-stack limit exceeded.'-[Limit], nl ],
|
|
1151
|
+
resolve_c_stack_overflow(Limit).
|
|
1152
|
+
|
|
1153
|
+
resolve_c_stack_overflow(_Limit) -->
|
|
1154
|
+
{ thread_self(main) },
|
|
1155
|
+
[ 'Use the shell command ' ], code('~w', 'ulimit -s size'),
|
|
1156
|
+
[ ' to enlarge the limit.' ].
|
|
1157
|
+
resolve_c_stack_overflow(_Limit) -->
|
|
1158
|
+
[ 'Use the ' ], code('~w', 'c_stack(KBytes)'),
|
|
1159
|
+
[ ' option of '], code(thread_create/3), [' to enlarge the limit.' ].
|
|
1160
|
+
|
|
1161
|
+
|
|
1162
|
+
/*******************************
|
|
1163
|
+
* MAKE/AUTOLOAD *
|
|
1164
|
+
*******************************/
|
|
1165
|
+
|
|
1166
|
+
prolog_message(make(reload(Files))) -->
|
|
1167
|
+
{ length(Files, N)
|
|
1168
|
+
},
|
|
1169
|
+
[ 'Make: reloading ~D files'-[N] ].
|
|
1170
|
+
prolog_message(make(done(_Files))) -->
|
|
1171
|
+
[ 'Make: finished' ].
|
|
1172
|
+
prolog_message(make(library_index(Dir))) -->
|
|
1173
|
+
[ 'Updating index for library ~w'-[Dir] ].
|
|
1174
|
+
prolog_message(autoload(Pred, File)) -->
|
|
1175
|
+
thread_context,
|
|
1176
|
+
[ 'autoloading ~p from ~w'-[Pred, File] ].
|
|
1177
|
+
prolog_message(autoload(read_index(Dir))) -->
|
|
1178
|
+
[ 'Loading autoload index for ~w'-[Dir] ].
|
|
1179
|
+
prolog_message(autoload(disabled(Loaded))) -->
|
|
1180
|
+
[ 'Disabled autoloading (loaded ~D files)'-[Loaded] ].
|
|
1181
|
+
prolog_message(autoload(already_defined(PI, From))) -->
|
|
1182
|
+
code(PI),
|
|
1183
|
+
( { '$pi_head'(PI, Head),
|
|
1184
|
+
predicate_property(Head, built_in)
|
|
1185
|
+
}
|
|
1186
|
+
-> [' is a built-in predicate']
|
|
1187
|
+
; [ ' is already imported from module ' ],
|
|
1188
|
+
code(From)
|
|
1189
|
+
).
|
|
1190
|
+
|
|
1191
|
+
swi_message(autoload(Msg)) -->
|
|
1192
|
+
[ nl, ' ' ],
|
|
1193
|
+
autoload_message(Msg).
|
|
1194
|
+
|
|
1195
|
+
autoload_message(not_exported(PI, Spec, _FullFile, _Exports)) -->
|
|
1196
|
+
[ ansi(code, '~w', [Spec]),
|
|
1197
|
+
' does not export ',
|
|
1198
|
+
ansi(code, '~p', [PI])
|
|
1199
|
+
].
|
|
1200
|
+
autoload_message(no_file(Spec)) -->
|
|
1201
|
+
[ ansi(code, '~p', [Spec]), ': No such file' ].
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
/*******************************
|
|
1205
|
+
* COMPILER WARNINGS *
|
|
1206
|
+
*******************************/
|
|
1207
|
+
|
|
1208
|
+
% print warnings about dubious code raised by the compiler.
|
|
1209
|
+
% TBD: pass in PC to produce exact error locations.
|
|
1210
|
+
|
|
1211
|
+
prolog_message(compiler_warnings(Clause, Warnings0)) -->
|
|
1212
|
+
{ print_goal_options(DefOptions),
|
|
1213
|
+
( prolog_load_context(variable_names, VarNames)
|
|
1214
|
+
-> warnings_with_named_vars(Warnings0, VarNames, Warnings),
|
|
1215
|
+
Options = [variable_names(VarNames)|DefOptions]
|
|
1216
|
+
; Options = DefOptions,
|
|
1217
|
+
Warnings = Warnings0
|
|
1218
|
+
)
|
|
1219
|
+
},
|
|
1220
|
+
compiler_warnings(Warnings, Clause, Options).
|
|
1221
|
+
|
|
1222
|
+
warnings_with_named_vars([], _, []).
|
|
1223
|
+
warnings_with_named_vars([H|T0], VarNames, [H|T]) :-
|
|
1224
|
+
term_variables(H, Vars),
|
|
1225
|
+
'$member'(V1, Vars),
|
|
1226
|
+
'$member'(_=V2, VarNames),
|
|
1227
|
+
V1 == V2,
|
|
1228
|
+
!,
|
|
1229
|
+
warnings_with_named_vars(T0, VarNames, T).
|
|
1230
|
+
warnings_with_named_vars([_|T0], VarNames, T) :-
|
|
1231
|
+
warnings_with_named_vars(T0, VarNames, T).
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
compiler_warnings([], _, _) --> [].
|
|
1235
|
+
compiler_warnings([H|T], Clause, Options) -->
|
|
1236
|
+
( compiler_warning(H, Clause, Options)
|
|
1237
|
+
-> []
|
|
1238
|
+
; [ 'Unknown compiler warning: ~W'-[H,Options] ]
|
|
1239
|
+
),
|
|
1240
|
+
( {T==[]}
|
|
1241
|
+
-> []
|
|
1242
|
+
; [nl]
|
|
1243
|
+
),
|
|
1244
|
+
compiler_warnings(T, Clause, Options).
|
|
1245
|
+
|
|
1246
|
+
compiler_warning(eq_vv(A,B), _Clause, Options) -->
|
|
1247
|
+
( { A == B }
|
|
1248
|
+
-> [ 'Test is always true: ~W'-[A==B, Options] ]
|
|
1249
|
+
; [ 'Test is always false: ~W'-[A==B, Options] ]
|
|
1250
|
+
).
|
|
1251
|
+
compiler_warning(eq_singleton(A,B), _Clause, Options) -->
|
|
1252
|
+
[ 'Test is always false: ~W'-[A==B, Options] ].
|
|
1253
|
+
compiler_warning(neq_vv(A,B), _Clause, Options) -->
|
|
1254
|
+
( { A \== B }
|
|
1255
|
+
-> [ 'Test is always true: ~W'-[A\==B, Options] ]
|
|
1256
|
+
; [ 'Test is always false: ~W'-[A\==B, Options] ]
|
|
1257
|
+
).
|
|
1258
|
+
compiler_warning(neq_singleton(A,B), _Clause, Options) -->
|
|
1259
|
+
[ 'Test is always true: ~W'-[A\==B, Options] ].
|
|
1260
|
+
compiler_warning(unify_singleton(A,B), _Clause, Options) -->
|
|
1261
|
+
[ 'Unified variable is not used: ~W'-[A=B, Options] ].
|
|
1262
|
+
compiler_warning(always(Bool, Pred, Arg), _Clause, Options) -->
|
|
1263
|
+
{ Goal =.. [Pred,Arg] },
|
|
1264
|
+
[ 'Test is always ~w: ~W'-[Bool, Goal, Options] ].
|
|
1265
|
+
compiler_warning(unbalanced_var(V), _Clause, Options) -->
|
|
1266
|
+
[ 'Variable not introduced in all branches: ~W'-[V, Options] ].
|
|
1267
|
+
compiler_warning(branch_singleton(V), _Clause, Options) -->
|
|
1268
|
+
[ 'Singleton variable in branch: ~W'-[V, Options] ].
|
|
1269
|
+
compiler_warning(negation_singleton(V), _Clause, Options) -->
|
|
1270
|
+
[ 'Singleton variable in \\+: ~W'-[V, Options] ].
|
|
1271
|
+
compiler_warning(multiton(V), _Clause, Options) -->
|
|
1272
|
+
[ 'Singleton-marked variable appears more than once: ~W'-[V, Options] ].
|
|
1273
|
+
|
|
1274
|
+
print_goal_options(
|
|
1275
|
+
[ quoted(true),
|
|
1276
|
+
portray(true)
|
|
1277
|
+
]).
|
|
1278
|
+
|
|
1279
|
+
|
|
1280
|
+
/*******************************
|
|
1281
|
+
* TOPLEVEL MESSAGES *
|
|
1282
|
+
*******************************/
|
|
1283
|
+
|
|
1284
|
+
prolog_message(version) -->
|
|
1285
|
+
{ current_prolog_flag(version_git, Version) },
|
|
1286
|
+
!,
|
|
1287
|
+
[ '~w'-[Version] ].
|
|
1288
|
+
prolog_message(version) -->
|
|
1289
|
+
{ current_prolog_flag(version_data, swi(Major,Minor,Patch,Options))
|
|
1290
|
+
},
|
|
1291
|
+
( { memberchk(tag(Tag), Options) }
|
|
1292
|
+
-> [ '~w.~w.~w-~w'-[Major, Minor, Patch, Tag] ]
|
|
1293
|
+
; [ '~w.~w.~w'-[Major, Minor, Patch] ]
|
|
1294
|
+
).
|
|
1295
|
+
prolog_message(address_bits) -->
|
|
1296
|
+
{ current_prolog_flag(address_bits, Bits)
|
|
1297
|
+
},
|
|
1298
|
+
!,
|
|
1299
|
+
[ '~d bits, '-[Bits] ].
|
|
1300
|
+
prolog_message(threads) -->
|
|
1301
|
+
{ current_prolog_flag(threads, true)
|
|
1302
|
+
},
|
|
1303
|
+
!,
|
|
1304
|
+
[ 'threaded, ' ].
|
|
1305
|
+
prolog_message(threads) -->
|
|
1306
|
+
[].
|
|
1307
|
+
prolog_message(copyright) -->
|
|
1308
|
+
[ 'SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.', nl,
|
|
1309
|
+
'Please run ', ansi(code, '?- license.', []), ' for legal details.'
|
|
1310
|
+
].
|
|
1311
|
+
prolog_message(documentaton) -->
|
|
1312
|
+
[ 'For online help and background, visit ', url('https://www.swi-prolog.org') ],
|
|
1313
|
+
( { exists_source(library(help)) }
|
|
1314
|
+
-> [ nl,
|
|
1315
|
+
'For built-in help, use ', ansi(code, '?- help(Topic).', []),
|
|
1316
|
+
' or ', ansi(code, '?- apropos(Word).', [])
|
|
1317
|
+
]
|
|
1318
|
+
; []
|
|
1319
|
+
).
|
|
1320
|
+
prolog_message(about) -->
|
|
1321
|
+
[ 'SWI-Prolog version (' ],
|
|
1322
|
+
prolog_message(threads),
|
|
1323
|
+
prolog_message(address_bits),
|
|
1324
|
+
['version ' ],
|
|
1325
|
+
prolog_message(version),
|
|
1326
|
+
[ ')', nl ],
|
|
1327
|
+
prolog_message(copyright).
|
|
1328
|
+
prolog_message(halt) -->
|
|
1329
|
+
[ 'halt' ].
|
|
1330
|
+
prolog_message(break(begin, Level)) -->
|
|
1331
|
+
[ 'Break level ~d'-[Level] ].
|
|
1332
|
+
prolog_message(break(end, Level)) -->
|
|
1333
|
+
[ 'Exit break level ~d'-[Level] ].
|
|
1334
|
+
prolog_message(var_query(_)) -->
|
|
1335
|
+
[ '... 1,000,000 ............ 10,000,000 years later', nl, nl,
|
|
1336
|
+
'~t~8|>> 42 << (last release gives the question)'
|
|
1337
|
+
].
|
|
1338
|
+
prolog_message(close_on_abort(Stream)) -->
|
|
1339
|
+
[ 'Abort: closed stream ~p'-[Stream] ].
|
|
1340
|
+
prolog_message(cancel_halt(Reason)) -->
|
|
1341
|
+
[ 'Halt cancelled: ~p'-[Reason] ].
|
|
1342
|
+
prolog_message(on_error(halt(Status))) -->
|
|
1343
|
+
{ statistics(errors, Errors),
|
|
1344
|
+
statistics(warnings, Warnings)
|
|
1345
|
+
},
|
|
1346
|
+
[ 'Halting with status ~w due to ~D errors and ~D warnings'-
|
|
1347
|
+
[Status, Errors, Warnings] ].
|
|
1348
|
+
|
|
1349
|
+
prolog_message(query(QueryResult)) -->
|
|
1350
|
+
query_result(QueryResult).
|
|
1351
|
+
|
|
1352
|
+
query_result(no) --> % failure
|
|
1353
|
+
[ ansi(truth(false), 'false.', []) ],
|
|
1354
|
+
extra_line.
|
|
1355
|
+
query_result(yes(true, [])) --> % prompt_alternatives_on: groundness
|
|
1356
|
+
!,
|
|
1357
|
+
[ ansi(truth(true), 'true.', []) ],
|
|
1358
|
+
extra_line.
|
|
1359
|
+
query_result(yes(Delays, Residuals)) -->
|
|
1360
|
+
result([], Delays, Residuals),
|
|
1361
|
+
extra_line.
|
|
1362
|
+
query_result(done) --> % user typed <CR>
|
|
1363
|
+
extra_line.
|
|
1364
|
+
query_result(yes(Bindings, Delays, Residuals)) -->
|
|
1365
|
+
result(Bindings, Delays, Residuals),
|
|
1366
|
+
prompt(yes, Bindings, Delays, Residuals).
|
|
1367
|
+
query_result(more(Bindings, Delays, Residuals)) -->
|
|
1368
|
+
result(Bindings, Delays, Residuals),
|
|
1369
|
+
prompt(more, Bindings, Delays, Residuals).
|
|
1370
|
+
:- if(current_prolog_flag(emscripten, true)).
|
|
1371
|
+
query_result(help) -->
|
|
1372
|
+
[ ansi(bold, ' Possible actions:', []), nl,
|
|
1373
|
+
' ; (n,r,space): redo | t: trace&redo'-[], nl,
|
|
1374
|
+
' *: show choicepoint | . (c,a): stop'-[], nl,
|
|
1375
|
+
' w: write | p: print'-[], nl,
|
|
1376
|
+
' +: max_depth*5 | -: max_depth//5'-[], nl,
|
|
1377
|
+
' h (?): help'-[],
|
|
1378
|
+
nl, nl
|
|
1379
|
+
].
|
|
1380
|
+
:- else.
|
|
1381
|
+
query_result(help) -->
|
|
1382
|
+
[ ansi(bold, ' Possible actions:', []), nl,
|
|
1383
|
+
' ; (n,r,space,TAB): redo | t: trace&redo'-[], nl,
|
|
1384
|
+
' *: show choicepoint | . (c,a,RET): stop'-[], nl,
|
|
1385
|
+
' w: write | p: print'-[], nl,
|
|
1386
|
+
' +: max_depth*5 | -: max_depth//5'-[], nl,
|
|
1387
|
+
' b: break | h (?): help'-[],
|
|
1388
|
+
nl, nl
|
|
1389
|
+
].
|
|
1390
|
+
:- endif.
|
|
1391
|
+
query_result(action) -->
|
|
1392
|
+
[ 'Action? '-[], flush ].
|
|
1393
|
+
query_result(confirm) -->
|
|
1394
|
+
[ 'Please answer \'y\' or \'n\'? '-[], flush ].
|
|
1395
|
+
query_result(eof) -->
|
|
1396
|
+
[ nl ].
|
|
1397
|
+
query_result(toplevel_open_line) -->
|
|
1398
|
+
[].
|
|
1399
|
+
|
|
1400
|
+
prompt(Answer, [], true, []-[]) -->
|
|
1401
|
+
!,
|
|
1402
|
+
prompt(Answer, empty).
|
|
1403
|
+
prompt(Answer, _, _, _) -->
|
|
1404
|
+
!,
|
|
1405
|
+
prompt(Answer, non_empty).
|
|
1406
|
+
|
|
1407
|
+
prompt(yes, empty) -->
|
|
1408
|
+
!,
|
|
1409
|
+
[ ansi(truth(true), 'true.', []) ],
|
|
1410
|
+
extra_line.
|
|
1411
|
+
prompt(yes, _) -->
|
|
1412
|
+
!,
|
|
1413
|
+
[ full_stop ],
|
|
1414
|
+
extra_line.
|
|
1415
|
+
prompt(more, empty) -->
|
|
1416
|
+
!,
|
|
1417
|
+
[ ansi(truth(true), 'true ', []), flush ].
|
|
1418
|
+
prompt(more, _) -->
|
|
1419
|
+
!,
|
|
1420
|
+
[ ' '-[], flush ].
|
|
1421
|
+
|
|
1422
|
+
result(Bindings, Delays, Residuals) -->
|
|
1423
|
+
{ current_prolog_flag(answer_write_options, Options0),
|
|
1424
|
+
Options = [partial(true)|Options0],
|
|
1425
|
+
GOptions = [priority(999)|Options0]
|
|
1426
|
+
},
|
|
1427
|
+
wfs_residual_program(Delays, GOptions),
|
|
1428
|
+
bindings(Bindings, [priority(699)|Options]),
|
|
1429
|
+
( {Residuals == []-[]}
|
|
1430
|
+
-> bind_delays_sep(Bindings, Delays),
|
|
1431
|
+
delays(Delays, GOptions)
|
|
1432
|
+
; bind_res_sep(Bindings, Residuals),
|
|
1433
|
+
residuals(Residuals, GOptions),
|
|
1434
|
+
( {Delays == true}
|
|
1435
|
+
-> []
|
|
1436
|
+
; [','-[], nl],
|
|
1437
|
+
delays(Delays, GOptions)
|
|
1438
|
+
)
|
|
1439
|
+
).
|
|
1440
|
+
|
|
1441
|
+
bindings([], _) -->
|
|
1442
|
+
[].
|
|
1443
|
+
bindings([binding(Names,Skel,Subst)|T], Options) -->
|
|
1444
|
+
{ '$last'(Names, Name) },
|
|
1445
|
+
var_names(Names), value(Name, Skel, Subst, Options),
|
|
1446
|
+
( { T \== [] }
|
|
1447
|
+
-> [ ','-[], nl ],
|
|
1448
|
+
bindings(T, Options)
|
|
1449
|
+
; []
|
|
1450
|
+
).
|
|
1451
|
+
|
|
1452
|
+
var_names([Name]) -->
|
|
1453
|
+
!,
|
|
1454
|
+
[ '~w = '-[Name] ].
|
|
1455
|
+
var_names([Name1,Name2|T]) -->
|
|
1456
|
+
!,
|
|
1457
|
+
[ '~w = ~w, '-[Name1, Name2] ],
|
|
1458
|
+
var_names([Name2|T]).
|
|
1459
|
+
|
|
1460
|
+
|
|
1461
|
+
value(Name, Skel, Subst, Options) -->
|
|
1462
|
+
( { var(Skel), Subst = [Skel=S] }
|
|
1463
|
+
-> { Skel = '$VAR'(Name) },
|
|
1464
|
+
[ '~W'-[S, Options] ]
|
|
1465
|
+
; [ '~W'-[Skel, Options] ],
|
|
1466
|
+
substitution(Subst, Options)
|
|
1467
|
+
).
|
|
1468
|
+
|
|
1469
|
+
substitution([], _) --> !.
|
|
1470
|
+
substitution([N=V|T], Options) -->
|
|
1471
|
+
[ ', ', ansi(comment, '% where', []), nl,
|
|
1472
|
+
' ~w = ~W'-[N,V,Options] ],
|
|
1473
|
+
substitutions(T, Options).
|
|
1474
|
+
|
|
1475
|
+
substitutions([], _) --> [].
|
|
1476
|
+
substitutions([N=V|T], Options) -->
|
|
1477
|
+
[ ','-[], nl, ' ~w = ~W'-[N,V,Options] ],
|
|
1478
|
+
substitutions(T, Options).
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
residuals(Normal-Hidden, Options) -->
|
|
1482
|
+
residuals1(Normal, Options),
|
|
1483
|
+
bind_res_sep(Normal, Hidden),
|
|
1484
|
+
( {Hidden == []}
|
|
1485
|
+
-> []
|
|
1486
|
+
; [ansi(comment, '% with pending residual goals', []), nl]
|
|
1487
|
+
),
|
|
1488
|
+
residuals1(Hidden, Options).
|
|
1489
|
+
|
|
1490
|
+
residuals1([], _) -->
|
|
1491
|
+
[].
|
|
1492
|
+
residuals1([G|Gs], Options) -->
|
|
1493
|
+
( { Gs \== [] }
|
|
1494
|
+
-> [ '~W,'-[G, Options], nl ],
|
|
1495
|
+
residuals1(Gs, Options)
|
|
1496
|
+
; [ '~W'-[G, Options] ]
|
|
1497
|
+
).
|
|
1498
|
+
|
|
1499
|
+
wfs_residual_program(true, _Options) -->
|
|
1500
|
+
!.
|
|
1501
|
+
wfs_residual_program(Goal, _Options) -->
|
|
1502
|
+
{ current_prolog_flag(toplevel_list_wfs_residual_program, true),
|
|
1503
|
+
'$current_typein_module'(TypeIn),
|
|
1504
|
+
( current_predicate(delays_residual_program/2)
|
|
1505
|
+
-> true
|
|
1506
|
+
; use_module(library(wfs), [delays_residual_program/2])
|
|
1507
|
+
),
|
|
1508
|
+
delays_residual_program(TypeIn:Goal, TypeIn:Program),
|
|
1509
|
+
Program \== []
|
|
1510
|
+
},
|
|
1511
|
+
!,
|
|
1512
|
+
[ ansi(comment, '% WFS residual program', []), nl ],
|
|
1513
|
+
[ ansi(wfs(residual_program), '~@', ['$messages':list_clauses(Program)]) ].
|
|
1514
|
+
wfs_residual_program(_, _) --> [].
|
|
1515
|
+
|
|
1516
|
+
delays(true, _Options) -->
|
|
1517
|
+
!.
|
|
1518
|
+
delays(Goal, Options) -->
|
|
1519
|
+
{ current_prolog_flag(toplevel_list_wfs_residual_program, true)
|
|
1520
|
+
},
|
|
1521
|
+
!,
|
|
1522
|
+
[ ansi(truth(undefined), '~W', [Goal, Options]) ].
|
|
1523
|
+
delays(_, _Options) -->
|
|
1524
|
+
[ ansi(truth(undefined), undefined, []) ].
|
|
1525
|
+
|
|
1526
|
+
:- public list_clauses/1.
|
|
1527
|
+
|
|
1528
|
+
list_clauses([]).
|
|
1529
|
+
list_clauses([H|T]) :-
|
|
1530
|
+
( system_undefined(H)
|
|
1531
|
+
-> true
|
|
1532
|
+
; portray_clause(user_output, H, [indent(4)])
|
|
1533
|
+
),
|
|
1534
|
+
list_clauses(T).
|
|
1535
|
+
|
|
1536
|
+
system_undefined((undefined :- tnot(undefined))).
|
|
1537
|
+
system_undefined((answer_count_restraint :- tnot(answer_count_restraint))).
|
|
1538
|
+
system_undefined((radial_restraint :- tnot(radial_restraint))).
|
|
1539
|
+
|
|
1540
|
+
bind_res_sep(_, []) --> !.
|
|
1541
|
+
bind_res_sep(_, []-[]) --> !.
|
|
1542
|
+
bind_res_sep([], _) --> !.
|
|
1543
|
+
bind_res_sep(_, _) --> [','-[], nl].
|
|
1544
|
+
|
|
1545
|
+
bind_delays_sep([], _) --> !.
|
|
1546
|
+
bind_delays_sep(_, true) --> !.
|
|
1547
|
+
bind_delays_sep(_, _) --> [','-[], nl].
|
|
1548
|
+
|
|
1549
|
+
extra_line -->
|
|
1550
|
+
{ current_prolog_flag(toplevel_extra_white_line, true) },
|
|
1551
|
+
!,
|
|
1552
|
+
['~N'-[]].
|
|
1553
|
+
extra_line -->
|
|
1554
|
+
[].
|
|
1555
|
+
|
|
1556
|
+
prolog_message(if_tty(Message)) -->
|
|
1557
|
+
( {current_prolog_flag(tty_control, true)}
|
|
1558
|
+
-> [ at_same_line ], list(Message)
|
|
1559
|
+
; []
|
|
1560
|
+
).
|
|
1561
|
+
prolog_message(halt(Reason)) -->
|
|
1562
|
+
[ '~w: halt'-[Reason] ].
|
|
1563
|
+
prolog_message(no_action(Char)) -->
|
|
1564
|
+
[ 'Unknown action: ~c (h for help)'-[Char], nl ].
|
|
1565
|
+
|
|
1566
|
+
prolog_message(history(help(Show, Help))) -->
|
|
1567
|
+
[ 'History Commands:', nl,
|
|
1568
|
+
' !!. Repeat last query', nl,
|
|
1569
|
+
' !nr. Repeat query numbered <nr>', nl,
|
|
1570
|
+
' !str. Repeat last query starting with <str>', nl,
|
|
1571
|
+
' !?str. Repeat last query holding <str>', nl,
|
|
1572
|
+
' ^old^new. Substitute <old> into <new> of last query', nl,
|
|
1573
|
+
' !nr^old^new. Substitute in query numbered <nr>', nl,
|
|
1574
|
+
' !str^old^new. Substitute in query starting with <str>', nl,
|
|
1575
|
+
' !?str^old^new. Substitute in query holding <str>', nl,
|
|
1576
|
+
' ~w.~21|Show history list'-[Show], nl,
|
|
1577
|
+
' ~w.~21|Show this list'-[Help], nl, nl
|
|
1578
|
+
].
|
|
1579
|
+
prolog_message(history(no_event)) -->
|
|
1580
|
+
[ '! No such event' ].
|
|
1581
|
+
prolog_message(history(bad_substitution)) -->
|
|
1582
|
+
[ '! Bad substitution' ].
|
|
1583
|
+
prolog_message(history(expanded(Event))) -->
|
|
1584
|
+
[ '~w.'-[Event] ].
|
|
1585
|
+
prolog_message(history(history(Events))) -->
|
|
1586
|
+
history_events(Events).
|
|
1587
|
+
prolog_message(history(no_history)) -->
|
|
1588
|
+
[ '! event history not supported in this version' ].
|
|
1589
|
+
|
|
1590
|
+
history_events([]) -->
|
|
1591
|
+
[].
|
|
1592
|
+
history_events([Nr-Event|T]) -->
|
|
1593
|
+
[ ansi(comment, '%', []),
|
|
1594
|
+
ansi(bold, '~t~w ~6|', [Nr]),
|
|
1595
|
+
ansi(code, '~s', [Event]),
|
|
1596
|
+
nl
|
|
1597
|
+
],
|
|
1598
|
+
history_events(T).
|
|
1599
|
+
|
|
1600
|
+
|
|
1601
|
+
%! user_version_messages(+Terms)//
|
|
1602
|
+
%
|
|
1603
|
+
% Helper for the `welcome` message to print information registered
|
|
1604
|
+
% using version/1.
|
|
1605
|
+
|
|
1606
|
+
user_version_messages([]) --> [].
|
|
1607
|
+
user_version_messages([H|T]) -->
|
|
1608
|
+
user_version_message(H),
|
|
1609
|
+
user_version_messages(T).
|
|
1610
|
+
|
|
1611
|
+
%! user_version_message(+Term)
|
|
1612
|
+
|
|
1613
|
+
user_version_message(Term) -->
|
|
1614
|
+
translate_message(Term), !, [nl].
|
|
1615
|
+
user_version_message(Atom) -->
|
|
1616
|
+
[ '~w'-[Atom], nl ].
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
/*******************************
|
|
1620
|
+
* DEBUGGER MESSAGES *
|
|
1621
|
+
*******************************/
|
|
1622
|
+
|
|
1623
|
+
prolog_message(spy(Head)) -->
|
|
1624
|
+
[ 'New spy point on ' ],
|
|
1625
|
+
goal_predicate(Head).
|
|
1626
|
+
prolog_message(already_spying(Head)) -->
|
|
1627
|
+
[ 'Already spying ' ],
|
|
1628
|
+
goal_predicate(Head).
|
|
1629
|
+
prolog_message(nospy(Head)) -->
|
|
1630
|
+
[ 'Removed spy point from ' ],
|
|
1631
|
+
goal_predicate(Head).
|
|
1632
|
+
prolog_message(trace_mode(OnOff)) -->
|
|
1633
|
+
[ 'Trace mode switched to ~w'-[OnOff] ].
|
|
1634
|
+
prolog_message(debug_mode(OnOff)) -->
|
|
1635
|
+
[ 'Debug mode switched to ~w'-[OnOff] ].
|
|
1636
|
+
prolog_message(debugging(OnOff, Threads)) -->
|
|
1637
|
+
[ 'Debug mode is ~w'-[OnOff] ],
|
|
1638
|
+
debugging_threads(Threads).
|
|
1639
|
+
prolog_message(spying([])) -->
|
|
1640
|
+
!,
|
|
1641
|
+
[ 'No spy points' ].
|
|
1642
|
+
prolog_message(spying(Heads)) -->
|
|
1643
|
+
[ 'Spy points (see spy/1) on:', nl ],
|
|
1644
|
+
predicate_list(Heads).
|
|
1645
|
+
prolog_message(trace(Head, [])) -->
|
|
1646
|
+
!,
|
|
1647
|
+
[ ' ' ], goal_predicate(Head), [ ' Not tracing'-[], nl].
|
|
1648
|
+
prolog_message(trace(Head, Ports)) -->
|
|
1649
|
+
{ '$member'(Port, Ports), compound(Port),
|
|
1650
|
+
!,
|
|
1651
|
+
numbervars(Head+Ports, 0, _, [singletons(true)])
|
|
1652
|
+
},
|
|
1653
|
+
[ ' ~p: ~p'-[Head,Ports] ].
|
|
1654
|
+
prolog_message(trace(Head, Ports)) -->
|
|
1655
|
+
[ ' ' ], goal_predicate(Head), [ ': ~w'-[Ports], nl].
|
|
1656
|
+
prolog_message(tracing([])) -->
|
|
1657
|
+
!,
|
|
1658
|
+
[ 'No traced predicates (see trace/1,2)' ].
|
|
1659
|
+
prolog_message(tracing(Heads)) -->
|
|
1660
|
+
[ 'Trace points (see trace/1,2) on:', nl ],
|
|
1661
|
+
tracing_list(Heads).
|
|
1662
|
+
|
|
1663
|
+
goal_predicate(Head) -->
|
|
1664
|
+
{ predicate_property(Head, file(File)),
|
|
1665
|
+
predicate_property(Head, line_count(Line)),
|
|
1666
|
+
goal_to_predicate_indicator(Head, PI),
|
|
1667
|
+
term_string(PI, PIS, [quoted(true)])
|
|
1668
|
+
},
|
|
1669
|
+
[ url(File:Line, PIS) ].
|
|
1670
|
+
goal_predicate(Head) -->
|
|
1671
|
+
{ goal_to_predicate_indicator(Head, PI)
|
|
1672
|
+
},
|
|
1673
|
+
[ ansi(code, '~p', [PI]) ].
|
|
1674
|
+
|
|
1675
|
+
|
|
1676
|
+
predicate_list([]) --> % TBD: Share with dwim, etc.
|
|
1677
|
+
[].
|
|
1678
|
+
predicate_list([H|T]) -->
|
|
1679
|
+
[ ' ' ], goal_predicate(H), [nl],
|
|
1680
|
+
predicate_list(T).
|
|
1681
|
+
|
|
1682
|
+
tracing_list([]) -->
|
|
1683
|
+
[].
|
|
1684
|
+
tracing_list([trace(Head, Ports)|T]) -->
|
|
1685
|
+
translate_message(trace(Head, Ports)),
|
|
1686
|
+
tracing_list(T).
|
|
1687
|
+
|
|
1688
|
+
debugging_threads([]) -->
|
|
1689
|
+
[].
|
|
1690
|
+
debugging_threads(ThreadsByClass) -->
|
|
1691
|
+
[ nl, 'Threads in the following classes run in debug mode:', nl],
|
|
1692
|
+
list_threads_by_class(ThreadsByClass).
|
|
1693
|
+
|
|
1694
|
+
list_threads_by_class([]) -->
|
|
1695
|
+
[].
|
|
1696
|
+
list_threads_by_class([H|T]) -->
|
|
1697
|
+
list_thread_class(H),
|
|
1698
|
+
list_threads_by_class(T).
|
|
1699
|
+
|
|
1700
|
+
list_thread_class(Class-Threads) -->
|
|
1701
|
+
{ length(Threads, Count) },
|
|
1702
|
+
[ ' Class ', ansi(code, '~p', [Class]), ': ~D threads'-[Count] ].
|
|
1703
|
+
|
|
1704
|
+
% frame(+Frame, +Choice, +Port, +PC) - Print for the debugger.
|
|
1705
|
+
prolog_message(frame(Frame, _Choice, backtrace, _PC)) -->
|
|
1706
|
+
!,
|
|
1707
|
+
{ prolog_frame_attribute(Frame, level, Level)
|
|
1708
|
+
},
|
|
1709
|
+
[ ansi(frame(level), '~t[~D] ~10|', [Level]) ],
|
|
1710
|
+
frame_context(Frame),
|
|
1711
|
+
frame_goal(Frame).
|
|
1712
|
+
prolog_message(frame(Frame, _Choice, choice, PC)) -->
|
|
1713
|
+
!,
|
|
1714
|
+
prolog_message(frame(Frame, backtrace, PC)).
|
|
1715
|
+
prolog_message(frame(_, _Choice, cut_call(_PC), _)) --> !.
|
|
1716
|
+
prolog_message(frame(Frame, _Choice, Port, _PC)) -->
|
|
1717
|
+
frame_flags(Frame),
|
|
1718
|
+
port(Port),
|
|
1719
|
+
frame_level(Frame),
|
|
1720
|
+
frame_context(Frame),
|
|
1721
|
+
frame_depth_limit(Port, Frame),
|
|
1722
|
+
frame_goal(Frame),
|
|
1723
|
+
[ flush ].
|
|
1724
|
+
|
|
1725
|
+
% frame(:Goal, +Trace) - Print for trace/2
|
|
1726
|
+
prolog_message(frame(Goal, trace(Port))) -->
|
|
1727
|
+
!,
|
|
1728
|
+
thread_context,
|
|
1729
|
+
[ ' T ' ],
|
|
1730
|
+
port(Port),
|
|
1731
|
+
goal(Goal).
|
|
1732
|
+
prolog_message(frame(Goal, trace(Port, Id))) -->
|
|
1733
|
+
!,
|
|
1734
|
+
thread_context,
|
|
1735
|
+
[ ' T ' ],
|
|
1736
|
+
port(Port, Id),
|
|
1737
|
+
goal(Goal).
|
|
1738
|
+
|
|
1739
|
+
frame_goal(Frame) -->
|
|
1740
|
+
{ prolog_frame_attribute(Frame, goal, Goal)
|
|
1741
|
+
},
|
|
1742
|
+
goal(Goal).
|
|
1743
|
+
|
|
1744
|
+
goal(Goal0) -->
|
|
1745
|
+
{ clean_goal(Goal0, Goal),
|
|
1746
|
+
current_prolog_flag(debugger_write_options, Options)
|
|
1747
|
+
},
|
|
1748
|
+
[ '~W'-[Goal, Options] ].
|
|
1749
|
+
|
|
1750
|
+
frame_level(Frame) -->
|
|
1751
|
+
{ prolog_frame_attribute(Frame, level, Level)
|
|
1752
|
+
},
|
|
1753
|
+
[ '(~D) '-[Level] ].
|
|
1754
|
+
|
|
1755
|
+
frame_context(Frame) -->
|
|
1756
|
+
( { current_prolog_flag(debugger_show_context, true),
|
|
1757
|
+
prolog_frame_attribute(Frame, context_module, Context)
|
|
1758
|
+
}
|
|
1759
|
+
-> [ '[~w] '-[Context] ]
|
|
1760
|
+
; []
|
|
1761
|
+
).
|
|
1762
|
+
|
|
1763
|
+
frame_depth_limit(fail, Frame) -->
|
|
1764
|
+
{ prolog_frame_attribute(Frame, depth_limit_exceeded, true)
|
|
1765
|
+
},
|
|
1766
|
+
!,
|
|
1767
|
+
[ '[depth-limit exceeded] ' ].
|
|
1768
|
+
frame_depth_limit(_, _) -->
|
|
1769
|
+
[].
|
|
1770
|
+
|
|
1771
|
+
frame_flags(Frame) -->
|
|
1772
|
+
{ prolog_frame_attribute(Frame, goal, Goal),
|
|
1773
|
+
( predicate_property(Goal, transparent)
|
|
1774
|
+
-> T = '^'
|
|
1775
|
+
; T = ' '
|
|
1776
|
+
),
|
|
1777
|
+
( predicate_property(Goal, spying)
|
|
1778
|
+
-> S = '*'
|
|
1779
|
+
; S = ' '
|
|
1780
|
+
)
|
|
1781
|
+
},
|
|
1782
|
+
[ '~w~w '-[T, S] ].
|
|
1783
|
+
|
|
1784
|
+
% trace/1 context handling
|
|
1785
|
+
port(Port, Dict) -->
|
|
1786
|
+
{ _{level:Level, start:Time} :< Dict
|
|
1787
|
+
},
|
|
1788
|
+
( { Port \== call,
|
|
1789
|
+
get_time(Now),
|
|
1790
|
+
Passed is (Now - Time)*1000.0
|
|
1791
|
+
}
|
|
1792
|
+
-> [ '[~d +~1fms] '-[Level, Passed] ]
|
|
1793
|
+
; [ '[~d] '-[Level] ]
|
|
1794
|
+
),
|
|
1795
|
+
port(Port).
|
|
1796
|
+
port(Port, _Id-Level) -->
|
|
1797
|
+
[ '[~d] '-[Level] ],
|
|
1798
|
+
port(Port).
|
|
1799
|
+
|
|
1800
|
+
port(PortTerm) -->
|
|
1801
|
+
{ functor(PortTerm, Port, _),
|
|
1802
|
+
port_name(Port, Name)
|
|
1803
|
+
},
|
|
1804
|
+
!,
|
|
1805
|
+
[ ansi(port(Port), '~w: ', [Name]) ].
|
|
1806
|
+
|
|
1807
|
+
port_name(call, 'Call').
|
|
1808
|
+
port_name(exit, 'Exit').
|
|
1809
|
+
port_name(fail, 'Fail').
|
|
1810
|
+
port_name(redo, 'Redo').
|
|
1811
|
+
port_name(unify, 'Unify').
|
|
1812
|
+
port_name(exception, 'Exception').
|
|
1813
|
+
|
|
1814
|
+
clean_goal(M:Goal, Goal) :-
|
|
1815
|
+
hidden_module(M),
|
|
1816
|
+
!.
|
|
1817
|
+
clean_goal(M:Goal, Goal) :-
|
|
1818
|
+
predicate_property(M:Goal, built_in),
|
|
1819
|
+
!.
|
|
1820
|
+
clean_goal(Goal, Goal).
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
/*******************************
|
|
1824
|
+
* COMPATIBILITY *
|
|
1825
|
+
*******************************/
|
|
1826
|
+
|
|
1827
|
+
prolog_message(compatibility(renamed(Old, New))) -->
|
|
1828
|
+
[ 'The predicate ~p has been renamed to ~p.'-[Old, New], nl,
|
|
1829
|
+
'Please update your sources for compatibility with future versions.'
|
|
1830
|
+
].
|
|
1831
|
+
|
|
1832
|
+
|
|
1833
|
+
/*******************************
|
|
1834
|
+
* THREADS *
|
|
1835
|
+
*******************************/
|
|
1836
|
+
|
|
1837
|
+
prolog_message(abnormal_thread_completion(Goal, exception(Ex))) -->
|
|
1838
|
+
!,
|
|
1839
|
+
[ 'Thread running "~p" died on exception: '-[Goal] ],
|
|
1840
|
+
translate_message(Ex).
|
|
1841
|
+
prolog_message(abnormal_thread_completion(Goal, fail)) -->
|
|
1842
|
+
[ 'Thread running "~p" died due to failure'-[Goal] ].
|
|
1843
|
+
prolog_message(threads_not_died(Running)) -->
|
|
1844
|
+
[ 'The following threads wouldn\'t die: ~p'-[Running] ].
|
|
1845
|
+
|
|
1846
|
+
|
|
1847
|
+
/*******************************
|
|
1848
|
+
* PACKS *
|
|
1849
|
+
*******************************/
|
|
1850
|
+
|
|
1851
|
+
prolog_message(pack(attached(Pack, BaseDir))) -->
|
|
1852
|
+
[ 'Attached package ~w at ~q'-[Pack, BaseDir] ].
|
|
1853
|
+
prolog_message(pack(duplicate(Entry, OldDir, Dir))) -->
|
|
1854
|
+
[ 'Package ~w already attached at ~q.'-[Entry,OldDir], nl,
|
|
1855
|
+
'\tIgnoring version from ~q'- [Dir]
|
|
1856
|
+
].
|
|
1857
|
+
prolog_message(pack(no_arch(Entry, Arch))) -->
|
|
1858
|
+
[ 'Package ~w: no binary for architecture ~w'-[Entry, Arch] ].
|
|
1859
|
+
|
|
1860
|
+
/*******************************
|
|
1861
|
+
* MISC *
|
|
1862
|
+
*******************************/
|
|
1863
|
+
|
|
1864
|
+
prolog_message(null_byte_in_path(Component)) -->
|
|
1865
|
+
[ '0-byte in PATH component: ~p (skipped directory)'-[Component] ].
|
|
1866
|
+
prolog_message(invalid_tmp_dir(Dir, Reason)) -->
|
|
1867
|
+
[ 'Cannot use ~p as temporary file directory: ~w'-[Dir, Reason] ].
|
|
1868
|
+
prolog_message(ambiguous_stream_pair(Pair)) -->
|
|
1869
|
+
[ 'Ambiguous operation on stream pair ~p'-[Pair] ].
|
|
1870
|
+
prolog_message(backcomp(init_file_moved(FoundFile))) -->
|
|
1871
|
+
{ absolute_file_name(app_config('init.pl'), InitFile,
|
|
1872
|
+
[ file_errors(fail)
|
|
1873
|
+
])
|
|
1874
|
+
},
|
|
1875
|
+
[ 'The location of the config file has moved'-[], nl,
|
|
1876
|
+
' from "~w"'-[FoundFile], nl,
|
|
1877
|
+
' to "~w"'-[InitFile], nl,
|
|
1878
|
+
' See https://www.swi-prolog.org/modified/config-files.html'-[]
|
|
1879
|
+
].
|
|
1880
|
+
prolog_message(not_accessed_flags(List)) -->
|
|
1881
|
+
[ 'The following Prolog flags have been set but not used:', nl ],
|
|
1882
|
+
flags(List).
|
|
1883
|
+
prolog_message(prolog_flag_invalid_preset(Flag, Preset, _Type, New)) -->
|
|
1884
|
+
[ 'Prolog flag ', ansi(code, '~q', Flag), ' has been (re-)created with a type that is \c
|
|
1885
|
+
incompatible with its value.', nl,
|
|
1886
|
+
'Value updated from ', ansi(code, '~p', [Preset]), ' to default (',
|
|
1887
|
+
ansi(code, '~p', [New]), ')'
|
|
1888
|
+
].
|
|
1889
|
+
|
|
1890
|
+
|
|
1891
|
+
flags([H|T]) -->
|
|
1892
|
+
[' ', ansi(code, '~q', [H])],
|
|
1893
|
+
( {T == []}
|
|
1894
|
+
-> []
|
|
1895
|
+
; [nl],
|
|
1896
|
+
flags(T)
|
|
1897
|
+
).
|
|
1898
|
+
|
|
1899
|
+
|
|
1900
|
+
/*******************************
|
|
1901
|
+
* DEPRECATED *
|
|
1902
|
+
*******************************/
|
|
1903
|
+
|
|
1904
|
+
deprecated(set_prolog_stack(_Stack,limit)) -->
|
|
1905
|
+
[ 'set_prolog_stack/2: limit(Size) sets the combined limit.'-[], nl,
|
|
1906
|
+
'See https://www.swi-prolog.org/changes/stack-limit.html'
|
|
1907
|
+
].
|
|
1908
|
+
deprecated(autoload(TargetModule, File, _M:PI, expansion)) -->
|
|
1909
|
+
!,
|
|
1910
|
+
[ 'Auto-loading ', ansi(code, '~p', [PI]), ' from ' ],
|
|
1911
|
+
load_file(File), [ ' into ' ],
|
|
1912
|
+
target_module(TargetModule),
|
|
1913
|
+
[ ' is deprecated due to term- or goal-expansion' ].
|
|
1914
|
+
deprecated(source_search_working_directory(File, _FullFile)) -->
|
|
1915
|
+
[ 'Found file ', ansi(code, '~w', [File]),
|
|
1916
|
+
' relative to the current working directory.', nl,
|
|
1917
|
+
'This behaviour is deprecated but still supported by', nl,
|
|
1918
|
+
'the Prolog flag ',
|
|
1919
|
+
ansi(code, source_search_working_directory, []), '.', nl
|
|
1920
|
+
].
|
|
1921
|
+
deprecated(moved_library(Old, New)) -->
|
|
1922
|
+
[ 'Library was moved: ~q --> ~q'-[Old, New] ].
|
|
1923
|
+
|
|
1924
|
+
load_file(File) -->
|
|
1925
|
+
{ file_base_name(File, Base),
|
|
1926
|
+
absolute_file_name(library(Base), File, [access(read), file_errors(fail)]),
|
|
1927
|
+
file_name_extension(Clean, pl, Base)
|
|
1928
|
+
},
|
|
1929
|
+
!,
|
|
1930
|
+
[ ansi(code, '~p', [library(Clean)]) ].
|
|
1931
|
+
load_file(File) -->
|
|
1932
|
+
[ url(File) ].
|
|
1933
|
+
|
|
1934
|
+
target_module(Module) -->
|
|
1935
|
+
{ module_property(Module, file(File)) },
|
|
1936
|
+
!,
|
|
1937
|
+
load_file(File).
|
|
1938
|
+
target_module(Module) -->
|
|
1939
|
+
[ 'module ', ansi(code, '~p', [Module]) ].
|
|
1940
|
+
|
|
1941
|
+
|
|
1942
|
+
|
|
1943
|
+
/*******************************
|
|
1944
|
+
* TRIPWIRES *
|
|
1945
|
+
*******************************/
|
|
1946
|
+
|
|
1947
|
+
tripwire_message(max_integer_size, Bytes) -->
|
|
1948
|
+
!,
|
|
1949
|
+
[ 'Trapped tripwire max_integer_size: big integers and \c
|
|
1950
|
+
rationals are limited to ~D bytes'-[Bytes] ].
|
|
1951
|
+
tripwire_message(Wire, Context) -->
|
|
1952
|
+
[ 'Trapped tripwire ~w for '-[Wire] ],
|
|
1953
|
+
tripwire_context(Wire, Context).
|
|
1954
|
+
|
|
1955
|
+
tripwire_context(_, ATrie) -->
|
|
1956
|
+
{ '$is_answer_trie'(ATrie, _),
|
|
1957
|
+
!,
|
|
1958
|
+
'$tabling':atrie_goal(ATrie, QGoal),
|
|
1959
|
+
user_predicate_indicator(QGoal, Goal)
|
|
1960
|
+
},
|
|
1961
|
+
[ '~p'-[Goal] ].
|
|
1962
|
+
tripwire_context(_, Ctx) -->
|
|
1963
|
+
[ '~p'-[Ctx] ].
|
|
1964
|
+
|
|
1965
|
+
|
|
1966
|
+
/*******************************
|
|
1967
|
+
* INTERNATIONALIZATION *
|
|
1968
|
+
*******************************/
|
|
1969
|
+
|
|
1970
|
+
:- create_prolog_flag(message_language, default, []).
|
|
1971
|
+
|
|
1972
|
+
%! message_lang(-Lang) is multi.
|
|
1973
|
+
%
|
|
1974
|
+
% True when Lang is a language id preferred for messages. Starts with
|
|
1975
|
+
% the most specific language (e.g., `nl_BE`) and ends with `en`.
|
|
1976
|
+
|
|
1977
|
+
message_lang(Lang) :-
|
|
1978
|
+
current_message_lang(Lang0),
|
|
1979
|
+
( Lang0 == en
|
|
1980
|
+
-> Lang = en
|
|
1981
|
+
; sub_atom(Lang0, 0, _, _, en_)
|
|
1982
|
+
-> longest_id(Lang0, Lang)
|
|
1983
|
+
; ( longest_id(Lang0, Lang)
|
|
1984
|
+
; Lang = en
|
|
1985
|
+
)
|
|
1986
|
+
).
|
|
1987
|
+
|
|
1988
|
+
longest_id(Lang, Id) :-
|
|
1989
|
+
split_string(Lang, "_-", "", [H|Components]),
|
|
1990
|
+
longest_prefix(Components, Taken),
|
|
1991
|
+
atomic_list_concat([H|Taken], '_', Id).
|
|
1992
|
+
|
|
1993
|
+
longest_prefix([H|T0], [H|T]) :-
|
|
1994
|
+
longest_prefix(T0, T).
|
|
1995
|
+
longest_prefix(_, []).
|
|
1996
|
+
|
|
1997
|
+
%! current_message_lang(-Lang) is det.
|
|
1998
|
+
%
|
|
1999
|
+
% Get the current language for messages.
|
|
2000
|
+
|
|
2001
|
+
current_message_lang(Lang) :-
|
|
2002
|
+
( current_prolog_flag(message_language, Lang0),
|
|
2003
|
+
Lang0 \== default
|
|
2004
|
+
-> Lang = Lang0
|
|
2005
|
+
; os_user_lang(Lang0)
|
|
2006
|
+
-> clean_encoding(Lang0, Lang1),
|
|
2007
|
+
set_prolog_flag(message_language, Lang1),
|
|
2008
|
+
Lang = Lang1
|
|
2009
|
+
; Lang = en
|
|
2010
|
+
).
|
|
2011
|
+
|
|
2012
|
+
os_user_lang(Lang) :-
|
|
2013
|
+
current_prolog_flag(windows, true),
|
|
2014
|
+
win_get_user_preferred_ui_languages(name, [Lang|_]).
|
|
2015
|
+
os_user_lang(Lang) :-
|
|
2016
|
+
catch(setlocale(messages, _, ''), _, fail),
|
|
2017
|
+
setlocale(messages, Lang, Lang).
|
|
2018
|
+
os_user_lang(Lang) :-
|
|
2019
|
+
getenv('LANG', Lang).
|
|
2020
|
+
|
|
2021
|
+
|
|
2022
|
+
clean_encoding(Lang0, Lang) :-
|
|
2023
|
+
( sub_atom(Lang0, A, _, _, '.')
|
|
2024
|
+
-> sub_atom(Lang0, 0, A, _, Lang)
|
|
2025
|
+
; Lang = Lang0
|
|
2026
|
+
).
|
|
2027
|
+
|
|
2028
|
+
/*******************************
|
|
2029
|
+
* PRIMITIVES *
|
|
2030
|
+
*******************************/
|
|
2031
|
+
|
|
2032
|
+
code(Term) -->
|
|
2033
|
+
code('~p', Term).
|
|
2034
|
+
|
|
2035
|
+
code(Format, Term) -->
|
|
2036
|
+
[ ansi(code, Format, [Term]) ].
|
|
2037
|
+
|
|
2038
|
+
list([]) --> [].
|
|
2039
|
+
list([H|T]) --> [H], list(T).
|
|
2040
|
+
|
|
2041
|
+
|
|
2042
|
+
/*******************************
|
|
2043
|
+
* DEFAULT THEME *
|
|
2044
|
+
*******************************/
|
|
2045
|
+
|
|
2046
|
+
:- public default_theme/2.
|
|
2047
|
+
|
|
2048
|
+
default_theme(var, [fg(red)]).
|
|
2049
|
+
default_theme(code, [fg(blue)]).
|
|
2050
|
+
default_theme(comment, [fg(green)]).
|
|
2051
|
+
default_theme(warning, [fg(red)]).
|
|
2052
|
+
default_theme(error, [bold, fg(red)]).
|
|
2053
|
+
default_theme(truth(false), [bold, fg(red)]).
|
|
2054
|
+
default_theme(truth(true), [bold]).
|
|
2055
|
+
default_theme(truth(undefined), [bold, fg(cyan)]).
|
|
2056
|
+
default_theme(wfs(residual_program), [fg(cyan)]).
|
|
2057
|
+
default_theme(frame(level), [bold]).
|
|
2058
|
+
default_theme(port(call), [bold, fg(green)]).
|
|
2059
|
+
default_theme(port(exit), [bold, fg(green)]).
|
|
2060
|
+
default_theme(port(fail), [bold, fg(red)]).
|
|
2061
|
+
default_theme(port(redo), [bold, fg(yellow)]).
|
|
2062
|
+
default_theme(port(unify), [bold, fg(blue)]).
|
|
2063
|
+
default_theme(port(exception), [bold, fg(magenta)]).
|
|
2064
|
+
default_theme(message(informational), [fg(green)]).
|
|
2065
|
+
default_theme(message(information), [fg(green)]).
|
|
2066
|
+
default_theme(message(debug(_)), [fg(blue)]).
|
|
2067
|
+
default_theme(message(Level), Attrs) :-
|
|
2068
|
+
nonvar(Level),
|
|
2069
|
+
default_theme(Level, Attrs).
|
|
2070
|
+
|
|
2071
|
+
|
|
2072
|
+
/*******************************
|
|
2073
|
+
* PRINTING MESSAGES *
|
|
2074
|
+
*******************************/
|
|
2075
|
+
|
|
2076
|
+
:- multifile
|
|
2077
|
+
user:message_hook/3,
|
|
2078
|
+
prolog:message_prefix_hook/2.
|
|
2079
|
+
:- dynamic
|
|
2080
|
+
user:message_hook/3,
|
|
2081
|
+
prolog:message_prefix_hook/2.
|
|
2082
|
+
:- thread_local
|
|
2083
|
+
user:thread_message_hook/3.
|
|
2084
|
+
:- '$notransact'((user:message_hook/3,
|
|
2085
|
+
prolog:message_prefix_hook/2,
|
|
2086
|
+
user:thread_message_hook/3)).
|
|
2087
|
+
|
|
2088
|
+
%! print_message(+Kind, +Term)
|
|
2089
|
+
%
|
|
2090
|
+
% Print an error message using a term as generated by the exception
|
|
2091
|
+
% system.
|
|
2092
|
+
|
|
2093
|
+
print_message(Level, _Term) :-
|
|
2094
|
+
msg_property(Level, stream(S)),
|
|
2095
|
+
stream_property(S, error(true)),
|
|
2096
|
+
!.
|
|
2097
|
+
print_message(Level, Term) :-
|
|
2098
|
+
setup_call_cleanup(
|
|
2099
|
+
notrace(push_msg(Term, Stack)),
|
|
2100
|
+
ignore(print_message_guarded(Level, Term)),
|
|
2101
|
+
notrace(pop_msg(Stack))),
|
|
2102
|
+
!.
|
|
2103
|
+
print_message(Level, Term) :-
|
|
2104
|
+
( Level \== silent
|
|
2105
|
+
-> format(user_error, 'Recursive ~w message: ~q~n', [Level, Term]),
|
|
2106
|
+
autoload_call(backtrace(20))
|
|
2107
|
+
; true
|
|
2108
|
+
).
|
|
2109
|
+
|
|
2110
|
+
push_msg(Term, Messages) :-
|
|
2111
|
+
nb_current('$inprint_message', Messages),
|
|
2112
|
+
!,
|
|
2113
|
+
\+ ( '$member'(Msg, Messages),
|
|
2114
|
+
Msg =@= Term
|
|
2115
|
+
),
|
|
2116
|
+
Stack = [Term|Messages],
|
|
2117
|
+
b_setval('$inprint_message', Stack).
|
|
2118
|
+
push_msg(Term, []) :-
|
|
2119
|
+
b_setval('$inprint_message', [Term]).
|
|
2120
|
+
|
|
2121
|
+
pop_msg(Stack) :-
|
|
2122
|
+
nb_delete('$inprint_message'), % delete history
|
|
2123
|
+
b_setval('$inprint_message', Stack).
|
|
2124
|
+
|
|
2125
|
+
print_message_guarded(Level, Term) :-
|
|
2126
|
+
( must_print(Level, Term)
|
|
2127
|
+
-> ( prolog:message_action(Term, Level),
|
|
2128
|
+
fail % forall/2 is cleaner, but not yet
|
|
2129
|
+
; true % defined
|
|
2130
|
+
),
|
|
2131
|
+
( translate_message(Term, Lines, [])
|
|
2132
|
+
-> ( nonvar(Term),
|
|
2133
|
+
( notrace(user:thread_message_hook(Term, Level, Lines))
|
|
2134
|
+
-> true
|
|
2135
|
+
; notrace(user:message_hook(Term, Level, Lines))
|
|
2136
|
+
)
|
|
2137
|
+
-> true
|
|
2138
|
+
; '$inc_message_count'(Level),
|
|
2139
|
+
print_system_message(Term, Level, Lines),
|
|
2140
|
+
maybe_halt_on_error(Level)
|
|
2141
|
+
)
|
|
2142
|
+
)
|
|
2143
|
+
; true
|
|
2144
|
+
).
|
|
2145
|
+
|
|
2146
|
+
maybe_halt_on_error(error) :-
|
|
2147
|
+
current_prolog_flag(on_error, halt),
|
|
2148
|
+
!,
|
|
2149
|
+
halt(1).
|
|
2150
|
+
maybe_halt_on_error(warning) :-
|
|
2151
|
+
current_prolog_flag(on_warning, halt),
|
|
2152
|
+
!,
|
|
2153
|
+
halt(1).
|
|
2154
|
+
maybe_halt_on_error(_).
|
|
2155
|
+
|
|
2156
|
+
|
|
2157
|
+
%! print_system_message(+Term, +Kind, +Lines)
|
|
2158
|
+
%
|
|
2159
|
+
% Print the message if the user did not intecept the message.
|
|
2160
|
+
% The first is used for errors and warnings that can be related
|
|
2161
|
+
% to source-location. Note that syntax errors have their own
|
|
2162
|
+
% source-location and should therefore not be handled this way.
|
|
2163
|
+
|
|
2164
|
+
print_system_message(_, silent, _) :- !.
|
|
2165
|
+
print_system_message(_, informational, _) :-
|
|
2166
|
+
current_prolog_flag(verbose, silent),
|
|
2167
|
+
!.
|
|
2168
|
+
print_system_message(_, banner, _) :-
|
|
2169
|
+
current_prolog_flag(verbose, silent),
|
|
2170
|
+
!.
|
|
2171
|
+
print_system_message(_, _, []) :- !.
|
|
2172
|
+
print_system_message(Term, Kind, Lines) :-
|
|
2173
|
+
catch(flush_output(user_output), _, true), % may not exist
|
|
2174
|
+
source_location(File, Line),
|
|
2175
|
+
Term \= error(syntax_error(_), _),
|
|
2176
|
+
msg_property(Kind, location_prefix(File:Line, LocPrefix, LinePrefix)),
|
|
2177
|
+
!,
|
|
2178
|
+
to_list(LocPrefix, LocPrefixL),
|
|
2179
|
+
insert_prefix(Lines, LinePrefix, Ctx, PrefixLines),
|
|
2180
|
+
'$append'([ [begin(Kind, Ctx)],
|
|
2181
|
+
LocPrefixL,
|
|
2182
|
+
[nl],
|
|
2183
|
+
PrefixLines,
|
|
2184
|
+
[end(Ctx)]
|
|
2185
|
+
],
|
|
2186
|
+
AllLines),
|
|
2187
|
+
msg_property(Kind, stream(Stream)),
|
|
2188
|
+
ignore(stream_property(Stream, position(Pos))),
|
|
2189
|
+
print_message_lines(Stream, AllLines),
|
|
2190
|
+
( \+ stream_property(Stream, position(Pos)),
|
|
2191
|
+
msg_property(Kind, wait(Wait)),
|
|
2192
|
+
Wait > 0
|
|
2193
|
+
-> sleep(Wait)
|
|
2194
|
+
; true
|
|
2195
|
+
).
|
|
2196
|
+
print_system_message(_, Kind, Lines) :-
|
|
2197
|
+
msg_property(Kind, stream(Stream)),
|
|
2198
|
+
print_message_lines(Stream, kind(Kind), Lines).
|
|
2199
|
+
|
|
2200
|
+
to_list(ListIn, List) :-
|
|
2201
|
+
is_list(ListIn),
|
|
2202
|
+
!,
|
|
2203
|
+
List = ListIn.
|
|
2204
|
+
to_list(NonList, [NonList]).
|
|
2205
|
+
|
|
2206
|
+
:- multifile
|
|
2207
|
+
user:message_property/2.
|
|
2208
|
+
|
|
2209
|
+
msg_property(Kind, Property) :-
|
|
2210
|
+
notrace(user:message_property(Kind, Property)),
|
|
2211
|
+
!.
|
|
2212
|
+
msg_property(Kind, prefix(Prefix)) :-
|
|
2213
|
+
msg_prefix(Kind, Prefix),
|
|
2214
|
+
!.
|
|
2215
|
+
msg_property(_, prefix('~N')) :- !.
|
|
2216
|
+
msg_property(query, stream(user_output)) :- !.
|
|
2217
|
+
msg_property(_, stream(user_error)) :- !.
|
|
2218
|
+
msg_property(error, tag('ERROR')).
|
|
2219
|
+
msg_property(warning, tag('Warning')).
|
|
2220
|
+
msg_property(Level,
|
|
2221
|
+
location_prefix(File:Line,
|
|
2222
|
+
['~N~w: '-[Tag], url(File:Line), ':'],
|
|
2223
|
+
'~N~w: '-[Tag])) :-
|
|
2224
|
+
include_msg_location(Level),
|
|
2225
|
+
msg_property(Level, tag(Tag)).
|
|
2226
|
+
msg_property(error, wait(0.1)) :- !.
|
|
2227
|
+
|
|
2228
|
+
include_msg_location(warning).
|
|
2229
|
+
include_msg_location(error).
|
|
2230
|
+
|
|
2231
|
+
msg_prefix(debug(_), Prefix) :-
|
|
2232
|
+
msg_context('~N% ', Prefix).
|
|
2233
|
+
msg_prefix(Level, Prefix) :-
|
|
2234
|
+
msg_property(Level, tag(Tag)),
|
|
2235
|
+
atomics_to_string(['~N', Tag, ': '], Prefix0),
|
|
2236
|
+
msg_context(Prefix0, Prefix).
|
|
2237
|
+
msg_prefix(informational, '~N% ').
|
|
2238
|
+
msg_prefix(information, '~N% ').
|
|
2239
|
+
|
|
2240
|
+
%! msg_context(+Prefix0, -Prefix) is det.
|
|
2241
|
+
%
|
|
2242
|
+
% Add contextual information to a message. This uses the Prolog flag
|
|
2243
|
+
% `message_context`. Recognised context terms are:
|
|
2244
|
+
%
|
|
2245
|
+
% - time
|
|
2246
|
+
% - time(Format)
|
|
2247
|
+
% - thread
|
|
2248
|
+
%
|
|
2249
|
+
% In addition, the hook prolog:message_prefix_hook/2 is called that
|
|
2250
|
+
% allows for additional context information.
|
|
2251
|
+
|
|
2252
|
+
msg_context(Prefix0, Prefix) :-
|
|
2253
|
+
current_prolog_flag(message_context, Context),
|
|
2254
|
+
is_list(Context),
|
|
2255
|
+
!,
|
|
2256
|
+
add_message_context(Context, Prefix0, Prefix).
|
|
2257
|
+
msg_context(Prefix, Prefix).
|
|
2258
|
+
|
|
2259
|
+
add_message_context([], Prefix, Prefix).
|
|
2260
|
+
add_message_context([H|T], Prefix0, Prefix) :-
|
|
2261
|
+
( add_message_context1(H, Prefix0, Prefix1)
|
|
2262
|
+
-> true
|
|
2263
|
+
; Prefix1 = Prefix0
|
|
2264
|
+
),
|
|
2265
|
+
add_message_context(T, Prefix1, Prefix).
|
|
2266
|
+
|
|
2267
|
+
add_message_context1(Context, Prefix0, Prefix) :-
|
|
2268
|
+
prolog:message_prefix_hook(Context, Extra),
|
|
2269
|
+
atomics_to_string([Prefix0, Extra, ' '], Prefix).
|
|
2270
|
+
add_message_context1(time, Prefix0, Prefix) :-
|
|
2271
|
+
get_time(Now),
|
|
2272
|
+
format_time(string(S), '%T.%3f ', Now),
|
|
2273
|
+
string_concat(Prefix0, S, Prefix).
|
|
2274
|
+
add_message_context1(time(Format), Prefix0, Prefix) :-
|
|
2275
|
+
get_time(Now),
|
|
2276
|
+
format_time(string(S), Format, Now),
|
|
2277
|
+
atomics_to_string([Prefix0, S, ' '], Prefix).
|
|
2278
|
+
add_message_context1(thread, Prefix0, Prefix) :-
|
|
2279
|
+
\+ current_prolog_flag(toplevel_thread, true),
|
|
2280
|
+
thread_self(Id0),
|
|
2281
|
+
!,
|
|
2282
|
+
( atom(Id0)
|
|
2283
|
+
-> Id = Id0
|
|
2284
|
+
; thread_property(Id0, id(Id))
|
|
2285
|
+
),
|
|
2286
|
+
format(string(Prefix), '~w[Thread ~w] ', [Prefix0, Id]).
|
|
2287
|
+
|
|
2288
|
+
%! print_message_lines(+Stream, +PrefixOrKind, +Lines)
|
|
2289
|
+
%
|
|
2290
|
+
% Quintus compatibility predicate to print message lines using
|
|
2291
|
+
% a prefix.
|
|
2292
|
+
|
|
2293
|
+
print_message_lines(Stream, kind(Kind), Lines) :-
|
|
2294
|
+
!,
|
|
2295
|
+
msg_property(Kind, prefix(Prefix)),
|
|
2296
|
+
insert_prefix(Lines, Prefix, Ctx, PrefixLines),
|
|
2297
|
+
'$append'([ begin(Kind, Ctx)
|
|
2298
|
+
| PrefixLines
|
|
2299
|
+
],
|
|
2300
|
+
[ end(Ctx)
|
|
2301
|
+
],
|
|
2302
|
+
AllLines),
|
|
2303
|
+
print_message_lines(Stream, AllLines).
|
|
2304
|
+
print_message_lines(Stream, Prefix, Lines) :-
|
|
2305
|
+
insert_prefix(Lines, Prefix, _, PrefixLines),
|
|
2306
|
+
print_message_lines(Stream, PrefixLines).
|
|
2307
|
+
|
|
2308
|
+
%! insert_prefix(+Lines, +Prefix, +Ctx, -PrefixedLines)
|
|
2309
|
+
|
|
2310
|
+
insert_prefix([at_same_line|Lines0], Prefix, Ctx, Lines) :-
|
|
2311
|
+
!,
|
|
2312
|
+
prefix_nl(Lines0, Prefix, Ctx, Lines).
|
|
2313
|
+
insert_prefix(Lines0, Prefix, Ctx, [prefix(Prefix)|Lines]) :-
|
|
2314
|
+
prefix_nl(Lines0, Prefix, Ctx, Lines).
|
|
2315
|
+
|
|
2316
|
+
prefix_nl([], _, _, [nl]).
|
|
2317
|
+
prefix_nl([nl], _, _, [nl]) :- !.
|
|
2318
|
+
prefix_nl([flush], _, _, [flush]) :- !.
|
|
2319
|
+
prefix_nl([nl|T0], Prefix, Ctx, [nl, prefix(Prefix)|T]) :-
|
|
2320
|
+
!,
|
|
2321
|
+
prefix_nl(T0, Prefix, Ctx, T).
|
|
2322
|
+
prefix_nl([ansi(Attrs,Fmt,Args)|T0], Prefix, Ctx,
|
|
2323
|
+
[ansi(Attrs,Fmt,Args,Ctx)|T]) :-
|
|
2324
|
+
!,
|
|
2325
|
+
prefix_nl(T0, Prefix, Ctx, T).
|
|
2326
|
+
prefix_nl([H|T0], Prefix, Ctx, [H|T]) :-
|
|
2327
|
+
prefix_nl(T0, Prefix, Ctx, T).
|
|
2328
|
+
|
|
2329
|
+
%! print_message_lines(+Stream, +Lines)
|
|
2330
|
+
|
|
2331
|
+
print_message_lines(Stream, Lines) :-
|
|
2332
|
+
with_output_to(
|
|
2333
|
+
Stream,
|
|
2334
|
+
notrace(print_message_lines_guarded(current_output, Lines))).
|
|
2335
|
+
|
|
2336
|
+
print_message_lines_guarded(_, []) :- !.
|
|
2337
|
+
print_message_lines_guarded(S, [H|T]) :-
|
|
2338
|
+
line_element(S, H),
|
|
2339
|
+
print_message_lines_guarded(S, T).
|
|
2340
|
+
|
|
2341
|
+
line_element(S, E) :-
|
|
2342
|
+
prolog:message_line_element(S, E),
|
|
2343
|
+
!.
|
|
2344
|
+
line_element(S, full_stop) :-
|
|
2345
|
+
!,
|
|
2346
|
+
'$put_token'(S, '.'). % insert space if needed.
|
|
2347
|
+
line_element(S, nl) :-
|
|
2348
|
+
!,
|
|
2349
|
+
nl(S).
|
|
2350
|
+
line_element(S, prefix(Fmt-Args)) :-
|
|
2351
|
+
!,
|
|
2352
|
+
safe_format(S, Fmt, Args).
|
|
2353
|
+
line_element(S, prefix(Fmt)) :-
|
|
2354
|
+
!,
|
|
2355
|
+
safe_format(S, Fmt, []).
|
|
2356
|
+
line_element(S, flush) :-
|
|
2357
|
+
!,
|
|
2358
|
+
flush_output(S).
|
|
2359
|
+
line_element(S, Fmt-Args) :-
|
|
2360
|
+
!,
|
|
2361
|
+
safe_format(S, Fmt, Args).
|
|
2362
|
+
line_element(S, ansi(_, Fmt, Args)) :-
|
|
2363
|
+
!,
|
|
2364
|
+
safe_format(S, Fmt, Args).
|
|
2365
|
+
line_element(S, ansi(_, Fmt, Args, _Ctx)) :-
|
|
2366
|
+
!,
|
|
2367
|
+
safe_format(S, Fmt, Args).
|
|
2368
|
+
line_element(S, url(URL)) :-
|
|
2369
|
+
!,
|
|
2370
|
+
print_link(S, URL).
|
|
2371
|
+
line_element(S, url(_URL, Fmt-Args)) :-
|
|
2372
|
+
!,
|
|
2373
|
+
safe_format(S, Fmt, Args).
|
|
2374
|
+
line_element(S, url(_URL, Fmt)) :-
|
|
2375
|
+
!,
|
|
2376
|
+
safe_format(S, Fmt, []).
|
|
2377
|
+
line_element(_, begin(_Level, _Ctx)) :- !.
|
|
2378
|
+
line_element(_, end(_Ctx)) :- !.
|
|
2379
|
+
line_element(S, Fmt) :-
|
|
2380
|
+
safe_format(S, Fmt, []).
|
|
2381
|
+
|
|
2382
|
+
print_link(S, File:Line:Column) :-
|
|
2383
|
+
!,
|
|
2384
|
+
safe_format(S, '~w:~d:~d', [File, Line, Column]).
|
|
2385
|
+
print_link(S, File:Line) :-
|
|
2386
|
+
!,
|
|
2387
|
+
safe_format(S, '~w:~d', [File, Line]).
|
|
2388
|
+
print_link(S, File) :-
|
|
2389
|
+
safe_format(S, '~w', [File]).
|
|
2390
|
+
|
|
2391
|
+
%! safe_format(+Stream, +Format, +Args) is det.
|
|
2392
|
+
|
|
2393
|
+
safe_format(S, Fmt, Args) :-
|
|
2394
|
+
E = error(_,_),
|
|
2395
|
+
catch(format(S,Fmt,Args), E,
|
|
2396
|
+
format_failed(S,Fmt,Args,E)).
|
|
2397
|
+
|
|
2398
|
+
format_failed(S, _Fmt, _Args, E) :-
|
|
2399
|
+
stream_property(S, error(true)),
|
|
2400
|
+
!,
|
|
2401
|
+
throw(E).
|
|
2402
|
+
format_failed(S, Fmt, Args, error(E,_)) :-
|
|
2403
|
+
format(S, '~N [[ EXCEPTION while printing message ~q~n\c
|
|
2404
|
+
~7|with arguments ~W:~n\c
|
|
2405
|
+
~7|raised: ~W~n~4|]]~n',
|
|
2406
|
+
[ Fmt,
|
|
2407
|
+
Args, [quoted(true), max_depth(10)],
|
|
2408
|
+
E, [quoted(true), max_depth(10)]
|
|
2409
|
+
]).
|
|
2410
|
+
|
|
2411
|
+
%! message_to_string(+Term, -String)
|
|
2412
|
+
%
|
|
2413
|
+
% Translate an error term into a string
|
|
2414
|
+
|
|
2415
|
+
message_to_string(Term, Str) :-
|
|
2416
|
+
translate_message(Term, Actions, []),
|
|
2417
|
+
!,
|
|
2418
|
+
actions_to_format(Actions, Fmt, Args),
|
|
2419
|
+
format(string(Str), Fmt, Args).
|
|
2420
|
+
|
|
2421
|
+
actions_to_format([], '', []) :- !.
|
|
2422
|
+
actions_to_format([nl], '', []) :- !.
|
|
2423
|
+
actions_to_format([Term, nl], Fmt, Args) :-
|
|
2424
|
+
!,
|
|
2425
|
+
actions_to_format([Term], Fmt, Args).
|
|
2426
|
+
actions_to_format([nl|T], Fmt, Args) :-
|
|
2427
|
+
!,
|
|
2428
|
+
actions_to_format(T, Fmt0, Args),
|
|
2429
|
+
atom_concat('~n', Fmt0, Fmt).
|
|
2430
|
+
actions_to_format([ansi(_Attrs, Fmt0, Args0)|Tail], Fmt, Args) :-
|
|
2431
|
+
!,
|
|
2432
|
+
actions_to_format(Tail, Fmt1, Args1),
|
|
2433
|
+
atom_concat(Fmt0, Fmt1, Fmt),
|
|
2434
|
+
append_args(Args0, Args1, Args).
|
|
2435
|
+
actions_to_format([url(Pos)|Tail], Fmt, Args) :-
|
|
2436
|
+
!,
|
|
2437
|
+
actions_to_format(Tail, Fmt1, Args1),
|
|
2438
|
+
url_actions_to_format(url(Pos), Fmt1, Args1, Fmt, Args).
|
|
2439
|
+
actions_to_format([url(URL, Label)|Tail], Fmt, Args) :-
|
|
2440
|
+
!,
|
|
2441
|
+
actions_to_format(Tail, Fmt1, Args1),
|
|
2442
|
+
url_actions_to_format(url(URL, Label), Fmt1, Args1, Fmt, Args).
|
|
2443
|
+
actions_to_format([Fmt0-Args0|Tail], Fmt, Args) :-
|
|
2444
|
+
!,
|
|
2445
|
+
actions_to_format(Tail, Fmt1, Args1),
|
|
2446
|
+
atom_concat(Fmt0, Fmt1, Fmt),
|
|
2447
|
+
append_args(Args0, Args1, Args).
|
|
2448
|
+
actions_to_format([Skip|T], Fmt, Args) :-
|
|
2449
|
+
action_skip(Skip),
|
|
2450
|
+
!,
|
|
2451
|
+
actions_to_format(T, Fmt, Args).
|
|
2452
|
+
actions_to_format([Term|Tail], Fmt, Args) :-
|
|
2453
|
+
atomic(Term),
|
|
2454
|
+
!,
|
|
2455
|
+
actions_to_format(Tail, Fmt1, Args),
|
|
2456
|
+
atom_concat(Term, Fmt1, Fmt).
|
|
2457
|
+
actions_to_format([Term|Tail], Fmt, Args) :-
|
|
2458
|
+
actions_to_format(Tail, Fmt1, Args1),
|
|
2459
|
+
atom_concat('~w', Fmt1, Fmt),
|
|
2460
|
+
append_args([Term], Args1, Args).
|
|
2461
|
+
|
|
2462
|
+
action_skip(at_same_line).
|
|
2463
|
+
action_skip(flush).
|
|
2464
|
+
action_skip(begin(_Level, _Ctx)).
|
|
2465
|
+
action_skip(end(_Ctx)).
|
|
2466
|
+
|
|
2467
|
+
url_actions_to_format(url(File:Line:Column), Fmt1, Args1, Fmt, Args) :-
|
|
2468
|
+
!,
|
|
2469
|
+
atom_concat('~w:~d:~d', Fmt1, Fmt),
|
|
2470
|
+
append_args([File,Line,Column], Args1, Args).
|
|
2471
|
+
url_actions_to_format(url(File:Line), Fmt1, Args1, Fmt, Args) :-
|
|
2472
|
+
!,
|
|
2473
|
+
atom_concat('~w:~d', Fmt1, Fmt),
|
|
2474
|
+
append_args([File,Line], Args1, Args).
|
|
2475
|
+
url_actions_to_format(url(File), Fmt1, Args1, Fmt, Args) :-
|
|
2476
|
+
!,
|
|
2477
|
+
atom_concat('~w', Fmt1, Fmt),
|
|
2478
|
+
append_args([File], Args1, Args).
|
|
2479
|
+
url_actions_to_format(url(_URL, Label), Fmt1, Args1, Fmt, Args) :-
|
|
2480
|
+
!,
|
|
2481
|
+
atom_concat('~w', Fmt1, Fmt),
|
|
2482
|
+
append_args([Label], Args1, Args).
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
append_args(M:Args0, Args1, M:Args) :-
|
|
2486
|
+
!,
|
|
2487
|
+
strip_module(Args1, _, A1),
|
|
2488
|
+
to_list(Args0, Args01),
|
|
2489
|
+
'$append'(Args01, A1, Args).
|
|
2490
|
+
append_args(Args0, Args1, Args) :-
|
|
2491
|
+
strip_module(Args1, _, A1),
|
|
2492
|
+
to_list(Args0, Args01),
|
|
2493
|
+
'$append'(Args01, A1, Args).
|
|
2494
|
+
|
|
2495
|
+
/*******************************
|
|
2496
|
+
* MESSAGES TO PRINT ONCE *
|
|
2497
|
+
*******************************/
|
|
2498
|
+
|
|
2499
|
+
:- dynamic
|
|
2500
|
+
printed/2.
|
|
2501
|
+
|
|
2502
|
+
%! print_once(Message, Level)
|
|
2503
|
+
%
|
|
2504
|
+
% True for messages that must be printed only once.
|
|
2505
|
+
|
|
2506
|
+
print_once(compatibility(_), _).
|
|
2507
|
+
print_once(null_byte_in_path(_), _).
|
|
2508
|
+
print_once(deprecated(_), _).
|
|
2509
|
+
|
|
2510
|
+
%! must_print(+Level, +Message)
|
|
2511
|
+
%
|
|
2512
|
+
% True if the message must be printed.
|
|
2513
|
+
|
|
2514
|
+
must_print(Level, Message) :-
|
|
2515
|
+
nonvar(Message),
|
|
2516
|
+
print_once(Message, Level),
|
|
2517
|
+
!,
|
|
2518
|
+
\+ printed(Message, Level),
|
|
2519
|
+
assert(printed(Message, Level)).
|
|
2520
|
+
must_print(_, _).
|
|
2521
|
+
|