Skip to content

Commit 7d3f49b

Browse files
committed
Not worse
1 parent c7ef5d0 commit 7d3f49b

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

prolog/metta_lang/metta_compiler.pl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@
7474
:- ensure_loaded(metta_space).
7575
:- ensure_loaded(metta_compiler_print).
7676
:- dynamic(transpiler_clause_store/9).
77+
:- multifile(transpiler_predicate_store/7).
7778
:- dynamic(transpiler_predicate_store/7).
79+
:- dynamic(transpiler_predicate_nary_store/9).
80+
:- discontiguous transpiler_predicate_nary_store/9.
7881
:- discontiguous(compile_flow_control/8).
82+
:- multifile(compile_flow_control/8).
7983
:- ensure_loaded(metta_compiler_lib).
8084
:- ensure_loaded(metta_compiler_lib_stdlib).
8185

prolog/metta_lang/metta_eval.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@
556556
maplist(as_prolog_x(Depth,Self), [Sym|Args] , [ASym|Adjusted]),
557557
eval_20(Eq,RetType,Depth,Self, [ASym|Adjusted], Y),sanity_check_eval(eval_20_not_atom,Y).
558558

559-
eval_20(_Eq,_RetType,Depth,_Self,X,YO):- Depth<0,bt,trace,!,X=YO.
559+
eval_20(_Eq,_RetType,Depth,_Self,X,YO):- overflow_depth(Depth),bt,trace,!,X=YO.
560560
eval_20(Eq,RetType,_Dpth,_Slf,Name,Y):-
561561
atom(Name), !,
562562
(Name=='NotReducible'->throw(metta_NotReducible);

prolog/metta_lang/metta_printer.pl

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,14 +1857,20 @@
18571857
last_item([Item],Item).
18581858

18591859
write_start(Type):- current_printer_override(P1),call(P1,'$write_start'(Type)),!.
1860-
write_start(Char):- atom_length(Char, 1),write(Char),!.
1861-
write_start(Type):- compound_type_s_m_e(Type,L,_,_),write(L),!.
1860+
write_start(Char):- is_str_char(Char),write_ch(Char),!.
1861+
write_start(Type):- compound_type_s_m_e(Type,L,_,_),write_ch(L),!.
18621862
write_middle(Type):- current_printer_override(P1),call(P1,'$write_middle'(Type)),!.
1863-
write_middle(Char):- atom_length(Char, 1),write(Char),!.
1864-
write_middle(Type):- compound_type_s_m_e(Type,_,M,_),write(M),!.
1863+
write_middle(Char):- is_str_char(Char),write_ch(Char),!.
1864+
write_middle(Type):- compound_type_s_m_e(Type,_,M,_), write_ch(M),!.
18651865
write_end(Type):- current_printer_override(P1),call(P1,'$write_end'(Type)),!.
1866-
write_end(Char):- atom_length(Char, 1),write(Char),!.
1867-
write_end(Type):- compound_type_s_m_e(Type,_,_,R),write(R),!.
1866+
write_end(Char):- is_str_char(Char),write_ch(Char),!.
1867+
write_end(Type):- compound_type_s_m_e(Type,_,_,R),write_ch(R),!.
1868+
1869+
is_str_char( L ):- compound(L),arg(1,L,C),!,is_str_char(C).
1870+
is_str_char(Char):- atomic(Char), atom_length(Char, 1),!.
1871+
1872+
write_ch(L):- compound(L),arg(1,L,C),!,write_ch(C).
1873+
write_ch(L):- assertion(L\==cmpd),write(L).
18681874

18691875
print_compound_type(Indent, Type, [H|T] ):-
18701876
last_item([H|T],Last),
@@ -1880,7 +1886,7 @@
18801886

18811887

18821888
compound_type_s_m_e(list,'(','.',')').
1883-
compound_type_s_m_e(cmpd,S,E,M):- prolog_term_start(S),compound_type_s_m_e(ocmpd,S,E,M),!.
1889+
compound_type_s_m_e(cmpd,S,E,M):- !, prolog_term_start(S),compound_type_s_m_e(ocmpd,S,E,M),!.
18841890
compound_type_s_m_e(ocmpd,'#(','.',')').
18851891
compound_type_s_m_e(ocmpd,'[','|',']').
18861892
compound_type_s_m_e(ocmpd,'{','|','}').
@@ -1895,12 +1901,12 @@
18951901

18961902
% Print the rest of the elements in the list, ensuring spacing
18971903
print_rest_elements(_,T, _) :- T==[], !.
1898-
print_rest_elements(M, T, Indent) :- \+ is_lcons(T), !, write(' '), write(M), write(' '), print_sexpr(T, Indent).
1899-
print_rest_elements(M, [H|T], Indent) :-
1904+
print_rest_elements(Type, T, Indent) :- \+ is_lcons(T), !, write(' '), write_middle(Type), write(' '), print_sexpr(T, Indent).
1905+
print_rest_elements(Type, [H|T], Indent) :-
19001906
write(' '), % Space before each element after the first
19011907
print_sexpr(H, Indent),
19021908
(is_lcons(H) -> NextIndent is Indent + 0 ; NextIndent is Indent + 0),
1903-
print_rest_elements(M, T, NextIndent).
1909+
print_rest_elements(Type, T, NextIndent).
19041910

19051911
% Helper predicate to print indentation spaces
19061912

0 commit comments

Comments
 (0)