From ccbf8d2b4cfdbce46ef8e1c9eb86bd66d8f37067 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sun, 5 Feb 2023 13:53:53 -0800 Subject: [PATCH] minor cleanup --- implementations/C/convert_defs.py | 41 ++++++++++++------------------- implementations/C/definitions.c | 31 +++++++++++------------ 2 files changed, 31 insertions(+), 41 deletions(-) diff --git a/implementations/C/convert_defs.py b/implementations/C/convert_defs.py index 9a2a8a7..ac3f694 100644 --- a/implementations/C/convert_defs.py +++ b/implementations/C/convert_defs.py @@ -39,13 +39,6 @@ disenstacken ? [uncons ?] loop pop swons swap cons infra swons swaack [i] dip swaack'''.splitlines() -## -##for line in defs: -## name, body = line.split(None, 1) -## print(f'{name}, def_{name}') -## -##print() -##print() print(f'''\ /* @@ -60,7 +53,6 @@ if sys.argv[-1] == '--header': name, body = line.split(None, 1) print(f'void def_{name}(JoyListPtr stack, JoyListPtr expression);') - elif sys.argv[-1] == '--keywords': sys.stdout.write(open('KEYWORDS.in').read()) for line in defs: @@ -68,16 +60,15 @@ elif sys.argv[-1] == '--keywords': print(f'{name}, def_{name}') else: - - print(''' - #include "joy.h" - #include "definitions.h" + print('''\ +#include "joy.h" +#include "definitions.h" - /* - Declare a bunch of list pointers to eventually hold the body expressions - of the definitions. - */ +/* +Declare a bunch of list pointers to eventually hold the body expressions +of the definitions. +*/ ''') for line in defs: name, body = line.split(None, 1) @@ -87,13 +78,13 @@ else: print(''' - /* - Next, we want an initializer function to fill out the body pointers. - */ +/* +Next, we want an initializer function to fill out the body pointers. +*/ - void - init_defs(void) - { +void +init_defs(void) +{ ''') for line in defs: name, body = line.split(None, 1) @@ -104,9 +95,9 @@ else: print(''' - /* - Last, a set of functions to go in the wordlist, one for each definition. - */ +/* +Last, a set of functions to go in the wordlist, one for each definition. +*/ ''') for line in defs: name, body = line.split(None, 1) diff --git a/implementations/C/definitions.c b/implementations/C/definitions.c index 3e26150..c423aa3 100644 --- a/implementations/C/definitions.c +++ b/implementations/C/definitions.c @@ -3,15 +3,14 @@ Auto-generated file by convert_defs.py Do not edit. */ - - #include "joy.h" - #include "definitions.h" +#include "joy.h" +#include "definitions.h" - /* - Declare a bunch of list pointers to eventually hold the body expressions - of the definitions. - */ +/* +Declare a bunch of list pointers to eventually hold the body expressions +of the definitions. +*/ JoyList def_abs_body; JoyList def_anamorphism_body; @@ -36,13 +35,13 @@ JoyList def_swons_body; JoyList def_infra_body; - /* - Next, we want an initializer function to fill out the body pointers. - */ +/* +Next, we want an initializer function to fill out the body pointers. +*/ - void - init_defs(void) - { +void +init_defs(void) +{ def_abs_body = text_to_expression("dup 0 < [] [neg] branch"); def_anamorphism_body = text_to_expression("[pop []] swap [dip swons] genrec"); @@ -68,9 +67,9 @@ JoyList def_infra_body; } - /* - Last, a set of functions to go in the wordlist, one for each definition. - */ +/* +Last, a set of functions to go in the wordlist, one for each definition. +*/ 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_onto_expression(def_anamorphism_body, expression); }