Scryer Prolog is implemented in Rust (64%) and Prolog (36%).
To install, enter the following commands:
git clone https://github.com/mthom/scryer-prolog
cd scryer-prolog
curl https://sh.rustup.rs -sSf | sh # if cargo is not yet installed
cargo build --release
This creates the executable file target/release/scryer-prolog
.
Define an alias like scryerp
or just scry
to make this easier to run.
To update your version of Scryer Prolog:
git pull
cargo build --release
To start a Scryer Prolog top level from a terminal, enter scry
.
By default, Scryer Prolog only provides built-in predicates
that are defined in the ISO standard.
But it bundles many libraries that define non-ISO predicates that can
easily be made available with :- use_module(library(library-name)).
To specify configuration for all top level sessions,
create the file $HOME/.scryerrc
.
This file often imports commonly used libraries.
For example:
:- use_module(library(clpz)).
:- use_module(library(dcgs)).
:- use_module(library(format)).
:- use_module(library(lists)).
There is currently an {% aTargetBlank
"https://github.com/mthom/scryer-prolog/issues/1775", "issue" %}
where operators defined in modules that are loaded in .scryerrc
are not available in source files passed to the Scryer interpreter.
A workaround is to explicitly load the module in the source file
with :- use_module(library(library-name)).
After entering a query, press "h" to get the following help:
SPACE, "n" or ";": next solution, if any
RETURN or ".": stop enumeration
"a": enumerate all solutions
"f": enumerate the next 5 solutions
"h": display this help message
"w": write terms without depth limit
"p": print terms with depth limit
The following list describes some of the most commonly seen
error messages that are output by Scryer Prolog.
Warning: singleton variable Name at line N of file-name.pl.
This means that the variable Name
either:
error(existence_error(source_sink,"file-name.pl"),open/4).
This error occurs when Scryer Prolog is started with a file path
and the file is not found.
error(syntax_error(inconsistent_entry),load/1).
This error can occur when there is a typo in a compiler directive.
error(permission_error(access,private_procedure,module_does_not_contain_claimed_export),load/1).
This error means that a module is being defined and the list of exports
contains a functor that is not defined in the file.
Sadly, the error does not indicate which function is undefined.
error(permission_error(modify,static_procedure,(',')/2),load/1).
This error means that the source file contains a term with invalid syntax.
Often the cause is a rule body that contains a goal which is
not the last goal and is terminated by a period instead of a comma.
error(syntax_error(incomplete_reduction),read_term/3:line-number).
This error means that the source file contains a term with invalid syntax.
Often the cause is
a rule body whose last goal is terminated by a comma instead of a period or
a rule body goal that is not the last one and is not followed by a comma.
This error can also occur when a goal uses a non-built-in operator
that has not been loaded.
For example, using the #=
requires loading the clpz
library.
error(type_error(list,6),must_be/2).
This error can occur when a predicate argument is
expected to be a list, but is some other type.
For example, this happens when the second argument to format
is not a list.
Last modified 27 November 2024