Skip to content

Commit

Permalink
:- dynamic(enabled_log_progress/0).
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Dec 2, 2024
1 parent 9fb8a9b commit 7adcbee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
34 changes: 18 additions & 16 deletions src/canary/metta_debug.pl
Original file line number Diff line number Diff line change
Expand Up @@ -771,32 +771,31 @@
log_file_type(prolog).


into_blocktype(InfoType,Goal):- !,
enter_markdown(InfoType),!,
Goal.
%setup_call_cleanup(format('~N```~w~n',[InfoType]),Goal, format('~N```~n',[])).
into_blocktype(InfoType,Goal):- enter_markdown(InfoType),!,call(Goal).

into_blocktype(InfoType,Goal):- log_file_type(markdown), !,
setup_call_cleanup(format('~N```~w~n',[InfoType]),Goal, format('~N```~n',[])).

into_blocktype(InfoType,Goal):- log_file_type(prolog), !,
setup_call_cleanup(format('~N```~w~n',[InfoType]),Goal, format('~N```~n',[])).

into_blocktype(InfoType,Goal):- log_file_type(prolog), !,
setup_call_cleanup(format('~N/*~n```~w~n*/~n',[InfoType]),Goal, format('~N/*~n```~n*/~n',[])).
%into_blocktype(InfoType,Goal):- log_file_type(markdown), !, setup_call_cleanup(format('~N```~w~n',[InfoType]),Goal, format('~N```~n',[])).
%into_blocktype(InfoType,Goal):- log_file_type(prolog), !, setup_call_cleanup(format('~N```~w~n',[InfoType]),Goal, format('~N```~n',[])).
%into_blocktype(InfoType,Goal):- log_file_type(prolog), !, setup_call_cleanup(format('~N/*~n```~w~n*/~n',[InfoType]),Goal, format('~N/*~n```~n*/~n',[])).

output_language( InfoType, Goal ) :- log_file_type(Lang), !, % (Lang==prolog; Lang==metta),!,
((InfoType == Lang -> (must_det_ll((enter_markdown(Lang),leave_comment)),call(Goal)) ; (must_det_ll(enter_comment),into_blocktype(InfoType,Goal)))).

output_language( InfoType, Goal ) :- log_file_type(markdown), !, into_blocktype(InfoType,Goal).
output_language( comment, Goal ) :- log_file_type(markdown), !, call(Goal).
output_language( comment, Goal ) :- log_file_type(prolog), !, format('~N:- q.~n', [output_language( comment, Goal)]).
output_language( comment, Goal ) :- log_file_type(metta), !, in_cmt(Goal).
%output_language( InfoType, Goal ) :- log_file_type(markdown), !, into_blocktype(InfoType,Goal).
%output_language( comment, Goal ) :- log_file_type(markdown), !, call(Goal).
%output_language( comment, Goal ) :- log_file_type(prolog), !, format('~N:- q.~n', [output_language( comment, Goal)]).
%output_language( comment, Goal ) :- log_file_type(metta), !, in_cmt(Goal).

:- dynamic(enabled_save_markdown/0).



:- dynamic(inside_comment/0).
leave_comment:- \+ enabled_save_markdown, !.
leave_comment:- inside_comment,!, format('~N*/~n~n'),retract(inside_comment).
leave_comment.

enter_comment:- \+ enabled_save_markdown, !.
enter_comment:- inside_comment,!.
enter_comment:- format('~N~n/*~n'),assert(inside_comment).
:- enter_comment.
Expand All @@ -806,10 +805,13 @@


:- dynamic(inside_markdown/1).
leave_markdown(_):- \+ enabled_save_markdown, !.
leave_markdown(_):- \+ inside_markdown(_),!.
leave_markdown(Lang):- inside_markdown(Lang),!, format('~N```~n'),retract(inside_markdown(Lang)).
leave_markdown(_):- !. % inside_markdown(Other),!,leave_markdown(Other).
%leave_markdown(_):- inside_markdown(Other),!,leave_markdown(Other).
leave_markdown(_Lang):- !. %format('~N```~n'),!.

