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'''\
/*
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:
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)
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)
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)
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;
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");
}
- /*
- 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); }