diff --git a/src/canary/metta_interp.pl b/src/canary/metta_interp.pl index aa087700ebc..55af8a4433f 100755 --- a/src/canary/metta_interp.pl +++ b/src/canary/metta_interp.pl @@ -129,15 +129,15 @@ :-dynamic(user:loaded_into_kb/2). :- dynamic(user:is_metta_dir/1). -once_writeq_ln(_):- \+ clause(pfcTraceExecution,true),!. -once_writeq_ln(P):- nb_current('$once_writeq_ln',W),W=@=P,!. -once_writeq_ln(P):- +once_writeq_nl(_):- \+ clause(pfcTraceExecution,true),!. +once_writeq_nl(P):- nb_current('$once_writeq_ln',W),W=@=P,!. +once_writeq_nl(P):- \+ \+ (numbervars(P,444,_,[attvar(skip),singletons(true)]), ansi_format([fg(cyan)],'~N~q.~n',[P])),nb_setval('$once_writeq_ln',P),!. % TODO uncomment this next line but it is breaking the curried chainer % pfcAdd_Now(P):- pfcAdd(P),!. -pfcAdd_Now(P):- current_predicate(pfcAdd/1),!, once_writeq_ln(pfcAdd(P)),pfcAdd(P). -pfcAdd_Now(P):- once_writeq_ln(asssert(P)),assert(P). +pfcAdd_Now(P):- current_predicate(pfcAdd/1),!, once_writeq_nl(pfcAdd(P)),pfcAdd(P). +pfcAdd_Now(P):- once_writeq_nl(asssert(P)),assert(P). %:- endif. system:copy_term_g(I,O):- ground(I),!,I=O. diff --git a/src/canary/metta_loader.pl b/src/canary/metta_loader.pl index 5f2a0b50767..dec81a69e0f 100755 --- a/src/canary/metta_loader.pl +++ b/src/canary/metta_loader.pl @@ -461,8 +461,6 @@ format(user_error,'~N; Done translating ~w forms: ~q.', [TF,asserted_metta_pred(MangleP2,Filename)]))). -write_src_woi(Term):- with_indents(false,write_src(Term)). - % write comments write_metta_datalog_term(Output,'$COMMENT'(Term,_,_),_MangleP2,_Lineno):- format(Output,"/* ~w */~n",[Term]). diff --git a/src/canary/metta_pfc_base.pl b/src/canary/metta_pfc_base.pl index aad619a51fe..14c8ccda24e 100755 --- a/src/canary/metta_pfc_base.pl +++ b/src/canary/metta_pfc_base.pl @@ -1278,7 +1278,7 @@ pfc_eval_rhs1(Assertion,Support) :- % an assertion to be added. - once_writeq_ln(pfcRHS(Assertion)), + once_writeq_nl(pfcRHS(Assertion)), (must_ex(pfcPost1(Assertion,Support))*->true ; pfcWarn("Malformed rhs of a rule: ~p",[Assertion])). diff --git a/src/canary/metta_printer.pl b/src/canary/metta_printer.pl index 74979ba1e02..bcd3060da41 100755 --- a/src/canary/metta_printer.pl +++ b/src/canary/metta_printer.pl @@ -145,9 +145,13 @@ py_is_enabled:- predicate_property(py_ppp(_),defined), asserta((py_is_enabled:-!)). %write_src(V):- !, \+ \+ quietly(pp_sex(V)),!. -write_src(V):- \+ \+ notrace(pp_sex(V)),!. -write_src_woi_ln(X):- - format('~N'),write_src_woi(X),format('~N'). +write_src(V):- \+ \+ notrace(( + guess_metta_vars(V),pp_sex(V))),!. +write_src_woi(Term):- + notrace((with_indents(false,write_src(Term)))). +write_src_woi_nl(X):- \+ \+ + notrace((guess_metta_vars(X), + format('~N'),write_src_woi(X),format('~N'))). pp_sex(V):- pp_sexi(V),!. diff --git a/src/canary/metta_space.pl b/src/canary/metta_space.pl index fc96c1a295b..73b66412c21 100755 --- a/src/canary/metta_space.pl +++ b/src/canary/metta_space.pl @@ -553,7 +553,7 @@ has_type(S,Type):- sub_atom(S,0,4,Aft,FB),flybase_identifier(FB,Type),!,Aft>0. -call_sexpr(S):- once_writeq_ln(call_sexpr(S)). +call_sexpr(S):- once_writeq_nl(call_sexpr(S)). %call_sexpr(Space,Expr,Result):- :- dynamic(fb_pred/2). @@ -666,4 +666,24 @@ symbolic_list_concat(A,B):- atomic_list_concat(A,B). symbol_contains(T,TT):- atom_contains(T,TT). */ +search_for1(X):- + forall((metta_atom(_Where,What),contains_var(X,What)), + write_src_nl(What)). +search_for2(X):- + forall((metta_src(_Where,What),contains_var(X,What)), + write_src_woi_nl(What)). + + +metta_src(Where,What):- + loaded_into_kb(Where,File), metta_file_buffer(_,What,Vars,File,_Loc), + ignore(maplist(name_the_var,Vars)). + + +name_the_var(N=V):- ignore((atom_concat('_',NV,N),V='$VAR'(NV))). +guess_metta_vars(What):- + ignore(once((metta_file_buffer(_,What0,Vars,_File,_Loc), + alpha_unif(What,What0), + maplist(name_the_var,Vars)))). + +alpha_unif(What,What0):- What=@=What0,What=What0. diff --git a/tests/extended_compat/ai-service/ai-service-composition-hard.metta.answers b/tests/extended_compat/ai-service/ai-service-composition-hard.metta.answers index 2c5da382ce3..e69de29bb2d 100644 --- a/tests/extended_compat/ai-service/ai-service-composition-hard.metta.answers +++ b/tests/extended_compat/ai-service/ai-service-composition-hard.metta.answers @@ -1 +0,0 @@ -timeout: failed to run command 'time': No such file or directory diff --git a/tests/extended_compat/ai-service/ai-service-composition-sanity.metta.answers b/tests/extended_compat/ai-service/ai-service-composition-sanity.metta.answers index 2c5da382ce3..b546e15489d 100644 --- a/tests/extended_compat/ai-service/ai-service-composition-sanity.metta.answers +++ b/tests/extended_compat/ai-service/ai-service-composition-sanity.metta.answers @@ -1 +1,10 @@ -timeout: failed to run command 'time': No such file or directory +[()] +[()] +[()] +[()] +[()] +[()] +[()] +[] +0.11user 0.01system 0:00.12elapsed 99%CPU (0avgtext+0avgdata 26552maxresident)k +560inputs+0outputs (5major+3377minor)pagefaults 0swaps