Skip to content

Commit

Permalink
print outputs much closer to H-E
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Dec 24, 2024
1 parent 7751c26 commit ec5fed2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
19 changes: 14 additions & 5 deletions prolog/metta_lang/metta_interp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,9 @@




assert_preds('&corelib',_Load, _Clause):- !.
assert_preds(Self,Load,List):- is_list(List),!,maplist(assert_preds(Self,Load),List).
assert_preds(_Self,_Load,Clause):- compiler_assertz(Clause),!.
%assert_preds(_Self,_Load,_Preds):- \+ show_transpiler,!.
assert_preds(Self,Load,Preds):-
expand_to_hb(Preds,H,_B),
Expand Down Expand Up @@ -1370,16 +1371,24 @@
assertion_neck_cl(':-').


load_hook0(_,_):- \+ show_transpiler, !. % \+ is_transpiling, !.
%load_hook0(_,_):- \+ show_transpiler, !. % \+ is_transpiling, !.


load_hook0(Load,Assertion):- assertion_hb(Assertion,Self,Eq,H,B),
load_hook1(Load,Self,Eq,H,B).

load_hook1(_Load,'&corelib',_Eq,_H,_B):-!.
load_hook1(Load,Self,Eq,H,B):-
once(functs_to_preds([Eq,H,B],Preds)),
assert_preds(Self,Load,Preds),!.
% old compiler hook
/*
load_hook0(Load,Assertion):-
assertion_hb(Assertion,Self, Eq, H,B),
rtrace_on_error(compile_for_assert_eq(Eq, H, B, Preds)),!,
rtrace_on_error(assert_preds(Self,Load,Preds)).
load_hook0(_,_):- \+ current_prolog_flag(metta_interp,ready),!.
*/
/*
load_hook0(Load,get_metta_atom(Eq,Self,H)):- B = 'True',
H\=[':'|_], functs_to_preds([=,H,B],Preds),
Expand Down Expand Up @@ -1611,8 +1620,8 @@
write_exec0(Exec):-
wots(S,write_src(exec(Exec))),
nb_setval(exec_src,Exec),
format('~N'),
output_language(metta,ignore((notrace((color_g_mesg('#0D6328',writeln(S))))))).
not_compatio((format('~N'),
output_language(metta,ignore((notrace((color_g_mesg('#0D6328',writeln(S))))))))).

%!(let* (( ($a $b) (collapse (get-atoms &self)))) ((bind! &stdlib $a) (bind! &corelib $b)))

Expand Down Expand Up @@ -2202,7 +2211,7 @@
test_alarm,
run_cmd_args,
write_answer_output,
maybe_halt(7)]))),!.
not_compat_io(maybe_halt(7))]))),!.

need_interaction:- \+ option_value('had_interaction',true),
\+ is_converting, \+ is_compiling, \+ is_pyswip,!,
Expand Down
16 changes: 8 additions & 8 deletions prolog/metta_lang/metta_repl.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@
Prev = prev_result('Empty'),

% Print formatted answer output
in_answer_io(format('~n[')))),!,
in_answer_io(format('~N[')))),!,

% Interactive looping with possible timing and stepping control
(
Expand Down Expand Up @@ -1204,7 +1204,7 @@

),

in_answer_io((write(']'),if_t(\+is_mettalog,nl))),
in_answer_io((write(']\n'),if_t(\+is_mettalog, nop(nl)))),
flag(need_prompt,_,1),
ignore(Result = res(FOut)).

Expand All @@ -1227,11 +1227,11 @@

output_language(answers,(if_t(ResNum=<Max,
(
(((ResNum==1,Complete==true)->(old_not_compatio(format('~N~nDeterministic: ', [])), !); %or Nondet
(((ResNum==1,Complete==true)->(not_compatio(format('~N~nDeterministic: ', [])), !); %or Nondet
/* previously: handle deterministic result output */
(Complete==true -> (old_not_compatio(format('~N~nR(~w): ',[ResNum])),! );
old_not_compatio(format('~N~nN(~w): ',[ResNum]))))),
ignore(((
(Complete==true -> (not_compatio(format('~N~nR(~w): ',[ResNum])),! );
not_compatio(format('~N~nN(~w): ',[ResNum]))))),
not_compatio(ignore(((
if_t( \+ symbolic(Output), not_compatio(nop(nl))),
%if_t(ResNum==1,in_answer_io(format('~N['))),
% user_io
Expand All @@ -1240,7 +1240,7 @@
\+ \+
(maybe_name_vars(NamedVarsList),
old_not_compatio(write_bsrc(Output)),
true)))) )) ))))),
true)))) )) )))))),

in_answer_io(write_asrc((Output))),

Expand Down Expand Up @@ -1796,7 +1796,7 @@
% Print the compiled goal with formatting.
Call = do_metta_runtime(Res, Goal),
output_language(prolog, notrace((color_g_mesg('#114411', print_pl_source(:- Call))))),
call(Call).
nop(call(Call)).


%! verbose_unify(+Term) is det.
Expand Down
2 changes: 1 addition & 1 deletion prolog/metta_lang/metta_subst.pl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
set_last_error(_).
*/
subst_args1(Eq,RetType,Depth, Self, [OP|ARGS], Template):-
subst_args1(Eq,RetType,Depth, Self, [OP|ARGS], Template):-
is_space_op(OP), !,
subst_args_as(Depth, Self, [OP|ARGS], Template).

Expand Down
2 changes: 1 addition & 1 deletion prolog/metta_lang/metta_testing.pl
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@
!.
test_alarm :-
% Set time limit and attempt goal within 0.5 seconds.
time(catch(
(catch(
% Run goal with time limit; fail if it exceeds limit.
(call_with_time_limit(0.5,
(forall(between(1, 15, _), sleep(0.1)),
Expand Down

0 comments on commit ec5fed2

Please sign in to comment.