push_quote_onto_expression
doesn't push an empty list, unlike push_quote() which does.
This commit is contained in:
parent
a9e4f93cdc
commit
6eae43c27f
|
|
@ -36,7 +36,9 @@ codi cons dip
|
||||||
codireco codi reco
|
codireco codi reco
|
||||||
dinfrirst dip infrst
|
dinfrirst dip infrst
|
||||||
dipd [dip] codi
|
dipd [dip] codi
|
||||||
disenstacken ? [uncons ?] loop pop'''.splitlines()
|
disenstacken ? [uncons ?] loop pop
|
||||||
|
swons swap cons
|
||||||
|
infra swons swaack [i] dip swaack'''.splitlines()
|
||||||
|
|
||||||
|
|
||||||
for line in defs:
|
for line in defs:
|
||||||
|
|
@ -72,5 +74,5 @@ print()
|
||||||
print()
|
print()
|
||||||
for line in defs:
|
for line in defs:
|
||||||
name, body = line.split(None, 1)
|
name, body = line.split(None, 1)
|
||||||
print(f'void def_{name}(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) {{ push_quote(def_{name}_body, expression); }}')
|
print(f'void def_{name}(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) {{ push_quote_onto_expression(def_{name}_body, expression); }}')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,15 @@ make_list_node(JoyList el)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
push_quote(JoyList el, JoyListPtr stack)
|
||||||
|
{
|
||||||
|
JoyList node = make_list_node(el);
|
||||||
|
node->tail = *stack;
|
||||||
|
*stack = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
JoyList
|
JoyList
|
||||||
pop_any(JoyListPtr stack)
|
pop_any(JoyListPtr stack)
|
||||||
{
|
{
|
||||||
|
|
@ -215,7 +224,7 @@ pop_list_node(JoyListPtr stack)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
push_quote(JoyList el, JoyListPtr expression)
|
push_quote_onto_expression(JoyList el, JoyListPtr expression)
|
||||||
{
|
{
|
||||||
JoyList node;
|
JoyList node;
|
||||||
|
|
||||||
|
|
@ -480,12 +489,6 @@ Instead, let's keep a stack of sub-expressions, reading from them
|
||||||
one-by-one, and prepending new sub-expressions to the stack rather than
|
one-by-one, and prepending new sub-expressions to the stack rather than
|
||||||
concatenating them.
|
concatenating them.
|
||||||
|
|
||||||
|
|
||||||
Return the next term from the expression and the new expression.
|
|
||||||
|
|
||||||
(item, quote), expression = expression
|
|
||||||
return item, push_quote(quote, expression)
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -506,7 +509,7 @@ next_term(JoyListPtr expression)
|
||||||
term = quote->head;
|
term = quote->head;
|
||||||
quote = quote->tail;
|
quote = quote->tail;
|
||||||
if (quote) {
|
if (quote) {
|
||||||
push_quote(quote, expression);
|
push_quote_onto_expression(quote, expression);
|
||||||
}
|
}
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
@ -563,14 +566,14 @@ cmp_joyfunc(JoyListPtr stack, JoyListPtr expression)
|
||||||
mpz_t *b = pop_int(stack);
|
mpz_t *b = pop_int(stack);
|
||||||
mpz_t *a = pop_int(stack);
|
mpz_t *a = pop_int(stack);
|
||||||
int hmm = mpz_cmp(*a, *b);
|
int hmm = mpz_cmp(*a, *b);
|
||||||
push_quote(((hmm > 0) ? G : (hmm < 0) ? L : E), expression);
|
push_quote_onto_expression(((hmm > 0) ? G : (hmm < 0) ? L : E), expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
i_joyfunc(JoyListPtr stack, JoyListPtr expression)
|
i_joyfunc(JoyListPtr stack, JoyListPtr expression)
|
||||||
{
|
{
|
||||||
push_quote(pop_list_node(stack), expression);
|
push_quote_onto_expression(pop_list_node(stack), expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -579,7 +582,7 @@ branch(JoyListPtr stack, JoyListPtr expression)
|
||||||
{
|
{
|
||||||
JoyList T = pop_list_node(stack);
|
JoyList T = pop_list_node(stack);
|
||||||
JoyList F = pop_list_node(stack);
|
JoyList F = pop_list_node(stack);
|
||||||
push_quote((pop_bool(stack) ? T : F), expression);
|
push_quote_onto_expression((pop_bool(stack) ? T : F), expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -652,8 +655,8 @@ dip(JoyListPtr stack, JoyListPtr expression)
|
||||||
JoyList x = EMPTY_LIST;
|
JoyList x = EMPTY_LIST;
|
||||||
JoyListPtr xPtr = &x;
|
JoyListPtr xPtr = &x;
|
||||||
push_thing(node->head, xPtr);
|
push_thing(node->head, xPtr);
|
||||||
push_quote(*xPtr, expression);
|
push_quote_onto_expression(*xPtr, expression);
|
||||||
push_quote(quote, expression);
|
push_quote_onto_expression(quote, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -725,26 +728,26 @@ JoyList def_dipd_body;
|
||||||
JoyList def_disenstacken_body;
|
JoyList def_disenstacken_body;
|
||||||
|
|
||||||
|
|
||||||
void def_abs(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_abs_body, expression); }
|
void def_abs(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_abs_body, expression); }
|
||||||
void def_anamorphism(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_anamorphism_body, expression); }
|
void def_anamorphism(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_anamorphism_body, expression); }
|
||||||
void def_app1(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_app1_body, expression); }
|
void def_app1(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_app1_body, expression); }
|
||||||
void def_app2(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_app2_body, expression); }
|
void def_app2(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_app2_body, expression); }
|
||||||
void def_app3(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_app3_body, expression); }
|
void def_app3(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_app3_body, expression); }
|
||||||
void def_appN(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_appN_body, expression); }
|
void def_appN(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_appN_body, expression); }
|
||||||
void def_at(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_at_body, expression); }
|
void def_at(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_at_body, expression); }
|
||||||
void def_average(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_average_body, expression); }
|
void def_average(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_average_body, expression); }
|
||||||
void def_b(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_b_body, expression); }
|
void def_b(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_b_body, expression); }
|
||||||
void def_binary(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_binary_body, expression); }
|
void def_binary(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_binary_body, expression); }
|
||||||
void def_ccccons(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_ccccons_body, expression); }
|
void def_ccccons(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_ccccons_body, expression); }
|
||||||
void def_ccons(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_ccons_body, expression); }
|
void def_ccons(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_ccons_body, expression); }
|
||||||
void def_cleave(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_cleave_body, expression); }
|
void def_cleave(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_cleave_body, expression); }
|
||||||
void def_clop(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_clop_body, expression); }
|
void def_clop(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_clop_body, expression); }
|
||||||
void def_cmp(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_cmp_body, expression); }
|
void def_cmp(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_cmp_body, expression); }
|
||||||
void def_codi(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_codi_body, expression); }
|
void def_codi(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_codi_body, expression); }
|
||||||
void def_codireco(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_codireco_body, expression); }
|
void def_codireco(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_codireco_body, expression); }
|
||||||
void def_dinfrirst(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_dinfrirst_body, expression); }
|
void def_dinfrirst(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_dinfrirst_body, expression); }
|
||||||
void def_dipd(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_dipd_body, expression); }
|
void def_dipd(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_dipd_body, expression); }
|
||||||
void def_disenstacken(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote(def_disenstacken_body, expression); }
|
void def_disenstacken(__attribute__((unused)) JoyListPtr stack, JoyListPtr expression) { push_quote_onto_expression(def_disenstacken_body, expression); }
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -791,7 +794,7 @@ joy(JoyListPtr stack, JoyListPtr expression)
|
||||||
const struct dict_entry *interned;
|
const struct dict_entry *interned;
|
||||||
JoyList e = EMPTY_LIST;
|
JoyList e = EMPTY_LIST;
|
||||||
JoyListPtr ePtr = &e;
|
JoyListPtr ePtr = &e;
|
||||||
push_quote(*expression, ePtr);
|
push_quote_onto_expression(*expression, ePtr);
|
||||||
expression = ePtr;
|
expression = ePtr;
|
||||||
|
|
||||||
while (*expression) {
|
while (*expression) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue