Skip to content

Commit

Permalink
Sometimes its nice to have the output of the transpiler shown in a file
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSPoon committed Nov 30, 2024
1 parent 8f8e295 commit 2e85478
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/canary/metta_runtime.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

% File that is loaded from LSP server and transpiled MeTTa files so all the options such as not starting the REPL and things happen
:- (prolog_load_context(directory, Value);Value='.'), absolute_file_name('../packs/',Dir,[relative_to(Value)]),
atom_concat(Dir,'predicate_streams',PS),
atom_concat(Dir,'logicmoo_utils',LU),
attach_packs(Dir,[duplicate(replace),search(first)]),
pack_attach(PS,[duplicate(replace),search(first)]),
pack_attach(LU,[duplicate(replace),search(first)]).

:- set_prolog_flag(mettalog_rt, true),
set_prolog_flag(mettalog_rt_args, []),
set_prolog_flag(metta_argv, []).

:- set_prolog_flag(argv,[]),
set_prolog_flag(os_argv,[swipl]).


:- % user:ensure_loaded(metta_compiler_lib),!,
user:ensure_loaded(metta_interp),!,
user:loon.


metta_runtime_write_answers(List):- write('['),write_answers_aux(List), write(']'),nl.
write_answers_aux(List):- List == [], !.
write_answers_aux([H|List]):- List == [], !, write_src_woi(H).
write_answers_aux([H|List]):- write_src_woi(H), write(', '), write_answers_aux(List).


do_file_top(Var,Call):-
with_output_to(user_error, findall(Var,Call,List)),
with_output_to(user_error, metta_runtime_write_answers(List)),
write_answer_output.

begin_metta_runtime:- write_answer_output.

end_metta_runtime:- write_answer_output.


0 comments on commit 2e85478

Please sign in to comment.