[[package]]
name = "prolog_parser"
-version = "0.8.40"
+version = "0.8.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lexical 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-rug-adapter 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "prolog_parser 0.8.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "prolog_parser 0.8.41 (registry+https://github.com/rust-lang/crates.io-index)",
"ref_thread_local 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rug 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustyline 5.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"checksum num-traits 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "443c53b3c3531dfcbfa499d8893944db78474ad7a1d87fa2d94d1a2231693ac6"
"checksum ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7eb5259643245d3f292c7a146b2df53bba24d7eab159410e648eb73dc164669d"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
-"checksum prolog_parser 0.8.40 (registry+https://github.com/rust-lang/crates.io-index)" = "013131c03328aef02b069e6b325b01fb47597034af169b8b8a1bb8f2cfab0868"
+"checksum prolog_parser 0.8.41 (registry+https://github.com/rust-lang/crates.io-index)" = "92be83a8004ae2c476b4257722e86f7df25fba80027e3c9e2e0d57ff2edc0023"
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
-% :- op(1105, xfy, ('|')).
-
-:- module(dcgs, [op(1200, xfx, -->), phrase/2, phrase/3]).
+:- module(dcgs, [op(1200, xfx, -->),
+ op(1105, xfy, '|'),
+ phrase/2,
+ phrase/3]).
:- use_module(library(lists), [append/3]).
).
phrase_((A ; B), S0, S) :-
( phrase(A, S0, S) ; phrase(B, S0, S) ).
-%% phrase_((A | B), S0, S) :-
-%% ( phrase(A, S0, S) ; phrase(B, S0, S) ).
+phrase_((A | B), S0, S) :-
+ ( phrase(A, S0, S) ; phrase(B, S0, S) ).
phrase_({G}, S0, S) :-
( call(G), S0 = S ).
phrase_(call(G), S0, S) :-
dcg_constr([_|_]). % 7.14.2 - terminal sequence
dcg_constr(( _, _ )). % 7.14.3 - concatenation
dcg_constr(( _ ; _ )). % 7.14.4 - alternative
-%% dcg_constr(( _'|'_ )). % 7.14.6 - alternative
+dcg_constr(( _'|'_ )). % 7.14.6 - alternative
dcg_constr({_}). % 7.14.7
dcg_constr(call(_)). % 7.14.8
dcg_constr(phrase(_)). % 7.14.9
subsumes_term(( _GRIf -> _GRThen ), GRCond),
dcg_cbody(GRCond, S0, S, Cond),
dcg_body(GRElse, S0, S, Else).
-%% dcg_cbody(( GREither '|' GROr ), S0, S, ( Either ; Or )) :-
-%% dcg_body(GREither, S0, S, Either),
-%% dcg_body(GROr, S0, S, Or).
+dcg_cbody(( GREither '|' GROr ), S0, S, ( Either ; Or )) :-
+ dcg_body(GREither, S0, S, Either),
+ dcg_body(GROr, S0, S, Or).
dcg_cbody({Goal}, S0, S, ( Goal, S0 = S )).
dcg_cbody(call(Cont), S0, S, call(Cont, S0, S)).
dcg_cbody(phrase(Body), S0, S, phrase(Body, S0, S)).
use std::iter::Rev;
use std::vec::IntoIter;
-fn unfold_by_str_once(term: &mut Term, s: &str) -> Option<(Term, Term)> {
- if let &mut Term::Clause(_, ref name, ref mut subterms, _) = term {
- if name.as_str() == s && subterms.len() == 2 {
- let snd = *subterms.pop().unwrap();
- let fst = *subterms.pop().unwrap();
-
- return Some((fst, snd));
- }
- }
-
- None
-}
-
-pub fn unfold_by_str(mut term: Term, s: &str) -> Vec<Term> {
- let mut terms = vec![];
-
- while let Some((fst, snd)) = unfold_by_str_once(&mut term, s) {
- terms.push(fst);
- term = snd;
- }
-
- terms.push(term);
- terms
-}
-
pub fn fold_by_str<I>(terms: I, mut term: Term, sym: ClauseName) -> Term
where
I: DoubleEndedIterator<Item = Term>,