From 94bcd2aa51c8db44e7c33a7ff1eaedb8e1a9f60d Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Tue, 7 Feb 2023 20:47:32 -0800 Subject: [PATCH] Minor cleanup. --- implementations/C/joy.c | 51 ++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/implementations/C/joy.c b/implementations/C/joy.c index 2e12012..6bdcfb3 100644 --- a/implementations/C/joy.c +++ b/implementations/C/joy.c @@ -80,27 +80,6 @@ my_callback(GC_PTR void_obj, __attribute__((unused)) GC_PTR void_environment) { JoyList -push_integer_from_str(char *str, JoyList tail) -{ - JoyList el = newJoyList; - el->head = newJoyType; - el->head->kind = joyInt; - mpz_init_set_str(el->head->value.i, str, 10); - GC_register_finalizer(el->head->value.i, my_callback, NULL, NULL, NULL); - el->tail = tail; - return el; -} - - -char * -trim_leading_blanks(char *str) -{ - size_t offset = strspn(str, BLANKS); - return (offset == strlen(str)) ? NULL : (str + offset); -} - - -JoyList make_non_list_node(char *text, size_t size) { char *sym; @@ -229,17 +208,6 @@ pop_list(JoyListPtr stack) } -void -push_quote_onto_expression(JoyList el, JoyListPtr expression) -{ - JoyList node; - if (!el) return; - node = make_list_node(el); - node->tail = *expression; - *expression = node; -} - - JoyList newIntNode(void) { JoyList node = newJoyList; @@ -361,6 +329,14 @@ print_stack(JoyList el) */ +char * +trim_leading_blanks(char *str) +{ + size_t offset = strspn(str, BLANKS); + return (offset == strlen(str)) ? NULL : (str + offset); +} + + JoyList parse_list(char **text) { @@ -505,6 +481,17 @@ concatenating them. */ +void +push_quote_onto_expression(JoyList el, JoyListPtr expression) +{ + JoyList node; + if (!el) return; + node = make_list_node(el); + node->tail = *expression; + *expression = node; +} + + JoyTypePtr next_term(JoyListPtr expression) { -- 2.11.0