|
13 | 13 | */
|
14 | 14 | % File: $PACKDIR/subclause_expansion/prolog/echo_files.pl
|
15 | 15 | :- module(echo_files,
|
16 |
| - []). |
| 16 | + [get_file_from_stream/2]). |
17 | 17 |
|
18 | 18 | :- define_into_module(
|
19 | 19 | [
|
|
23 | 23 | echo_source_file/1]).
|
24 | 24 |
|
25 | 25 | /** <module> Utility LOGICMOO_PREDICATE_STREAMS
|
26 |
| -This module allows running prolog files as echos. |
| 26 | +This module allows running prolog files as echos. |
27 | 27 | @author Douglas R. Miles
|
28 | 28 | @license LGPL
|
29 | 29 |
|
|
46 | 46 |
|
47 | 47 | %! echo_source_file(+File) is det.
|
48 | 48 | %
|
49 |
| -echo_source_file(F):- |
| 49 | +echo_source_file(F):- |
50 | 50 | (\+ t_l:echoing_file(F) -> asserta(t_l:echoing_file(F)) ; true),
|
51 | 51 | check_current_echo(F).
|
52 | 52 |
|
53 | 53 | echo_source_file:- prolog_load_context(file,File), echo_source_file(File).
|
54 | 54 |
|
55 | 55 | echo_source_file_no_catchup(F):-
|
56 |
| - ignore(( |
| 56 | + ignore(( |
57 | 57 | \+ t_l:echoing_file(F),
|
58 | 58 | asserta(t_l:echoing_file(F)),!,
|
59 | 59 | get_file_from_stream(S,F), character_count(S,Pos),
|
60 | 60 | assume_caughtup_to(F,S,Pos))),!.
|
61 | 61 |
|
62 |
| -check_current_echo:- |
| 62 | +check_current_echo:- |
63 | 63 | source_location(F,_), prolog_load_context(source,S), S\==F,!,
|
64 | 64 | check_current_echo(S),check_current_echo(F).
|
65 |
| -check_current_echo:- |
66 |
| - ignore((prolog_load_context(source,S),check_current_echo(S))), |
| 65 | +check_current_echo:- |
| 66 | + ignore((prolog_load_context(source,S),check_current_echo(S))), |
67 | 67 | ignore((source_location(F,_),S\==F,check_current_echo(F))),
|
68 | 68 | ignore((prolog_load_context(file,SL),SL\==S,SL\==F,check_current_echo(SL))),!.
|
69 | 69 |
|
|
98 | 98 | feedback_close(F):- retract(t_l:feedback_started(F,mf_s(MF,S,I,O,E))),!,set_prolog_IO(I,O,E),
|
99 | 99 | close(S),memory_file_to_string(MF,String),free_memory_file(MF),
|
100 | 100 | atom_length(String,L), (L>0 -> into_echo_cmt(write(String));true).
|
101 |
| -feedback_close(_):- told. |
| 101 | +feedback_close(_):- told. |
102 | 102 |
|
103 | 103 | mco_info(F,S,_I,Start,End):-
|
104 | 104 | get_file_range(F,Start,End,STerm),
|
|
115 | 115 | :- module_transparent(echo_catchup/4).
|
116 | 116 |
|
117 | 117 | echo_catchup(I,P,O,PO):- \+ echo_catchup_f(I,P,O,PO), fail.
|
118 |
| -echo_catchup_f(I,P,O,PO):- |
| 118 | +echo_catchup_f(I,P,O,PO):- |
119 | 119 | notrace((compound(P),
|
120 | 120 | source_location(F,_L),t_l:echoing_file(F),
|
121 | 121 | b_getval('$term', Term),I==Term)),
|
|
157 | 157 |
|
158 | 158 |
|
159 | 159 | mco_p(F,_S,_I,Start,End):- %garbage_collect_atoms,
|
160 |
| - get_file_range(F,Start,End,STerm), |
| 160 | + get_file_range(F,Start,End,STerm), |
161 | 161 | read_mco(STerm,Term,Cmnts,QQ,_Vs,_Sv),
|
162 | 162 | % (Cmnts\==[];QQ\==[]),!,
|
163 | 163 | % mco_info(F,S,I,Start,End),
|
164 | 164 | write(STerm),!,
|
165 | 165 | assume_caughtup_to(F,S,End).
|
166 | 166 |
|
167 | 167 | mco_p(F,S,I,Start,End):- print_tree(I),!,assume_caughtup_to(F,S,End).
|
168 |
| - |
| 168 | + |
169 | 169 | % mco_i(F,S,I,O):- format('~N/*~~'),
|
170 | 170 | mco_i2(F,S,I,O):- fail.
|
171 | 171 | mco_i(F,S,I,O):- fail.
|
|
185 | 185 | catch_up_to_stream(S):- character_count(S,Pos),catch_up_to_stream(S,Pos).
|
186 | 186 |
|
187 | 187 | get_file_range(F,Start,End,SubStr):-
|
188 |
| - Len is End-Start, |
| 188 | + Len is End-Start, |
189 | 189 | read_file_to_string(F,Str,[]),
|
190 | 190 | sub_string(Str,Start,Len,_,SubStr).
|
191 | 191 | get_file_from(F,Start,SubStr):-
|
192 | 192 | read_file_to_string(F,Str,[]),
|
193 | 193 | sub_string(Str,Start,_,0,SubStr).
|
194 | 194 |
|
195 | 195 |
|
196 |
| -print_file_range(F,S,Start,End):- |
| 196 | +print_file_range(F,S,Start,End):- |
197 | 197 | get_file_range(F,Start,End,SubStr),
|
198 | 198 | assume_caughtup_to(F,S,End),
|
199 | 199 | write_ommit_feedback(on,SubStr),!.
|
|
223 | 223 | se:echo_expander(system:term_expansion(I,P,O,PO), echo_catchup(I,P,O,PO)).
|
224 | 224 |
|
225 | 225 | %user:term_expansion(I,P,O,PO):- echo_catchup(I,P,O,PO).
|
226 |
| -system:term_expansion(_,_,_,_):- |
| 226 | +system:term_expansion(_,_,_,_):- |
227 | 227 | notrace((
|
228 | 228 | se:echo_expander(H,B),
|
229 |
| - nth_clause(H,1,Ref), |
| 229 | + nth_clause(H,1,Ref), |
230 | 230 | \+ (clause(H,_:B,Ref)))),
|
231 | 231 | ignore(retract(H:- B)),
|
232 | 232 | asserta(H:-B),
|
|
0 commit comments