From e5f1790da66d1ed8d4a997e170aadca2e2587bb1 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Tue, 2 Jul 2024 12:03:44 -0700 Subject: [PATCH] Continue with eval updates --- src/toolsrc/drawl.pla | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/toolsrc/drawl.pla b/src/toolsrc/drawl.pla index 38c29b1..1705893 100644 --- a/src/toolsrc/drawl.pla +++ b/src/toolsrc/drawl.pla @@ -366,23 +366,36 @@ end // Install default native functions // +def eval_atom(atom)#2 // return type, val + var atomtype, atomval + + when atom->type + is BOOL_FALSE + is BOOL_TRUE + is LIT_NUM + is VAR_NUM + is LIT_CHR + is VAR_CHR + is LIT_STR + is VAR_STR + is ARG_TYPE + wend + return atom->type, atomval +end + def natv_atom(expr) return expr->type <> CONS_TYPE ?? @pred_true :: @pred_false end def natv_eq(expr) - var atom1, atom2, val1, val2 + var type1, type2, val1, val2 - atom1 = expr=>car=>prop - atom2 = expr=>cdr=>car=>prop - - if atom1->type == LIT_NUM or atom1->type == VAR_NUM - val1 = atom1=>numval + type1, val1 = eval_atom(expr=>car=>prop) + type2, val2 = eval_atom(expr=>cdr=>car=>prop) + if type1 == type2 + return val1 == val2 ?? @pred_true :: @pred_false fin - if atom2->type == LIT_NUM or atom2->type == VAR_NUM - val2 = atom2=>numval - fin - return NULL + return @pred_false end def natv_cons(expr)