Merge branch 'rebis-dev' of https://github.com/mthom/scryer-prolog into rebis-dev
This commit is contained in:
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -23,9 +23,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "az"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9bcd47d94aa4eb8c076b50fc61a75020789394ffb9bd74a180b3379130f6569"
|
||||
checksum = "d84e1d907bfc5795a6addb95ef8666141ee73c8f2f5250ff2a46bf4e4f4aec8a"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
@@ -470,9 +470,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.84"
|
||||
version = "0.2.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cca32fa0182e8c0989459524dc356b8f2b5c10f1b9eb521b7d182c03cf8c5ff"
|
||||
checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3"
|
||||
|
||||
[[package]]
|
||||
name = "libsodium-sys"
|
||||
@@ -1103,9 +1103,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.16.19"
|
||||
version = "0.16.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "024a1e66fea74c66c66624ee5622a7ff0e4b73a13b4f5c326ddb50c708944226"
|
||||
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
|
||||
265
crates/prolog_parser/Cargo.lock
generated
Normal file
265
crates/prolog_parser/Cargo.lock
generated
Normal file
@@ -0,0 +1,265 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9"
|
||||
dependencies = [
|
||||
"nodrop",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "az"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d84e1d907bfc5795a6addb95ef8666141ee73c8f2f5250ff2a46bf4e4f4aec8a"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "gmp-mpfr-sys"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a57fdb339d49833021b1fded600ed240ae907e33909d5511a61dff884df7f16e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexical"
|
||||
version = "2.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e0d09e60c187a6d0a3fa418aec8587c6a4ae9de872f6126f2134f319b5ed10d"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"lexical-core",
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexical-core"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304bccb228c4b020f3a4835d247df0a02a7c4686098d4167762cfbbe4c5cb14"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"cfg-if",
|
||||
"rustc_version",
|
||||
"ryu",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.85"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3"
|
||||
|
||||
[[package]]
|
||||
name = "nodrop"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits 0.2.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits 0.2.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-bigint",
|
||||
"num-integer",
|
||||
"num-traits 0.2.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rug-adapter"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7470b6acf85abce0771203112db4181d03f7b8a6be49f0e842a78030192f8a58"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"num-bigint",
|
||||
"num-integer",
|
||||
"num-rational",
|
||||
"num-traits 0.2.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31"
|
||||
dependencies = [
|
||||
"num-traits 0.2.14",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7eb5259643245d3f292c7a146b2df53bba24d7eab159410e648eb73dc164669d"
|
||||
dependencies = [
|
||||
"num-traits 0.1.43",
|
||||
"unreachable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prolog_parser_rebis"
|
||||
version = "0.8.68"
|
||||
dependencies = [
|
||||
"lexical",
|
||||
"num-rug-adapter",
|
||||
"ordered-float",
|
||||
"rug",
|
||||
"unicode_reader",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rug"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e538d00da450a8e48aac7e6322e67b2dc86ec71a1feeac0e3954c4f07f01bc45"
|
||||
dependencies = [
|
||||
"az",
|
||||
"gmp-mpfr-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||
dependencies = [
|
||||
"semver-parser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver-parser"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f3eb36b47e512f8f1c9e3d10c2c1965bc992bd9cdb024fa581e2194501c83d3"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
|
||||
|
||||
[[package]]
|
||||
name = "unicode_reader"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b639121690b27acd92c97ed2b52c5e5e8d3d39482e943b4559695cef62f771a"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unreachable"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
||||
dependencies = [
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
@@ -1,8 +1,8 @@
|
||||
extern crate prolog_parser;
|
||||
extern crate prolog_parser_rebis;
|
||||
|
||||
use prolog_parser::ast::*;
|
||||
use prolog_parser::lexer::{Lexer, Token};
|
||||
use prolog_parser::tabled_rc::TabledData;
|
||||
use prolog_parser_rebis::ast::*;
|
||||
use prolog_parser_rebis::lexer::{Lexer, Token};
|
||||
use prolog_parser_rebis::tabled_rc::TabledData;
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
extern crate prolog_parser;
|
||||
extern crate prolog_parser_rebis;
|
||||
|
||||
use prolog_parser::ast::*;
|
||||
use prolog_parser::lexer::{Lexer, Token};
|
||||
use prolog_parser::tabled_rc::TabledData;
|
||||
use prolog_parser_rebis::ast::*;
|
||||
use prolog_parser_rebis::lexer::{Lexer, Token};
|
||||
use prolog_parser_rebis::tabled_rc::TabledData;
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
|
||||
@@ -156,6 +156,8 @@ user:goal_expansion(Term, M:get_atts(Var, Attr)) :-
|
||||
nonvar(Term),
|
||||
Term = get_atts(Var, M, Attr).
|
||||
|
||||
:- meta_predicate call_residue_vars(0, ?).
|
||||
|
||||
call_residue_vars(Goal, Vars) :-
|
||||
'$get_attr_var_queue_delim'(B),
|
||||
call(Goal),
|
||||
|
||||
@@ -5884,10 +5884,12 @@ difference_arcs([V|Vs], FL0) -->
|
||||
|
||||
writeln(T) :- write(T), nl.
|
||||
|
||||
:- meta_predicate must_succeed(0).
|
||||
|
||||
must_succeed(G) :-
|
||||
(G -> true
|
||||
;write(failed-G), halt
|
||||
).
|
||||
( G -> true
|
||||
; throw(failed-G)
|
||||
).
|
||||
|
||||
enumerate([], _) --> [].
|
||||
enumerate([N|Ns], V) -->
|
||||
@@ -6047,6 +6049,8 @@ remove_attr(Var, Attr) :-
|
||||
functor(Term, Attr, 1),
|
||||
put_atts(Var, -Term).
|
||||
|
||||
:- meta_predicate with_local_attributes(?, 0, ?).
|
||||
|
||||
with_local_attributes(Vars, Goal, Result) :-
|
||||
catch((Goal,
|
||||
maplist(del_all_attrs, Vars),
|
||||
@@ -7763,11 +7767,10 @@ zo_t(1, true).
|
||||
Generated predicates
|
||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||
|
||||
generated_clauses(Cs) :-
|
||||
make_parse_clpz(Cs1),
|
||||
make_parse_reified(Cs2),
|
||||
make_matches(Cs3),
|
||||
append([Cs1,Cs2,Cs3], Cs).
|
||||
term_expansion(make_parse_clpz, Clauses) :- make_parse_clpz(Clauses).
|
||||
term_expansion(make_parse_reified, Clauses) :- make_parse_reified(Clauses).
|
||||
term_expansion(make_matches, Clauses) :- make_matches(Clauses).
|
||||
|
||||
:- initialization((generated_clauses(Cs),
|
||||
maplist(assertz, Cs))).
|
||||
make_parse_clpz.
|
||||
make_parse_reified.
|
||||
make_matches.
|
||||
|
||||
@@ -19,7 +19,7 @@ phrase(GRBody, S0, S) :-
|
||||
( var(GRBody) ->
|
||||
throw(error(instantiation_error, phrase/3))
|
||||
; strip_module(GRBody, Module, GRBody0),
|
||||
dcg_constr(GRBody0),
|
||||
dcg_constr(GRBody0) ->
|
||||
( var(Module) ->
|
||||
phrase_(GRBody0, S0, S)
|
||||
; phrase_(Module:GRBody0, S0, S)
|
||||
@@ -31,9 +31,12 @@ phrase(GRBody, S0, S) :-
|
||||
|
||||
phrase_([], S, S).
|
||||
phrase_(!, S, S).
|
||||
phrase_(_:[], S, S) :- !.
|
||||
phrase_(_:!, S, S) :- !.
|
||||
phrase_((A, B), S0, S) :-
|
||||
phrase(A, S0, S1), phrase(B, S1, S).
|
||||
phrase_(M:(A, B), S0, S) :-
|
||||
!,
|
||||
phrase(M:A, S0, S1), phrase(M:B, S1, S).
|
||||
phrase_((A -> B ; C), S0, S) :-
|
||||
!,
|
||||
@@ -50,23 +53,37 @@ phrase_(M:(A -> B ; C), S0, S) :-
|
||||
phrase_((A ; B), S0, S) :-
|
||||
( phrase(A, S0, S) ; phrase(B, S0, S) ).
|
||||
phrase_(M:(A ; B), S0, S) :-
|
||||
!,
|
||||
( phrase(M:A, S0, S) ; phrase(M:B, S0, S) ).
|
||||
phrase_((A | B), S0, S) :-
|
||||
( phrase(A, S0, S) ; phrase(B, S0, S) ).
|
||||
phrase_(M:(A | B), S0, S) :-
|
||||
!,
|
||||
( phrase(M:A, S0, S) ; phrase(M:B, S0, S) ).
|
||||
phrase_({G}, S0, S) :-
|
||||
( call(G), S0 = S ).
|
||||
phrase_(M:{G}, S0, S) :-
|
||||
!,
|
||||
( call(M:G), S0 = S ).
|
||||
phrase_(call(G), S0, S) :-
|
||||
call(G, S0, S).
|
||||
phrase_(M:call(G), S0, S) :-
|
||||
!,
|
||||
call(M:G, S0, S).
|
||||
phrase_((A -> B), S0, S) :-
|
||||
phrase((A -> B ; fail), S0, S).
|
||||
phrase_(M:(A -> B), S0, S) :-
|
||||
!,
|
||||
phrase((M:A -> M:B ; fail), S0, S).
|
||||
phrase_(phrase(NonTerminal), S0, S) :-
|
||||
phrase(NonTerminal, S0, S).
|
||||
phrase_(M:phrase(NonTerminal), S0, S) :-
|
||||
!,
|
||||
phrase(M:NonTerminal, S0, S).
|
||||
phrase_([T|Ts], S0, S) :-
|
||||
append([T|Ts], S, S0).
|
||||
phrase_(_:[T|Ts], S0, S) :-
|
||||
append([T|Ts], S, S0).
|
||||
|
||||
|
||||
% The same version of the below two dcg_rule clauses, but with module scoping.
|
||||
|
||||
@@ -126,7 +126,7 @@ maplist(Cont, [E1|E1s], [E2|E2s], [E3|E3s], [E4|E4s], [E5|E5s], [E6|E6s], [E7|E7
|
||||
|
||||
|
||||
sum_list(Ls, S) :-
|
||||
foldl(sum_, Ls, 0, S).
|
||||
foldl(lists:sum_, Ls, 0, S).
|
||||
|
||||
sum_(L, S0, S) :- S is S0 + L.
|
||||
|
||||
@@ -160,17 +160,17 @@ transpose(Ls, Ts) :-
|
||||
|
||||
lists_transpose([], []).
|
||||
lists_transpose([L|Ls], Ts) :-
|
||||
maplist(same_length(L), Ls),
|
||||
foldl(transpose_, L, Ts, [L|Ls], _).
|
||||
maplist(lists:same_length(L), Ls),
|
||||
foldl(lists:transpose_, L, Ts, [L|Ls], _).
|
||||
|
||||
transpose_(_, Fs, Lists0, Lists) :-
|
||||
maplist(list_first_rest, Lists0, Fs, Lists).
|
||||
maplist(lists:list_first_rest, Lists0, Fs, Lists).
|
||||
|
||||
list_first_rest([L|Ls], L, Ls).
|
||||
|
||||
|
||||
list_to_set(Ls0, Ls) :-
|
||||
maplist(with_var, Ls0, LVs0),
|
||||
maplist(lists:with_var, Ls0, LVs0),
|
||||
keysort(LVs0, LVs),
|
||||
same_elements(LVs),
|
||||
pick_firsts(LVs0, Ls).
|
||||
@@ -188,7 +188,7 @@ with_var(E, E-_).
|
||||
|
||||
same_elements([]).
|
||||
same_elements([EV|EVs]) :-
|
||||
foldl(unify_same, EVs, EV, _).
|
||||
foldl(lists:unify_same, EVs, EV, _).
|
||||
|
||||
unify_same(E-V, Prev-Var, E-V) :-
|
||||
( Prev == E ->
|
||||
@@ -221,13 +221,13 @@ nth0_search(N0, N, [_|Es], E) :-
|
||||
|
||||
|
||||
list_max([N|Ns], Max) :-
|
||||
foldl(list_max_, Ns, N, Max).
|
||||
foldl(lists:list_max_, Ns, N, Max).
|
||||
|
||||
list_max_(N, Max0, Max) :-
|
||||
Max is max(N, Max0).
|
||||
|
||||
list_min([N|Ns], Min) :-
|
||||
foldl(list_min_, Ns, N, Min).
|
||||
foldl(lists:list_min_, Ns, N, Min).
|
||||
|
||||
list_min_(N, Min0, Min) :-
|
||||
Min is min(N, Min0).
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
:- use_module(library(dif)).
|
||||
|
||||
:- meta_predicate if_(0, 0, 0).
|
||||
|
||||
if_(If_1, Then_0, Else_0) :-
|
||||
call(If_1, T),
|
||||
( T == true -> call(Then_0)
|
||||
@@ -26,6 +28,8 @@ dif(X, Y, T) :-
|
||||
non(true, false).
|
||||
non(false, true).
|
||||
|
||||
:- meta_predicate tfilter(1, ?, ?).
|
||||
|
||||
tfilter(C_2, Es, Fs) :-
|
||||
i_tfilter(Es, C_2, Fs).
|
||||
|
||||
@@ -34,6 +38,8 @@ i_tfilter([E|Es], C_2, Fs0) :-
|
||||
if_(call(C_2, E), Fs0 = [E|Fs], Fs0 = Fs),
|
||||
i_tfilter(Es, C_2, Fs).
|
||||
|
||||
:- meta_predicate tpartition(1, ?, ?).
|
||||
|
||||
tpartition(P_2, Xs, Ts, Fs) :-
|
||||
i_tpartition(Xs, P_2, Ts, Fs).
|
||||
|
||||
@@ -44,12 +50,18 @@ i_tpartition([X|Xs], P_2, Ts0, Fs0) :-
|
||||
, ( Fs0 = [X|Fs], Ts0 = Ts ) ),
|
||||
i_tpartition(Xs, P_2, Ts, Fs).
|
||||
|
||||
:- meta_predicate ','(0, 0, ?).
|
||||
|
||||
','(A_1, B_1, T) :-
|
||||
if_(A_1, call(B_1, T), T = false).
|
||||
|
||||
:- meta_predicate ';'(0, 0, ?).
|
||||
|
||||
';'(A_1, B_1, T) :-
|
||||
if_(A_1, T = true, call(B_1, T)).
|
||||
|
||||
:- meta_predicate cond_t(0, 0, ?).
|
||||
|
||||
cond_t(If_1, Then_0, T) :-
|
||||
if_(If_1, ( Then_0, T = true ), T = false ).
|
||||
|
||||
@@ -60,8 +72,12 @@ i_memberd_t([], _, false).
|
||||
i_memberd_t([X|Xs], E, T) :-
|
||||
if_( X = E, T = true, i_memberd_t(Xs, E, T) ).
|
||||
|
||||
:- meta_predicate tmember(1, ?).
|
||||
|
||||
tmember(P_2, [X|Xs]) :-
|
||||
if_( call(P_2, X), true, tmember(P_2, Xs) ).
|
||||
|
||||
:- meta_predicate tmember_t(1, ?).
|
||||
|
||||
tmember_t(P_2, [X|Xs], T) :-
|
||||
if_( call(P_2, X), T = true, tmember_t(P_2, Xs, T) ).
|
||||
|
||||
@@ -423,7 +423,7 @@ expand_module_names(Goals, MetaSpecs, Module, ExpandedGoals, HeadVars) :-
|
||||
Goals =.. [GoalFunctor | SubGoals],
|
||||
( GoalFunctor == (:),
|
||||
SubGoals = [M, SubGoal] ->
|
||||
expand_module_names(SubGoal, MetaSpecs, Module, ExpandedSubGoal, HeadVars),
|
||||
expand_module_names(SubGoal, MetaSpecs, M, ExpandedSubGoal, HeadVars),
|
||||
ExpandedGoals = M:ExpandedSubGoal
|
||||
; expand_meta_predicate_subgoals(SubGoals, MetaSpecs, Module, ExpandedGoalList, HeadVars),
|
||||
ExpandedGoals =.. [GoalFunctor | ExpandedGoalList]
|
||||
@@ -434,6 +434,28 @@ expand_goal(UnexpandedGoals, Module, ExpandedGoals) :-
|
||||
expand_goal(UnexpandedGoals, Module, ExpandedGoals, []),
|
||||
!.
|
||||
|
||||
expand_goal_cases((Goal0, Goals0), Module, ExpandedGoals, HeadVars) :-
|
||||
( expand_goal(Goal0, Module, Goal1, HeadVars) ->
|
||||
expand_goal(Goals0, Module, Goals1, HeadVars),
|
||||
thread_goals(Goal1, ExpandedGoals, Goals1, (','))
|
||||
; expand_goal(Goals0, Module, Goals1, HeadVars),
|
||||
ExpandedGoals = (Goal0, Goals1)
|
||||
).
|
||||
expand_goal_cases((Goals0 -> Goals1), Module, ExpandedGoals, HeadVars) :-
|
||||
expand_goal(Goals0, Module, ExpandedGoals0, HeadVars),
|
||||
expand_goal(Goals1, Module, ExpandedGoals1, HeadVars),
|
||||
ExpandedGoals = (ExpandedGoals0 -> ExpandedGoals1).
|
||||
expand_goal_cases((Goals0 ; Goals1), Module, ExpandedGoals, HeadVars) :-
|
||||
expand_goal(Goals0, Module, ExpandedGoals0, HeadVars),
|
||||
expand_goal(Goals1, Module, ExpandedGoals1, HeadVars),
|
||||
ExpandedGoals = (ExpandedGoals0 ; ExpandedGoals1).
|
||||
expand_goal_cases((\+ Goals0), Module, ExpandedGoals, HeadVars) :-
|
||||
expand_goal(Goals0, Module, Goals1, HeadVars),
|
||||
ExpandedGoals = (\+ Goals1).
|
||||
expand_goal_cases((Module:Goals0), _, ExpandedGoals, HeadVars) :-
|
||||
expand_goal(Goals0, Module, Goals1, HeadVars),
|
||||
ExpandedGoals = (Module:Goals1).
|
||||
|
||||
expand_goal(UnexpandedGoals, Module, ExpandedGoals, HeadVars) :-
|
||||
( var(UnexpandedGoals) ->
|
||||
UnexpandedGoals = ExpandedGoals
|
||||
@@ -442,24 +464,8 @@ expand_goal(UnexpandedGoals, Module, ExpandedGoals, HeadVars) :-
|
||||
goal_expansion(UnexpandedGoals1, user, Goals)
|
||||
; Goals = UnexpandedGoals1
|
||||
),
|
||||
( Goals = (Goal0, Goals0) ->
|
||||
( expand_goal(Goal0, Module, Goal1, HeadVars) ->
|
||||
expand_goal(Goals0, Module, Goals1, HeadVars),
|
||||
thread_goals(Goal1, ExpandedGoals, Goals1, (','))
|
||||
; expand_goal(Goals0, Module, Goals1, HeadVars),
|
||||
ExpandedGoals = (Goal0, Goals1)
|
||||
)
|
||||
; Goals = (Goals0 -> Goals1) ->
|
||||
expand_goal(Goals0, Module, ExpandedGoals0, HeadVars),
|
||||
expand_goal(Goals1, Module, ExpandedGoals1, HeadVars),
|
||||
ExpandedGoals = (ExpandedGoals0 -> ExpandedGoals1)
|
||||
; Goals = (Goals0 ; Goals1) ->
|
||||
expand_goal(Goals0, Module, ExpandedGoals0, HeadVars),
|
||||
expand_goal(Goals1, Module, ExpandedGoals1, HeadVars),
|
||||
ExpandedGoals = (ExpandedGoals0 ; ExpandedGoals1)
|
||||
; Goals = (\+ Goals0) ->
|
||||
expand_goal(Goals0, Module, Goals1, HeadVars),
|
||||
ExpandedGoals = (\+ Goals1)
|
||||
( expand_goal_cases(Goals, Module, ExpandedGoals, HeadVars) ->
|
||||
true
|
||||
; predicate_property(Module:Goals, meta_predicate(MetaSpecs)) ->
|
||||
expand_module_names(Goals, MetaSpecs, Module, ExpandedGoals, HeadVars)
|
||||
; thread_goals(Goals, ExpandedGoals, (','))
|
||||
|
||||
@@ -1001,22 +1001,22 @@ fn append_compiled_clause(
|
||||
AppendOrPrepend::Append,
|
||||
);
|
||||
|
||||
if lower_bound + 1 == target_pos {
|
||||
let lower_bound_clause_start = find_inner_choice_instr(
|
||||
code,
|
||||
skeleton.clauses[lower_bound].clause_start,
|
||||
index_loc,
|
||||
);
|
||||
let target_pos_clause_start = find_inner_choice_instr(
|
||||
code,
|
||||
skeleton.clauses[target_pos - 1].clause_start,
|
||||
index_loc,
|
||||
);
|
||||
|
||||
if lower_bound + 1 == target_pos {
|
||||
set_switch_var_offset(
|
||||
code,
|
||||
index_loc,
|
||||
lower_bound_clause_start - index_loc,
|
||||
target_pos_clause_start - index_loc,
|
||||
retraction_info,
|
||||
);
|
||||
}
|
||||
|
||||
skeleton.clauses[target_pos - 1].clause_start
|
||||
target_pos_clause_start // skeleton.clauses[target_pos - 1].clause_start
|
||||
}
|
||||
_ => {
|
||||
skeleton.clauses[target_pos].opt_arg_index_key += clause_loc;
|
||||
|
||||
@@ -162,6 +162,14 @@ impl MachineState {
|
||||
}
|
||||
|
||||
fn bind_with_occurs_check(&mut self, r: Ref, addr: Addr) {
|
||||
if let Ref::StackCell(..) = r {
|
||||
// local variable optimization -- r cannot occur in the
|
||||
// data structure bound to addr, so don't bother
|
||||
// traversing it.
|
||||
self.bind(r, addr);
|
||||
return;
|
||||
}
|
||||
|
||||
let mut fail = false;
|
||||
|
||||
for addr in self.acyclic_pre_order_iter(addr) {
|
||||
|
||||
Reference in New Issue
Block a user