revert throwing domain errors for unexpected forms of read-options (#2015)
This commit is contained in:
@@ -124,7 +124,7 @@ call(_, _, _, _, _, _, _, _, _).
|
|||||||
% while others can be set with `set_prolog_flag/2`.
|
% while others can be set with `set_prolog_flag/2`.
|
||||||
%
|
%
|
||||||
% The flags that Scryer Prolog support are:
|
% The flags that Scryer Prolog support are:
|
||||||
%
|
%
|
||||||
% * `max_arity`: The max arity a predicate can have in Prolog. On Scryer is set to 1023. Read only.
|
% * `max_arity`: The max arity a predicate can have in Prolog. On Scryer is set to 1023. Read only.
|
||||||
% * `bounded`: `true` if integer arithmethic is bounded between some min/max values. On Scryer is always set
|
% * `bounded`: `true` if integer arithmethic is bounded between some min/max values. On Scryer is always set
|
||||||
% to `false` since it supports unbounded integer arithmethic. Read only.
|
% to `false` since it supports unbounded integer arithmethic. Read only.
|
||||||
@@ -184,7 +184,7 @@ answer_write_options(Value) :-
|
|||||||
%% set_prolog_flag(Flag, Value).
|
%% set_prolog_flag(Flag, Value).
|
||||||
%
|
%
|
||||||
% Sets the internal value of the flag. To see the list of flags supported by Scryer Prolog,
|
% Sets the internal value of the flag. To see the list of flags supported by Scryer Prolog,
|
||||||
% check `current_prolog_flag/2`. The flags that are read only will fail if you try to change their values
|
% check `current_prolog_flag/2`. The flags that are read only will fail if you try to change their values
|
||||||
set_prolog_flag(Flag, Value) :-
|
set_prolog_flag(Flag, Value) :-
|
||||||
(var(Flag) ; var(Value)),
|
(var(Flag) ; var(Value)),
|
||||||
throw(error(instantiation_error, set_prolog_flag/2)). % 8.17.1.3 a, b
|
throw(error(instantiation_error, set_prolog_flag/2)). % 8.17.1.3 a, b
|
||||||
@@ -721,30 +721,9 @@ parse_read_term_options(Options, OptionValues, Stub) :-
|
|||||||
parse_options_list(Options, builtins:parse_read_term_options_, DefaultOptions, OptionValues, Stub).
|
parse_options_list(Options, builtins:parse_read_term_options_, DefaultOptions, OptionValues, Stub).
|
||||||
|
|
||||||
|
|
||||||
parse_read_term_options_(singletons(Vars), singletons-Vars) :-
|
parse_read_term_options_(singletons(Vars), singletons-Vars) :- !.
|
||||||
( ( var(Vars)
|
parse_read_term_options_(variables(Vars), variables-Vars) :- !.
|
||||||
; '$skip_max_list'(_, _, Vars, Rs),
|
parse_read_term_options_(variable_names(Vars), variable_names-Vars) :- !.
|
||||||
Rs == []
|
|
||||||
) ->
|
|
||||||
!
|
|
||||||
; throw(error(domain_error(read_option, singletons(Vars)), read_term/2))
|
|
||||||
).
|
|
||||||
parse_read_term_options_(variables(Vars), variables-Vars) :-
|
|
||||||
( ( var(Vars)
|
|
||||||
; '$skip_max_list'(_, _, Vars, Rs),
|
|
||||||
Rs == []
|
|
||||||
) ->
|
|
||||||
!
|
|
||||||
; throw(error(domain_error(read_option, variables(Vars)), read_term/2))
|
|
||||||
).
|
|
||||||
parse_read_term_options_(variable_names(Vars), variable_names-Vars) :-
|
|
||||||
( ( var(Vars)
|
|
||||||
; '$skip_max_list'(_, _, Vars, Rs),
|
|
||||||
Rs == []
|
|
||||||
) ->
|
|
||||||
!
|
|
||||||
; throw(error(domain_error(read_option, variable_names(Vars)), read_term/2))
|
|
||||||
).
|
|
||||||
parse_read_term_options_(E,_) :-
|
parse_read_term_options_(E,_) :-
|
||||||
throw(error(domain_error(read_option, E), _)).
|
throw(error(domain_error(read_option, E), _)).
|
||||||
|
|
||||||
@@ -754,7 +733,7 @@ parse_read_term_options_(E,_) :-
|
|||||||
% Read Term from the stream Stream. It supports several options:
|
% Read Term from the stream Stream. It supports several options:
|
||||||
% * `variables(-Vars)` unifies Vars with a list of variables in the term. Similar to do `term_variables/2` with the new term.
|
% * `variables(-Vars)` unifies Vars with a list of variables in the term. Similar to do `term_variables/2` with the new term.
|
||||||
% * `variable_names(-Vars)` unifies Vars with a list `Name=Var` with Name describing the variable name and Var the variable itself that appears in Term.
|
% * `variable_names(-Vars)` unifies Vars with a list `Name=Var` with Name describing the variable name and Var the variable itself that appears in Term.
|
||||||
% * `singletons` similar to `variable_names` but only reports variables occurring only once in Term.
|
% * `singletons` similar to `variable_names` but only reports variables occurring only once in Term.
|
||||||
read_term(Stream, Term, Options) :-
|
read_term(Stream, Term, Options) :-
|
||||||
parse_read_term_options(Options, [Singletons, VariableNames, Variables], read_term/3),
|
parse_read_term_options(Options, [Singletons, VariableNames, Variables], read_term/3),
|
||||||
'$read_term'(Stream, Term, Singletons, Variables, VariableNames).
|
'$read_term'(Stream, Term, Singletons, Variables, VariableNames).
|
||||||
@@ -1622,7 +1601,7 @@ atom_concat(Atom_1, Atom_2, Atom_12) :-
|
|||||||
%% sub_atom(+Atom, ?Before, ?Length, ?After, ?SubAtom).
|
%% sub_atom(+Atom, ?Before, ?Length, ?After, ?SubAtom).
|
||||||
%
|
%
|
||||||
% Relates an atom to a subatom inside with some key properties:
|
% Relates an atom to a subatom inside with some key properties:
|
||||||
%
|
%
|
||||||
% * SubAtom starts at Before characters (0-based) from Atom
|
% * SubAtom starts at Before characters (0-based) from Atom
|
||||||
% * SubAtom has Length characters
|
% * SubAtom has Length characters
|
||||||
% * After SubAtom there are After characters in Atom
|
% * After SubAtom there are After characters in Atom
|
||||||
|
|||||||
Reference in New Issue
Block a user