Merge branch 'master' into library-use-case
This commit is contained in:
@@ -20,6 +20,7 @@ read and write chars.
|
|||||||
:- use_module(library(iso_ext)).
|
:- use_module(library(iso_ext)).
|
||||||
:- use_module(library(error)).
|
:- use_module(library(error)).
|
||||||
:- use_module(library(lists)).
|
:- use_module(library(lists)).
|
||||||
|
:- use_module(library(between)).
|
||||||
:- use_module(library(iso_ext), [partial_string/1,partial_string/3]).
|
:- use_module(library(iso_ext), [partial_string/1,partial_string/3]).
|
||||||
|
|
||||||
fabricate_var_name(VarType, VarName, N) :-
|
fabricate_var_name(VarType, VarName, N) :-
|
||||||
@@ -74,9 +75,10 @@ extend_var_list_([V|Vs], N, VarList, NewVarList, VarType) :-
|
|||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
%% char_type(+Char, -Type).
|
%% char_type(?Char, ?Type).
|
||||||
%
|
%
|
||||||
% Given a Char, Type is one of the categories that char fits in.
|
% Type is one of the categories that Char fits in.
|
||||||
|
% At least one of the arguments must be ground.
|
||||||
% Possible categories are:
|
% Possible categories are:
|
||||||
%
|
%
|
||||||
% - `alnum`
|
% - `alnum`
|
||||||
@@ -132,17 +134,32 @@ extend_var_list_([V|Vs], N, VarList, NewVarList, VarType) :-
|
|||||||
% Note that uppercase and lowercase transformations use a string. This is because
|
% Note that uppercase and lowercase transformations use a string. This is because
|
||||||
% some characters do not map 1:1 between lowercase and uppercase.
|
% some characters do not map 1:1 between lowercase and uppercase.
|
||||||
char_type(Char, Type) :-
|
char_type(Char, Type) :-
|
||||||
must_be(character, Char),
|
can_be(character, Char),
|
||||||
( ground(Type) ->
|
( \+ ctype(Type) ->
|
||||||
( ctype(Type) ->
|
domain_error(char_type, Type, char_type/2)
|
||||||
'$char_type'(Char, Type)
|
; true
|
||||||
; domain_error(char_type, Type, char_type/2)
|
),
|
||||||
)
|
( ground(Char) ->
|
||||||
; ctype(Type),
|
ctype(Type),
|
||||||
'$char_type'(Char, Type)
|
'$char_type'(Char, Type)
|
||||||
|
; ground(Type) ->
|
||||||
|
max_char_code(Max),
|
||||||
|
between(0, Max, Code),
|
||||||
|
char_code(Char, Code),
|
||||||
|
'$char_type'(Char, Type)
|
||||||
|
; must_be(character, Char)
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
|
max_char_code(Max) :-
|
||||||
|
catch((length(_, Code),
|
||||||
|
catch(char_code(_Char, Code),
|
||||||
|
error(representation_error(_),_),
|
||||||
|
throw(max_char_code(Code))),
|
||||||
|
false),
|
||||||
|
max_char_code(Code),
|
||||||
|
Max is Code - 1).
|
||||||
|
|
||||||
ctype(alnum).
|
ctype(alnum).
|
||||||
ctype(alpha).
|
ctype(alpha).
|
||||||
ctype(alphabetic).
|
ctype(alphabetic).
|
||||||
|
|||||||
@@ -102,6 +102,7 @@
|
|||||||
fd_dom/2,
|
fd_dom/2,
|
||||||
|
|
||||||
% for use in predicates from library(reif)
|
% for use in predicates from library(reif)
|
||||||
|
clpz_t/2,
|
||||||
(#=)/3,
|
(#=)/3,
|
||||||
(#<)/3
|
(#<)/3
|
||||||
|
|
||||||
@@ -7981,13 +7982,13 @@ coeff_var_term(C-V, T) :- ( C =:= 1 -> T = #V ; T = C * #V ).
|
|||||||
Reified predicates for use with predicates from library(reif).
|
Reified predicates for use with predicates from library(reif).
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
#=(X, Y, T) :-
|
clpz_t(Expr, T) :-
|
||||||
X #= Y #<==> #B,
|
Expr #<==> #B,
|
||||||
zo_t(B, T).
|
zo_t(B, T).
|
||||||
|
|
||||||
#<(X, Y, T) :-
|
#=(X, Y, T) :- clpz_t(X #= Y, T).
|
||||||
X #< Y #<==> #B,
|
|
||||||
zo_t(B, T).
|
#<(X, Y, T) :- clpz_t(X #< Y, T).
|
||||||
|
|
||||||
zo_t(0, false).
|
zo_t(0, false).
|
||||||
zo_t(1, true).
|
zo_t(1, true).
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ row([X | Y], Opt) -->
|
|||||||
!,
|
!,
|
||||||
( separator(Opt) ->
|
( separator(Opt) ->
|
||||||
row(Y, Opt)
|
row(Y, Opt)
|
||||||
; end_token ->
|
; end_token,
|
||||||
{ Y = [] }).
|
{ Y = [] }).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,23 +40,36 @@ load_scryerrc :-
|
|||||||
(\+ disabled_init_file -> load_scryerrc ; true),
|
(\+ disabled_init_file -> load_scryerrc ; true),
|
||||||
repl.
|
repl.
|
||||||
|
|
||||||
|
args_consults_goals([], [], []).
|
||||||
|
args_consults_goals([Arg|Args], Consults, Goals) :-
|
||||||
|
arg_consults_goals(Arg, Args, Consults, Goals).
|
||||||
|
|
||||||
|
arg_consults_goals(c(Mod), Args, [c(Mod)|Consults], Goals) :-
|
||||||
|
args_consults_goals(Args, Consults, Goals).
|
||||||
|
arg_consults_goals(g(Goal), Args, Consults, [g(Goal)|Goals]) :-
|
||||||
|
args_consults_goals(Args, Consults, Goals).
|
||||||
|
|
||||||
delegate_task([], []).
|
delegate_task([], []).
|
||||||
delegate_task([], Goals0) :-
|
delegate_task([], Goals0) :-
|
||||||
reverse(Goals0, Goals),
|
|
||||||
(\+ disabled_init_file -> load_scryerrc ; true),
|
(\+ disabled_init_file -> load_scryerrc ; true),
|
||||||
|
reverse(Goals0, Goals1),
|
||||||
|
args_consults_goals(Goals1, Consults, Goals),
|
||||||
|
run_goals(Consults),
|
||||||
run_goals(Goals),
|
run_goals(Goals),
|
||||||
repl.
|
repl.
|
||||||
|
|
||||||
delegate_task([Arg0|Args], Goals0) :-
|
delegate_task([Arg0|Args], Goals0) :-
|
||||||
( member(Arg0, ["-h", "--help"]) -> print_help
|
( ( member(Arg0, ["-h", "--help"]) -> print_help
|
||||||
; member(Arg0, ["-v", "--version"]) -> print_version
|
; member(Arg0, ["-v", "--version"]) -> print_version
|
||||||
; member(Arg0, ["-g", "--goal"]) -> gather_goal(g, Args, Goals0)
|
; member(Arg0, ["-g", "--goal"]) -> gather_goal(g, Args, Goals0)
|
||||||
; member(Arg0, ["-f"]) -> disable_init_file
|
; member(Arg0, ["-f"]) -> disable_init_file
|
||||||
; member(Arg0, ["--no-add-history"]) -> ignore_machine_arg
|
; member(Arg0, ["--no-add-history"]) -> ignore_machine_arg
|
||||||
|
),
|
||||||
|
!,
|
||||||
|
delegate_task(Args, Goals0)
|
||||||
; atom_chars(Mod, Arg0),
|
; atom_chars(Mod, Arg0),
|
||||||
catch(consult(Mod), E, print_exception(E))
|
delegate_task(Args, [c(Mod)|Goals0])
|
||||||
),
|
).
|
||||||
delegate_task(Args, Goals0).
|
|
||||||
|
|
||||||
print_help :-
|
print_help :-
|
||||||
write('Usage: scryer-prolog [OPTIONS] [FILES] [-- ARGUMENTS]'),
|
write('Usage: scryer-prolog [OPTIONS] [FILES] [-- ARGUMENTS]'),
|
||||||
@@ -96,6 +109,7 @@ ignore_machine_arg.
|
|||||||
|
|
||||||
arg_type(g).
|
arg_type(g).
|
||||||
arg_type(t).
|
arg_type(t).
|
||||||
|
arg_type(c(_)).
|
||||||
arg_type(g(_)).
|
arg_type(g(_)).
|
||||||
arg_type(t(_)).
|
arg_type(t(_)).
|
||||||
|
|
||||||
@@ -132,6 +146,14 @@ run_goals([g(Gs0)|Goals]) :- !,
|
|||||||
write_term(Goal, [variable_names(VNs),double_quotes(DQ)]), nl
|
write_term(Goal, [variable_names(VNs),double_quotes(DQ)]), nl
|
||||||
),
|
),
|
||||||
run_goals(Goals).
|
run_goals(Goals).
|
||||||
|
run_goals([c(Mod)|Goals]) :- !,
|
||||||
|
( catch(consult(Mod), E, print_exception(E)) ->
|
||||||
|
true
|
||||||
|
; write('% Warning: initialization failed for: '),
|
||||||
|
double_quotes_option(DQ),
|
||||||
|
write_term(consult(Mod), [double_quotes(DQ)]), nl
|
||||||
|
),
|
||||||
|
run_goals(Goals).
|
||||||
run_goals([Goal|_]) :-
|
run_goals([Goal|_]) :-
|
||||||
loader:write_error(error(domain_error(arg_type, Goal), run_goals/1)),
|
loader:write_error(error(domain_error(arg_type, Goal), run_goals/1)),
|
||||||
nl,
|
nl,
|
||||||
|
|||||||
0
tests/scryer/cli/src_tests/all_modules.stderr
Normal file
0
tests/scryer/cli/src_tests/all_modules.stderr
Normal file
48
tests/scryer/cli/src_tests/all_modules.stdin
Normal file
48
tests/scryer/cli/src_tests/all_modules.stdin
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
use_module(library(arithmetic)).
|
||||||
|
use_module(library(assoc)).
|
||||||
|
use_module(library(atts)).
|
||||||
|
use_module(library(between)).
|
||||||
|
use_module(library(charsio)).
|
||||||
|
use_module(library(clpb)).
|
||||||
|
use_module(library(clpz)).
|
||||||
|
use_module(library(cont)).
|
||||||
|
use_module(library(crypto)).
|
||||||
|
use_module(library(csv)).
|
||||||
|
use_module(library(dcgs)).
|
||||||
|
use_module(library(debug)).
|
||||||
|
use_module(library(diag)).
|
||||||
|
use_module(library(dif)).
|
||||||
|
use_module(library(error)).
|
||||||
|
use_module(library(ffi)).
|
||||||
|
use_module(library(files)).
|
||||||
|
use_module(library(format)).
|
||||||
|
use_module(library(freeze)).
|
||||||
|
use_module(library(gensym)).
|
||||||
|
use_module(library(http/http_open)).
|
||||||
|
use_module(library(http/http_server)).
|
||||||
|
use_module(library(iso_ext)).
|
||||||
|
use_module(library(lambda)).
|
||||||
|
use_module(library(lists)).
|
||||||
|
use_module(library(ordsets)).
|
||||||
|
use_module(library(os)).
|
||||||
|
use_module(library(pairs)).
|
||||||
|
use_module(library(pio)).
|
||||||
|
use_module(library(queues)).
|
||||||
|
use_module(library(random)).
|
||||||
|
use_module(library(reif)).
|
||||||
|
use_module(library(serialization/abnf)).
|
||||||
|
use_module(library(serialization/json)).
|
||||||
|
use_module(library(sgml)).
|
||||||
|
use_module(library(si)).
|
||||||
|
use_module(library(simplex)).
|
||||||
|
use_module(library(sockets)).
|
||||||
|
use_module(library(tabling)).
|
||||||
|
use_module(library(terms)).
|
||||||
|
use_module(library(time)).
|
||||||
|
use_module(library(tls)).
|
||||||
|
use_module(library(ugraphs)).
|
||||||
|
use_module(library(uuid)).
|
||||||
|
use_module(library(wasm)).
|
||||||
|
use_module(library(when)).
|
||||||
|
use_module(library(xpath)).
|
||||||
|
halt.
|
||||||
47
tests/scryer/cli/src_tests/all_modules.stdout
Normal file
47
tests/scryer/cli/src_tests/all_modules.stdout
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
|
true.
|
||||||
1
tests/scryer/cli/src_tests/all_modules.toml
Normal file
1
tests/scryer/cli/src_tests/all_modules.toml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
args = ["-f", "--no-add-history"]
|
||||||
Reference in New Issue
Block a user