diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-24 15:17:08 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-24 15:17:33 +0200 |
commit | 6fd66a9264731bd7ee6d7602675965021d929a4a (patch) | |
tree | e94fc63efb823ad2f5c9ef6de6188da389a08d38 /pl/atom_dcg.pl | |
parent | ff48d644a45dd71098ecb9007a41807fb37d0081 (diff) | |
download | EpisodeBrowser-6fd66a9264731bd7ee6d7602675965021d929a4a.tar.gz |
Remove Prolog dependency.
The only thing left to reimplement is the tracking of watched episodes
in MPC-HC.
Diffstat (limited to 'pl/atom_dcg.pl')
-rw-r--r-- | pl/atom_dcg.pl | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/pl/atom_dcg.pl b/pl/atom_dcg.pl deleted file mode 100644 index c5b9bfc..0000000 --- a/pl/atom_dcg.pl +++ /dev/null @@ -1,82 +0,0 @@ -:- module(atom_dcg, [compound_atom_codes/2]). - -% with_atoms/1-9 automatically convert atoms for the caller to codes -% for the callee, primarily to make atoms easier to use with -% definite-clause grammars. atom_phrase/2 is defined as a shortcut. - -% with_codes/1-9, conversely, convert codes for the caller to atoms -% for the callee. - -:- meta_predicate user:with_atoms(0). -:- meta_predicate user:with_atoms(0,0). -:- meta_predicate user:with_atoms(0,0,0). -:- meta_predicate user:with_atoms(0,0,0,0). -:- meta_predicate user:with_atoms(0,0,0,0,0). -:- meta_predicate user:with_atoms(0,0,0,0,0,0). -:- meta_predicate user:with_atoms(0,0,0,0,0,0,0). -:- meta_predicate user:with_atoms(0,0,0,0,0,0,0,0). -:- meta_predicate user:with_atoms(0,0,0,0,0,0,0,0,0). -user:with_atoms(A) :- atom_dcg:compound_atom_codes(A, A1), call(A1). -user:with_atoms(A, B) :- maplist(user:with_atoms, [A,B]). -user:with_atoms(A, B, C) :- maplist(user:with_atoms, [A,B,C]). -user:with_atoms(A, B, C, D) :- maplist(user:with_atoms, [A,B,C,D]). -user:with_atoms(A, B, C, D, E) :- maplist(user:with_atoms, [A,B,C,D,E]). -user:with_atoms(A, B, C, D, E, F) :- maplist(user:with_atoms, [A,B,C,D,E,F]). -user:with_atoms(A, B, C, D, E, F, G) :- maplist(user:with_atoms, [A,B,C,D,E,F,G]). -user:with_atoms(A, B, C, D, E, F, G, H) :- maplist(user:with_atoms, [A,B,C,D,E,F,G,H]). -user:with_atoms(A, B, C, D, E, F, G, H, I) :- maplist(user:with_atoms, [A,B,C,D,E,F,G,H,I]). - -:- meta_predicate user:with_codes(0). -:- meta_predicate user:with_codes(0,0). -:- meta_predicate user:with_codes(0,0,0). -:- meta_predicate user:with_codes(0,0,0,0). -:- meta_predicate user:with_codes(0,0,0,0,0). -:- meta_predicate user:with_codes(0,0,0,0,0,0). -:- meta_predicate user:with_codes(0,0,0,0,0,0,0). -:- meta_predicate user:with_codes(0,0,0,0,0,0,0,0). -:- meta_predicate user:with_codes(0,0,0,0,0,0,0,0,0). -user:with_codes(A) :- atom_dcg:compound_atom_codes(A1, A), call(A1). -user:with_codes(A, B) :- maplist(user:with_codes, [A,B]). -user:with_codes(A, B, C) :- maplist(user:with_codes, [A,B,C]). -user:with_codes(A, B, C, D) :- maplist(user:with_codes, [A,B,C,D]). -user:with_codes(A, B, C, D, E) :- maplist(user:with_codes, [A,B,C,D,E]). -user:with_codes(A, B, C, D, E, F) :- maplist(user:with_codes, [A,B,C,D,E,F]). -user:with_codes(A, B, C, D, E, F, G) :- maplist(user:with_codes, [A,B,C,D,E,F,G]). -user:with_codes(A, B, C, D, E, F, G, H) :- maplist(user:with_codes, [A,B,C,D,E,F,G,H]). -user:with_codes(A, B, C, D, E, F, G, H, I) :- maplist(user:with_codes, [A,B,C,D,E,F,G,H,I]). - -:- meta_predicate user:atom_phrase(2, ?). -user:atom_phrase(G, A) :- - atom_dcg:compound_atom_codes(G, G1), - ( var(A) - -> phrase(G1, C), - atom_codes(A, C) - ; atom_codes(A, C), - phrase(G1, C) - ). - -compound_atom_codes(Module:G, Module:G1) :- !, compound_atom_codes(G, G1). -compound_atom_codes(G, G1) :- - ( nonvar(G) - -> G =.. [F|Args0], - maplist(maybe_atom_codes, Args0, Args), - G1 =.. [F|Args] - ; G1 =.. [F|Args], - maplist(maybe_atom_codes, Args0, Args), - G =.. [F|Args0] - ). - -maybe_atom_codes(A, C) :- - (compound(A) ; compound(C)), !, - compound_atom_codes(A, C). - -maybe_atom_codes(A, C) :- - nonvar(A), !, - ( atom(A) - -> atom_codes(A, C) - ; C = A - ). - -maybe_atom_codes(A, C) :- - var(A), !, - when((ground(A) ; ground(C)), catch(atom_codes(A, C), _, A = C)). |