div and mod

This commit is contained in:
Simon Forman 2023-02-04 19:34:38 -08:00
parent 720f36a4c0
commit 6159165acd
4 changed files with 9 additions and 7 deletions

View File

@ -6,11 +6,11 @@
%}
struct dict_entry;
%%
"%", mod
"%", tdiv_r
*, mul
+, add
-, sub
/, div_joyfunc
/, tdiv_q
bool, truthy
branch, branch
clear, clear

View File

@ -516,8 +516,8 @@ name(JoyListPtr stack, __attribute__((unused)) JoyListPtr expression) \
{ \
mpz_t *a, *b; \
JoyList node; \
a = pop_int(stack); \
b = pop_int(stack); \
a = pop_int(stack); \
node = newIntNode(); \
mpz_ ## name(node->head->value.i, *a, *b); \
node->tail = *stack; \
@ -527,6 +527,8 @@ name(JoyListPtr stack, __attribute__((unused)) JoyListPtr expression) \
BINARY_MATH_OP(add)
BINARY_MATH_OP(sub)
BINARY_MATH_OP(mul)
BINARY_MATH_OP(tdiv_q)
BINARY_MATH_OP(tdiv_r)
/*

View File

@ -60,11 +60,11 @@ void add(JoyListPtr stack, JoyListPtr expression);
void branch(JoyListPtr stack, JoyListPtr expression);
void clear(JoyListPtr stack, JoyListPtr expression);
void cmp_joyfunc(JoyListPtr stack, JoyListPtr expression);
void div_joyfunc(JoyListPtr stack, JoyListPtr expression);
void i_joyfunc(JoyListPtr stack, JoyListPtr expression);
void mod(JoyListPtr stack, JoyListPtr expression);
void mul(JoyListPtr stack, JoyListPtr expression);
void sub(JoyListPtr stack, JoyListPtr expression);
void tdiv_q(JoyListPtr stack, JoyListPtr expression);
void tdiv_r(JoyListPtr stack, JoyListPtr expression);
void truthy(JoyListPtr stack, JoyListPtr expression);

View File

@ -107,11 +107,11 @@ in_word_set (register const char *str, register size_t len)
{"branch", branch},
{""}, {""},
#line 9 "KEYWORDS.txt"
{"%", mod},
{"%", tdiv_r},
#line 11 "KEYWORDS.txt"
{"+", add},
#line 13 "KEYWORDS.txt"
{"/", div_joyfunc},
{"/", tdiv_q},
{""}, {""}, {""},
#line 10 "KEYWORDS.txt"
{"*", mul},