Skip to content

Commit

Permalink
Sometimes its nice to have the output of the transpiler shown in a _t…
Browse files Browse the repository at this point in the history
…ransout.pl
  • Loading branch information
TeamSPoon committed Nov 30, 2024
1 parent 2e85478 commit f7c0849
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/canary/metta_runtime.pl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
write_answers_aux([H|List]):- write_src_woi(H), write(', '), write_answers_aux(List).


do_file_top(Var,Call):-
do_metta_runtime(Var,Call):-
with_output_to(user_error, findall(Var,Call,List)),
with_output_to(user_error, metta_runtime_write_answers(List)),
write_answer_output.
Expand Down
39 changes: 38 additions & 1 deletion tests/direct_comp/easy/format_args_transout.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
% Info: File /home/deb12user/metta-wam/tests/direct_comp/easy/format_args.metta is 2.29K bytes (66 lines)

:- ensure_loaded('/home/deb12user/metta-wam-royward-dev/src/canary/metta_runtime').

% Begin transpiler output

% [[prolog_if,[[assign,_21680,[]],[assign,_21382,[call(==),$VAR(x),_21680]],[native(is_True),_21382]],[[assign,_21120,$VAR(y)]],[[assign,$VAR(h),[call(car-atom),$VAR(x) ]],[assign,$VAR(t),[call(cdr-atom),$VAR(x)]],[assign,$VAR(rest),[call(append),$VAR(t),$VAR(y)]],[assign,_21928,[call(cons-atom),$VAR(h),$VAR(rest)]],[assign,_21120,_2 1928]]]]:- dynamic mc__append/3.
:- multifile mc__append/3.

Expand Down Expand Up @@ -94,6 +98,7 @@
metta_compiled_predicate('&self', 'mc__format-args-aux', 4).
metta_compiled_predicate('&self', mc__nth, 3).
metta_compiled_predicate('&self', mc__append, 3).
*/

% [[assign,$VAR(format-chars),[call(stringToChars),$VAR(format)]],[assign,$VAR(formatted),[call(format-args-aux),$VAR(format-chars),$VAR(args),0]],[assign,_105818,[call (charsToString),$VAR(formatted)]]]:- dynamic'mc__format-argsx'/3.
Expand All @@ -113,3 +118,35 @@
metta_compiled_predicate('&self', mc__nth, 3).
metta_compiled_predicate('&self', mc__append, 3).

% ;;; Tests

:- begin_metta_runtime.

:- do_metta_runtime(A,
'mc__format-argsx'("{}ab", ["XX", "ZZ"], A)).

:- do_metta_runtime(A,
mc__append([1, 2], [3, 5], A)).

:- do_metta_runtime(A,
mc__nth(3, [10, 11, 12, 13, 14, 15], A)).

:- do_metta_runtime(A,
'mc__format-argsx'("ab", ["XX", "ZZ"], A)).

:- do_metta_runtime(A,
'mc__format-argsx'("{ab", ["XX", "ZZ"], A)).

:- do_metta_runtime(A,
'mc__format-argsx'("a{b", ["XX", "ZZ"], A)).

:- do_metta_runtime(A,
'mc__format-argsx'("{}a{b", ["XX", "ZZ"], A)).

:- do_metta_runtime(A,
'mc__format-argsx'("{}a{}b", ["XX", "ZZ"], A)).

:- do_metta_runtime(A,
'mc__format-argsx'("a{}b{}", ["XX", "ZZ"], A)).

:- end_metta_runtime.

0 comments on commit f7c0849

Please sign in to comment.