Skip to content

Commit

Permalink
186| 27| 213| 87% | compat hyperon-experimental | baseline_compat/hyp…
Browse files Browse the repository at this point in the history
…eron-experimental_scripts
  • Loading branch information
TeamSPoon committed Dec 31, 2024
1 parent fcce533 commit ef77822
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 34 deletions.
9 changes: 6 additions & 3 deletions mettalog
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,8 @@ cleanup() {
else
METTA_CMD_EXIT_STATUS=${METTA_CMD_EXIT_STATUS:-$?}
fi
do_DEBUG "Exit code of METTA_CMD: $METTA_CMD_EXIT_STATUS to $HTML_OUT or $file_html or $HTML_FILE"

DEBUG "Exit code of METTA_CMD: $METTA_CMD_EXIT_STATUS to $HTML_OUT"

if [ ! -z "$TEE_FILE" ];then

Expand Down Expand Up @@ -1216,9 +1217,11 @@ if [[ "$html_flag" == "enable" ]]; then
export TEE_FILE

if [ ! -z "$HTML_OUT" ];then
HTML_OUT=$(readlink -m --relative-to="$(pwd)" "$HTML_OUT")
#HTML_OUT=$(realpath --relative-to="$(pwd)" "$HTML_OUT")
if [ ! -z "$OUTPUT_DIR" ] ;then
export METTALOG_OUTPUT="${OUTPUT_DIR}"
if [ -z "$METTALOG_OUTPUT" ] ;then
export METTALOG_OUTPUT="${OUTPUT_DIR}"
fi
# HTML_OUT="${OUTPUT_DIR}/${HTML_OUT}"
fi
fi
Expand Down
57 changes: 35 additions & 22 deletions prolog/metta_lang/metta_eval.pl
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@
% is_self_eval_l_fa('=',2).
% eval_20(Eq,RetType,Depth,Self,['quote',Eval],RetVal):- !, Eval = RetVal, check_returnval(Eq,RetType,RetVal).
is_self_eval_l_fa('quote',_).
%is_self_eval_l_fa('=',_):- nb_current(evaling_args,t).
%is_self_eval_l_fa(':',_):- nb_current(evaling_args,t).
is_self_eval_l_fa('Error',_).
is_self_eval_l_fa('{...}',_).
is_self_eval_l_fa('[...]',_).
Expand Down Expand Up @@ -1594,7 +1592,7 @@

eval_20( Eq, RetType, Depth, Self, [ 'parse' , L ] , Exp ):- !,
eval_args( Eq, RetType, Depth, Self, L, Str ),
once(read_metta( Str, Exp )).
once(parse_sexpr_metta1( Str, Exp )).

eval_20( _Eq, _RetType, _Depth, _Self, [ 'repr' , L ] , Sxx ):- !,
%eval_args( Eq, RetType, Depth, Self, L, Lis2 ),
Expand Down Expand Up @@ -2325,6 +2323,8 @@

suggest_type(_RetType,_Bool).

naive_eval_args:-
false.

eval_41(Eq,RetType,Depth,Self,[AE|More],Res):- naive_eval_args,!,
maplist(must_eval_args(Eq,_,Depth,Self),More,Adjusted),
Expand Down Expand Up @@ -2361,33 +2361,29 @@
if_or_else(eval_maybe_host_predicate(Eq,RetType,Depth,Self,PredDecl,Res),
if_or_else(eval_maybe_host_function(Eq,RetType,Depth,Self,PredDecl,Res), fail))).


naive_eval_args:- false_flag.
eval_all_args:- naive_eval_args.
eval_all_args:- fail, true_flag.
fail_missed_defn:- true_flag.
fail_on_constructor:- true_flag.


