minor fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "scryer-prolog"
|
name = "scryer-prolog"
|
||||||
version = "0.8.54"
|
version = "0.8.55"
|
||||||
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
authors = ["Mark Thom <markjordanthom@gmail.com>"]
|
||||||
repository = "https://github.com/mthom/scryer-prolog"
|
repository = "https://github.com/mthom/scryer-prolog"
|
||||||
description = "A modern Prolog implementation written mostly in Rust."
|
description = "A modern Prolog implementation written mostly in Rust."
|
||||||
|
|||||||
@@ -220,32 +220,28 @@ is_write_option(Functor) :-
|
|||||||
Functor =.. [Name, Arg],
|
Functor =.. [Name, Arg],
|
||||||
( Arg == true -> true
|
( Arg == true -> true
|
||||||
; Arg == false -> true
|
; Arg == false -> true
|
||||||
; throw(error(domain_error(write_option, Functor), write_term/2)) ), % 8.14.2.3 e)
|
; var(Arg) -> throw(error(instantiation_error, write_term/2))
|
||||||
|
; throw(error(domain_error(write_option, Functor), write_term/2))
|
||||||
|
), % 8.14.2.3 e)
|
||||||
( Name == ignore_ops -> true
|
( Name == ignore_ops -> true
|
||||||
; Name == quoted -> true
|
; Name == quoted -> true
|
||||||
; Name == numbervars -> true
|
; Name == numbervars -> true
|
||||||
; throw(error(domain_error(write_option, Functor), write_term/2)) ). % 8.14.2.3 e)
|
; throw(error(domain_error(write_option, Functor), write_term/2))
|
||||||
|
). % 8.14.2.3 e)
|
||||||
|
|
||||||
inst_member_or([X|Xs], Y, _) :-
|
inst_member_or([X|Xs], Y, _) :-
|
||||||
( nonvar(X), is_write_option(X) -> ( Y = X, ! ; inst_member_or(Xs, Y, _) )
|
( var(X) -> throw(error(instantiation_error, write_term/2))
|
||||||
; throw(instantiation_error) ). % 8.14.2.3 b)
|
; is_write_option(X) -> ( Y = X, ! ; inst_member_or(Xs, Y, _) )
|
||||||
|
; throw(error(domain_error(write_option, X), write_term/2))
|
||||||
|
).
|
||||||
inst_member_or([], Y, Y).
|
inst_member_or([], Y, Y).
|
||||||
|
|
||||||
%% TODO: complete the predicate! Most read options are missing.
|
write_term(_, Options) :-
|
||||||
read_term(Term, Options) :-
|
var(Options), throw(error(instantiation_error, write_term/2)).
|
||||||
|
write_term(Term, Options) :-
|
||||||
'$skip_max_list'(_, -1, Options, Options0),
|
'$skip_max_list'(_, -1, Options, Options0),
|
||||||
( Options0 == [] -> true
|
( var(Options0) -> throw(error(instantiation_error, write_term/2))
|
||||||
; var(Options0) -> throw(error(instantiation_error, read_term/2)) % 8.14.1.3 b)
|
; Options0 == [] -> true
|
||||||
; throw(error(type_error(list, Options), read_term/2)) % 8.14.1.3 d)
|
|
||||||
),
|
|
||||||
( Options = [variable_names(VarList)] -> '$read_term'(Term, VarList)
|
|
||||||
; Options = [] -> read(Term)
|
|
||||||
; false
|
|
||||||
).
|
|
||||||
|
|
||||||
write_term(Term, Options) :-
|
|
||||||
'$skip_max_list'(_, -1, Options, Options0),
|
|
||||||
( Options0 == [] -> true
|
|
||||||
; throw(error(type_error(list, Options), write_term/2))
|
; throw(error(type_error(list, Options), write_term/2))
|
||||||
), % 8.14.2.3 c)
|
), % 8.14.2.3 c)
|
||||||
inst_member_or(Options, ignore_ops(IgnoreOps), ignore_ops(false)),
|
inst_member_or(Options, ignore_ops(IgnoreOps), ignore_ops(false)),
|
||||||
@@ -259,6 +255,18 @@ write_canonical(Term) :- write_term(Term, [ignore_ops(true), quoted(true)]).
|
|||||||
|
|
||||||
writeq(Term) :- write_term(Term, [quoted(true), numbervars(true)]).
|
writeq(Term) :- write_term(Term, [quoted(true), numbervars(true)]).
|
||||||
|
|
||||||
|
%% TODO: complete the predicate! Most read options are missing.
|
||||||
|
read_term(Term, Options) :-
|
||||||
|
'$skip_max_list'(_, -1, Options, Options0),
|
||||||
|
( Options0 == [] -> true
|
||||||
|
; var(Options0) -> throw(error(instantiation_error, read_term/2)) % 8.14.1.3 b)
|
||||||
|
; throw(error(type_error(list, Options), read_term/2)) % 8.14.1.3 d)
|
||||||
|
),
|
||||||
|
( Options = [variable_names(VarList)] -> '$read_term'(Term, VarList)
|
||||||
|
; Options = [] -> read(Term)
|
||||||
|
; false
|
||||||
|
).
|
||||||
|
|
||||||
% expand_goal.
|
% expand_goal.
|
||||||
|
|
||||||
expand_goal(Term0, Term) :- '$expand_goal'(Term0, Term).
|
expand_goal(Term0, Term) :- '$expand_goal'(Term0, Term).
|
||||||
@@ -269,9 +277,9 @@ expand_term(Term0, Term) :- '$expand_term'(Term0, Term).
|
|||||||
|
|
||||||
% term_variables.
|
% term_variables.
|
||||||
|
|
||||||
% ensures List is either a variable or a proper list.
|
% ensures List is either a variable or a list.
|
||||||
can_be_list(List, _) :- var(List), !.
|
can_be_list(List, _) :- var(List), !.
|
||||||
can_be_list(List, _) :- '$skip_max_list'(_, -1, List, Tail), Tail == [], !.
|
can_be_list(List, _) :- '$skip_max_list'(_, -1, List, Tail), ( var(Tail) -> true ; Tail == []), !.
|
||||||
can_be_list(List, PI) :- throw(error(type_error(list, List), PI)).
|
can_be_list(List, PI) :- throw(error(type_error(list, List), PI)).
|
||||||
|
|
||||||
term_variables(Term, Vars) :-
|
term_variables(Term, Vars) :-
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ macro_rules! return_from_clause {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if $lco {
|
if $lco {
|
||||||
$machine_st.p = CodePtr::Local($machine_st.cp.clone());
|
$machine_st.p = CodePtr::Local($machine_st.cp);
|
||||||
} else {
|
} else {
|
||||||
$machine_st.p += 1;
|
$machine_st.p += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user