enter_markdown(_):- \+ enabled_save_markdown, !.
enter_markdown(Lang):- inside_markdown(Lang),!.
enter_markdown(Lang):- inside_markdown(Other),!,leave_markdown(Other),!,enter_markdown(Lang).
enter_markdown(Lang):- log_file_type(Us),Us=Lang,inside_comment,!,format('~N```~w~n',[Lang]),asserta(inside_markdown(Lang)),leave_comment.
Expand Down
12 changes: 6 additions & 6 deletions src/canary/metta_interp.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1787,9 +1787,9 @@
give_up(Why),pp_m(red,gave_up(Why)))).
%format("########################X2 ~w ~w ~w\n",[Self,TermV,FOut]).


o_s(['assertEqual'|O],S):- nonvar(O), o_s(O,S).
o_s(['assertEqualToResult'|O],S):- nonvar(O), o_s(O,S).
a_e('assertEqual'). a_e('assertNotEqual').
a_e('assertEqualToResult'). a_e('assertNotEqualToResult').
o_s([AE|O],S):- nonvar(AE), a_e(AE), nonvar(O), o_s(O,S).
o_s([O|_],S):- nonvar(O), !, o_s(O,S).
o_s(S,S).
into_simple_op(Load,[Op|O],op(Load,Op,S)):- o_s(O,S),!.
Expand Down Expand Up @@ -1853,7 +1853,7 @@
do_metta(true,exec,Self,Form,_Out).
eval_H(Term,X):- catch_metta_return(eval_args(Term,X),X).

eval_H(StackMax,Self,Term,X):- fast_option_value(compile, save),!.
eval_H(_StackMax,_Self, Term,Term):- fast_option_value(compile, save),!.
eval_H(StackMax,Self,Term,X):- catch_metta_return(eval_args('=',_,StackMax,Self,Term,X),X).
/*
eval_H(StackMax,Self,Term,X).
Expand Down Expand Up @@ -2241,7 +2241,7 @@
%:- ensure_loaded(metta_help).

:- enter_comment.

:- current_prolog_flag(stack_limit,X),X_16 is X * 16, set_prolog_flag(stack_limit,X_16).
:- initialization(use_corelib_file).
:- initialization(use_metta_ontology).

Expand All @@ -2268,7 +2268,7 @@

% Flush any pending output to ensure smooth runtime interactions
flush_metta_output :-
with_output_to(user_error, (write_answer_output, ttyflush)).
write_answer_output, ttyflush.

% Write out answers in hyperon-experimental format to user_error
metta_runtime_write_answers(List) :-
Expand Down
2 changes: 2 additions & 0 deletions src/canary/metta_parser.pl
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@
%
% @arg Fmt The format string used by ansi_format/3.
% @arg Args The arguments to be used in the format string.
:- dynamic(enabled_log_progress/0).
log_progress(_Fmt, _Args):- \+ enabled_log_progress, !.
log_progress(Fmt, Args):-
ttyflush,
io_to_err(ansi_format([bold, hfg(black)], Fmt, Args)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,11 @@
```prolog
*/

:- do_metta_runtime(A, mc__nqueens(12, A)).
:- do_metta_runtime(A, mc__nqueens(13, A)).
:- do_metta_runtime(A, mc__nqueens(14, A)).
%:- do_metta_runtime(A, mc__nqueens(12, A)).
%:- do_metta_runtime(A, mc__nqueens(13, A)).
%:- do_metta_runtime(A, mc__nqueens(14, A)). 500 secs
:- do_metta_runtime(A, mc__nqueens(15, A)).
%:- do_metta_runtime(A, mc__nqueens(16, A)).


/*
Expand Down

0 comments on commit 7adcbee

Please sign in to comment.