eval_adjust_args(Eq,RetType,ResIn,ResOut,Depth,Self,X,Y):-
if_or_else((eval_all_args,eval_adjust_args_niavely(Eq,RetType,ResIn,ResOut,Depth,Self,X,Y)),
eval_adjust_args_precise(Eq,RetType,ResIn,ResOut,Depth,Self,X,Y)).
if_or_else((eval_all_args,eval_adjust_args2(Eq,RetType,ResIn,ResOut,Depth,Self,X,Y)),
eval_adjust_args1(Eq,RetType,ResIn,ResOut,Depth,Self,X,Y)).

eval_adjust_args_precise(Eq,RetType,ResIn,ResOut,Depth,Self,[AE|More],[AE|Adjusted]):-
eval_adjust_args1(Eq,RetType,ResIn,ResOut,Depth,Self,[AE|More],[AE|Adjusted]):-
adjust_args_90(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted).
adjust_args_90(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted):- \+ is_debugging(eval_args),!,
adjust_args_91(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted).
adjust_args_9(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted).
adjust_args_90(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted):-
if_or_else(adjust_args_91(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted),
if_or_else(with_debug(eval_args,
adjust_args_91(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted),
if_or_else(More=Adjusted,
if_or_else(adjust_args_9(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted),
if_or_else(with_debug(eval_args,adjust_args_9(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted),
if_or_else(More=Adjusted,
if_or_else((trace, throw(adjust_args_9(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted)))))))).

adjust_args_91(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted):-
locally(nb_setval(evaling_args,t),adjust_args_9(Eq,RetType,ResIn,ResOut,Depth,Self,AE,More,Adjusted)).

eval_adjust_args_niavely(Eq,_RetType,ResIn,ResOut,Depth,Self,[AE|More],[AE|Adjusted]):-
locally(nb_setval(evaling_args,t),maplist(must_eval_args(Eq,_,Depth,Self),More,Adjusted)),

eval_adjust_args2(Eq,_RetType,ResIn,ResOut,Depth,Self,[AE|More],[AE|Adjusted]):-
maplist(must_eval_args(Eq,_,Depth,Self),More,Adjusted),
ResIn = ResOut.


Expand Down Expand Up @@ -2706,6 +2702,7 @@
len_or_unbound(_,_).


:-if(true).
:- nodebug(metta('defn')).

eval_maybe_defn(Eq,RetType,Depth,Self,X,Res):-
Expand Down Expand Up @@ -2750,11 +2747,28 @@
X=XX, Y=B0, X\=@=B0,
if_trace(e,color_g_mesg('#773700',indentq2(Depth,defs_used(USED)))),
light_eval(Eq,RetType,Depth,Self,B0,Y),!.
eval_defn_failure(Eq,RetType,Depth,Self,X,Res):-
eval_defn_failure(_Eq,_RetType,Depth,_Self,X,Res):-
if_trace(e,color_g_mesg('#773701',indentq2(Depth,defs_failed(X)))),
eval_constructor(Eq,RetType,Depth,Self,X,Res),
\+ fail_missed_defn.
!, \+ fail_missed_defn, X=Res.


:-else.
eval_maybe_defn(Eq,RetType,Depth,Self,X,Y):- can_be_ok(eval_maybe_defn,X),!,
trace_eval(eval_defn_choose_candidates(Eq,RetType),'defn',Depth,Self,X,Y).

eval_defn_choose_candidates(Eq,RetType,Depth,Self,X,Y):-
findall((XX->B0),get_defn_expansions(Eq,RetType,Depth,Self,X,XX,B0),XXB0L),
XXB0L\=[],!,
Depth2 is Depth-1,
if_trace((defn;metta_defn),
maplist(print_templates(Depth,' '),XXB0L)),!,
member(XX->B0,XXB0L), X=XX, Y=B0, X\=@=B0,
%(X==B0 -> trace; eval_args(Eq,RetType,Depth,Self,B0,Y)).
light_eval(Depth2,Self,B0,Y).
eval_defn_choose_candidates(_Eq,_RetType,_Depth,_Self,_X,_Y):- \+ is_debugging(metta_defn),!,fail.
eval_defn_choose_candidates(_Eq,_RetType,_Depth,_Self,X,_Y):-
color_g_mesg('#773700',write(no_def(X))),!,fail.
:- endif.

pl_clause_num(Head,Body,Ref,Index):-
clause(Head,Body,Ref),
Expand Down Expand Up @@ -3038,4 +3052,3 @@
eval_evals(_Eq,_Depth,_Self,_RetType,X,X):-!.



6 changes: 3 additions & 3 deletions prolog/metta_lang/metta_types.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@
% @arg Adjusted The result after evaluation.
%
eval_1_arg(Else, Eq, ReturnType, Depth, Self, Arg, Adjusted) :-
must_det_ll(
(
if_or_else(
eval(Eq, ReturnType, Depth, Self, Arg, Adjusted),
call(Else, Arg, Adjusted))).
Expand Down Expand Up @@ -1460,7 +1460,7 @@
into_typed_arg0(Depth, Self, T, M, Y) :-
% If the type is a variable, determine the value type and evaluate if needed.
var(T), !,
must_det_ll((
((
get_type(Depth, Self, M, T),
(wants_eval_kind(T) -> eval_args(Depth, Self, M, Y) ; Y = M))).
into_typed_arg0(Depth, Self, T, M, Y) :-
Expand Down Expand Up @@ -1870,7 +1870,7 @@
is_user_defined_head0(Eq, Other, H) :-
% If the head is callable, extract its functor and check it.
callable(H), !,
functor(H, F, _, _),
functor(H, F, _),
is_user_defined_head_f(Eq, Other, F).
is_user_defined_head0(Eq, Other, H) :-
% Default case: directly check the head.
Expand Down
6 changes: 3 additions & 3 deletions prolog/metta_lang/stdlib_mettalog.metta
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
(: get-ftype (-> Atom Atom)) ; returns only the function types of a symbol

(: pragma! (-> Atom Atom (->)))
(: = (-> Atom Atom %Undefined%))
;(: = (-> Atom Atom %Undefined%))
(: match (-> hyperon::space::DynSpace Atom Atom %Undefined%))
(: case (-> Expression Atom Atom))
(: combine (-> $t $t $t))
Expand Down Expand Up @@ -204,7 +204,7 @@ For example:

(predicate-arity predicate-arity 2)
(predicate-arity : 2)
;; (= (: $F P1) (predicate-arity $F 1))
(= (: $F P1) (predicate-arity $F 1))

;; Source Predicate and Function Types

Expand Down Expand Up @@ -311,7 +311,7 @@ For example:
(@param "Result of reduction or transformation of the first pattern")))
(@return "Not reduced itself unless custom equalities over equalities are added") )
(: = (-> $t $t Atom))
(: = (-> Atom Atom Atom))
;(: = (-> Atom Atom Atom))

(iz ErrorType MeTTa)
(@doc ErrorType (@desc "Type of the atom which contains error"))
Expand Down
6 changes: 3 additions & 3 deletions scripts/test_in_metta.sh
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,9 @@ while [ "$#" -gt 0 ]; do
--output=*) METTALOG_OUTPUT="${1#*=}" ;;
--report=*) generate_report_auto_reply="${1#*=}" ;;
--clean) clean=1; if_failures=0 ;;
--regression*) clean=0; if_failures=0; if_regressions=1 ;;
--continu*) clean=0; if_failures=0 ;;
--failure*) clean=0; if_failures=1 ;;
--regres*) clean=0; if_failures=0; if_regressions=1 ;;
--contin*) clean=0; if_failures=0 ;;
--fail*) clean=0; if_failures=1 ;;
--dry-run) dry_run=1 ;;
--test) dry_run=0 ; add_to_list "$1" passed_along_to_mettalog ;;
--fresh) fresh=1 ;;
Expand Down

0 comments on commit ef77822

Please sign in to comment.