This commit is contained in:
Simon Forman 2023-02-04 23:45:13 -08:00
parent 7874496090
commit b1a06979c2
2 changed files with 40 additions and 12 deletions

View File

@ -1,3 +1,18 @@
'''
It's cheap, but it works.
Doesn't handle non-alnum names.
Because the strings are parsed at start time, rather than compile time,
it's basically the same as implementing an inscribe command
and using it to write a simple Joy script to load the defs:
for line in defs:
print(f'[{line}] inscribe')
Eh?
'''
import sys
#list(open('../defs.txt'))

View File

@ -583,26 +583,39 @@ clear(JoyListPtr stack, __attribute__((unused)) JoyListPtr expression)
void
truthy(JoyListPtr stack, JoyListPtr expression)
truthy(JoyListPtr stack, __attribute__((unused)) JoyListPtr expression)
{
stack = expression;
}
/*
JoyListPtr s = stack;
/*
Keep the original stack in case the top item is already a Boolean value.
*/
JoyList s = *stack;
JoyList node = pop_any(stack);
switch (node->head->kind) {
case joyTrue:
stack = s;
*stack = s;
break;
case joyFalse:
stack = s;
*stack = s;
break;
case joyInt:
push_thing(
if (node->head->value.i);
if mpz_cmp_si(node->head->value.i, 0) {
push_thing(JoyTrue, stack);
} else {
push_thing(JoyFalse, stack);
}
break;
case joyList:
if (node->head->value.el) {
push_thing(JoyTrue, stack);
} else {
push_thing(JoyFalse, stack);
}
break;
default:
stack = expression;
printf("Cannot Boolify.\n");
exit(1);
}
}
*/
JoyList def_abs_body;