Reworked the directory structure, added start of test framework

This commit is contained in:
Johan B.W. de Vries 2025-02-02 14:25:16 +01:00
parent f798fbe55f
commit ad99832959
16 changed files with 399 additions and 256 deletions

4
0-lang0py/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/lang0py
/lang0py.c
/lang0py.exe
/lang0py.o

21
0-lang0py/Makefile Normal file
View File

@ -0,0 +1,21 @@
.SUFFIXES:
PYVERSION=3.10
PYPREFIX=/usr
INCLUDES=-I$(PYPREFIX)/include/python$(PYVERSION)
CYTHON=cython3
# No previous iteration to reference
all: lang0py.exe
%.exe: %.o
gcc -o $@ $< -lpython$(PYVERSION)
%.o: %.c
gcc -c $< $(INCLUDES)
%.c: %.py
$(CYTHON) -3 --embed $<
clean:
rm -f lang0py.c lang0py.o lang0py.exe

4
0-lang0py/lang0py.lang0 Normal file
View File

@ -0,0 +1,4 @@
; This file does not exit
; Iteration 0 is always writing a compiler in an existing environment
; Sometimes that means binary, sometimes that means assembly
; Luckily, for us this means we can use Python.

4
1-lang0py/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/lang0py*.c
/lang0py*.exe
/lang0py*.o
/lang0py*.py

36
1-lang0py/Makefile Normal file
View File

@ -0,0 +1,36 @@
.SUFFIXES:
PYVERSION=3.10
PYPREFIX=/usr
INCLUDES=-I$(PYPREFIX)/include/python$(PYVERSION)
CYTHON=cython3
LANG0PY=$(CURDIR)/../0-lang0py/lang0py.exe
all: lang0py.exe
%.exe: %.o
gcc -o $@ $< -lpython$(PYVERSION)
%.o: %.c
gcc -c $< $(INCLUDES)
%.c: %.py
$(CYTHON) -3 --embed $<
lang0py0.py: lang0py.lang0 $(LANG0PY)
cat $< | $(LANG0PY) > $@
lang0py1.py: lang0py.lang0 lang0py0.exe
cat $< | ./lang0py0.exe > $@
# Cannot diff on the first iteration - platform change
lang0py2.py: lang0py.lang0 lang0py1.exe
cat $< | ./lang0py1.exe > $@
-diff lang0py1.py lang0py2.py
lang0py.py: lang0py.lang0 lang0py2.exe
cat $< | ./lang0py2.exe > $@
-diff lang0py2.py lang0py.py
clean:
rm -f lang0py*.py lang0py*.c lang0py*.o lang0py*.exe

4
2-lang0c/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/lang0c*.c
/lang0c*.exe
/lang0c*.o
/lang0c*.py

42
2-lang0c/Makefile Normal file
View File

@ -0,0 +1,42 @@
.SUFFIXES:
PYVERSION=3.10
PYPREFIX=/usr
INCLUDES=
CYTHON=cython3
LANG0PY=$(CURDIR)/../1-lang0py/lang0py.exe
all: lang0c.exe
%.exe: %.o
gcc -o $@ $<
%.o: %.c
gcc -c $<
lang0c0.py: lang0c.lang0 $(LANG0PY)
cat $< | $(LANG0PY) > $@
lang0c0.c: lang0c0.py
$(CYTHON) -3 --embed $<
lang0c0.o: lang0c0.c
gcc -c $< -I$(PYPREFIX)/include/python$(PYVERSION)
lang0c0.exe: lang0c0.o
gcc -o $@ $< -lpython$(PYVERSION)
lang0c1.c: lang0c.lang0 lang0c0.exe
cat $< | ./lang0c0.exe > $@
# Cannot diff on the first iteration - platform change
lang0c2.c: lang0c.lang0 lang0c1.exe
cat $< | ./lang0c1.exe > $@
-diff lang0c1.c lang0c2.c
lang0c.c: lang0c.lang0 lang0c2.exe
cat $< | ./lang0c2.exe > $@
-diff lang0c2.c lang0c.c
clean:
rm -f lang0c*.py lang0c*.c lang0c*.o lang0c*.exe

View File

@ -1,69 +1,11 @@
.SUFFIXES: all:
$(MAKE) -C 0-lang0py all
GCC_FLAGS := -g -O0 -Wall $(MAKE) -C 1-lang0py all
$(MAKE) -C 2-lang0c all
$(MAKE) -C tests all
all: it2-out
# it0-out.py => Hand made
it1-out0.py: it0-out.py it1-in.lang0
cat it1-in.lang0 | python3 it0-out.py > it1-out0.py
it1-out1.py: it1-out0.py it1-in.lang0
cat it1-in.lang0 | python3 it1-out0.py > it1-out1.py
# We can diff here since the target hasn't changed
# The target for it0 is the same as for it1
diff it1-out0.py it1-out1.py
it1-out2.py: it1-out1.py it1-in.lang0
cat it1-in.lang0 | python3 it1-out1.py > it1-out2.py
diff it1-out1.py it1-out2.py
it1-out3.py: it1-out2.py it1-in.lang0
cat it1-in.lang0 | python3 it1-out2.py > it1-out3.py
diff it1-out2.py it1-out3.py
it1-out.py: it1-out3.py
cp it1-out3.py it1-out.py
it2-out0.py: it1-out.py it2-in.lang0
cat it2-in.lang0 | python3 it1-out.py > it2-out0.py
# No gcc step since the target is still python here
it2-out1.c: it2-out0.py it2-in.lang0
cat it2-in.lang0 | python3 it2-out0.py > it2-out1.c
# diff it2-out0.py it2-out1.py Do not diff - the target changed so the output will be different
it2-out1: it2-out1.c
gcc it2-out1.c -o it2-out1 $(GCC_FLAGS)
it2-out2.c: it2-out1 it2-in.lang0
cat it2-in.lang0 | ./it2-out1 > it2-out2.c
diff it2-out1.c it2-out2.c
it2-out2: it2-out2.c
gcc it2-out2.c -o it2-out2 $(GCC_FLAGS)
it2-out3.c: it2-out2 it2-in.lang0
cat it2-in.lang0 | ./it2-out2 > it2-out3.c
diff it2-out2.c it2-out3.c
it2-out3: it2-out3.c
gcc it2-out3.c -o it2-out3 $(GCC_FLAGS)
it2-out: it2-out3
cp it2-out3 it2-out
clean: clean:
-rm it1-out* it2-out* $(MAKE) -C 0-lang0py clean
$(MAKE) -C 1-lang0py clean
$(MAKE) -C 2-lang0c clean
$(MAKE) -C tests clean

View File

@ -9,7 +9,7 @@
"x": 725, "x": 725,
"y": 306, "y": 306,
"width": 197, "width": 197,
"height": 76, "height": 60,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -25,8 +25,8 @@
"type": 3 "type": 3
}, },
"seed": 902003894, "seed": 902003894,
"version": 28, "version": 30,
"versionNonce": 1349374006, "versionNonce": 882148575,
"isDeleted": false, "isDeleted": false,
"boundElements": [ "boundElements": [
{ {
@ -34,16 +34,16 @@
"id": "vC6ze8D2C_8xamOti_FDo" "id": "vC6ze8D2C_8xamOti_FDo"
} }
], ],
"updated": 1736684246699, "updated": 1738501880052,
"link": null, "link": null,
"locked": false "locked": false
}, },
{ {
"id": "vC6ze8D2C_8xamOti_FDo", "id": "vC6ze8D2C_8xamOti_FDo",
"type": "text", "type": "text",
"x": 752.9500732421875, "x": 734.580078125,
"y": 319, "y": 311,
"width": 141.099853515625, "width": 177.83984375,
"height": 50, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -58,20 +58,20 @@
"index": "a0V", "index": "a0V",
"roundness": null, "roundness": null,
"seed": 1788670826, "seed": 1788670826,
"version": 19, "version": 31,
"versionNonce": 1785814954, "versionNonce": 1178825919,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684250287, "updated": 1738501880052,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it0-out.py\n(hand written)", "text": "0-lang0py/lang0py\n(hand written)",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "sa5DlHhxpJaKEJJQyQzX0", "containerId": "sa5DlHhxpJaKEJJQyQzX0",
"originalText": "it0-out.py\n(hand written)", "originalText": "0-lang0py/lang0py\n(hand written)",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -133,7 +133,7 @@
"version": 68, "version": 68,
"versionNonce": 1195221302, "versionNonce": 1195221302,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684348736, "updated": 1736684348736,
"link": null, "link": null,
"locked": false, "locked": false,
@ -205,7 +205,7 @@
"version": 482, "version": 482,
"versionNonce": 2052650218, "versionNonce": 2052650218,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1736684934138,
"link": null, "link": null,
"locked": false, "locked": false,
@ -277,7 +277,7 @@
"version": 115, "version": 115,
"versionNonce": 1274068970, "versionNonce": 1274068970,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684445213, "updated": 1736684445213,
"link": null, "link": null,
"locked": false, "locked": false,
@ -349,7 +349,7 @@
"version": 179, "version": 179,
"versionNonce": 2088933354, "versionNonce": 2088933354,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684949700, "updated": 1736684949700,
"link": null, "link": null,
"locked": false, "locked": false,
@ -421,7 +421,7 @@
"version": 219, "version": 219,
"versionNonce": 600803830, "versionNonce": 600803830,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684961559, "updated": 1736684961559,
"link": null, "link": null,
"locked": false, "locked": false,
@ -493,7 +493,7 @@
"version": 529, "version": 529,
"versionNonce": 1524384362, "versionNonce": 1524384362,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1736684934138,
"link": null, "link": null,
"locked": false, "locked": false,
@ -565,7 +565,7 @@
"version": 580, "version": 580,
"versionNonce": 973746154, "versionNonce": 973746154,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1736684934138,
"link": null, "link": null,
"locked": false, "locked": false,
@ -637,7 +637,7 @@
"version": 628, "version": 628,
"versionNonce": 632995178, "versionNonce": 632995178,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1736684934138,
"link": null, "link": null,
"locked": false, "locked": false,
@ -689,9 +689,9 @@
{ {
"id": "wbK8T0IJWC6QMWKFsflZU", "id": "wbK8T0IJWC6QMWKFsflZU",
"type": "text", "type": "text",
"x": 593.9500732421875, "x": 593.7700576782227,
"y": 135, "y": 135,
"width": 141.099853515625, "width": 141.4598846435547,
"height": 50, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -706,20 +706,20 @@
"index": "a0l", "index": "a0l",
"roundness": null, "roundness": null,
"seed": 864846774, "seed": 864846774,
"version": 138, "version": 145,
"versionNonce": 1358166378, "versionNonce": 1419718257,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684351221, "updated": 1738502492344,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it1-in.lang0\n(hand written)", "text": "1-lang0py/\nlang0py0.lang0",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "JpWSt6KcCpoXnoEq_GCJp", "containerId": "JpWSt6KcCpoXnoEq_GCJp",
"originalText": "it1-in.lang0\n(hand written)", "originalText": "1-lang0py/\nlang0py0.lang0",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -761,9 +761,9 @@
{ {
"id": "Mj0dEWiGr1Z9qT8mn8V3K", "id": "Mj0dEWiGr1Z9qT8mn8V3K",
"type": "text", "type": "text",
"x": 1356.4500732421875, "x": 1361.7000579833984,
"y": 132.5, "y": 132.5,
"width": 141.099853515625, "width": 130.59988403320312,
"height": 50, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -778,20 +778,20 @@
"index": "a0l2", "index": "a0l2",
"roundness": null, "roundness": null,
"seed": 779040554, "seed": 779040554,
"version": 554, "version": 565,
"versionNonce": 365292266, "versionNonce": 874960209,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1738502506673,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it2-in.lang0\n(hand written)", "text": "2-lang0c/\nlang0c0.lang0",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "xdt3-HzXEKTWxrWigJjiT", "containerId": "xdt3-HzXEKTWxrWigJjiT",
"originalText": "it2-in.lang0\n(hand written)", "originalText": "2-lang0c/\nlang0c0.lang0",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -833,9 +833,9 @@
{ {
"id": "5pAueU5y4qXjdgix_f5pa", "id": "5pAueU5y4qXjdgix_f5pa",
"type": "text", "type": "text",
"x": 768.9500732421875, "x": 768.7700576782227,
"y": -61, "y": -61,
"width": 141.099853515625, "width": 141.4598846435547,
"height": 50, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -850,20 +850,20 @@
"index": "a0l8", "index": "a0l8",
"roundness": null, "roundness": null,
"seed": 471340598, "seed": 471340598,
"version": 242, "version": 243,
"versionNonce": 645687542, "versionNonce": 896719295,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684455955, "updated": 1738502495388,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it1-in.lang0\n(hand written)", "text": "1-lang0py/\nlang0py0.lang0",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "Vi9eTOIjQtbNC7zF_5rwS", "containerId": "Vi9eTOIjQtbNC7zF_5rwS",
"originalText": "it1-in.lang0\n(hand written)", "originalText": "1-lang0py/\nlang0py0.lang0",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -905,9 +905,9 @@
{ {
"id": "hOjP8z6dti8Z5hpgB3d5b", "id": "hOjP8z6dti8Z5hpgB3d5b",
"type": "text", "type": "text",
"x": 903.9500732421875, "x": 903.7700576782227,
"y": -252.25, "y": -252.25,
"width": 141.099853515625, "width": 141.4598846435547,
"height": 50, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -922,20 +922,20 @@
"index": "a0l8G", "index": "a0l8G",
"roundness": null, "roundness": null,
"seed": 1843097770, "seed": 1843097770,
"version": 308, "version": 309,
"versionNonce": 1508581622, "versionNonce": 1367318047,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684957255, "updated": 1738502496300,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it1-in.lang0\n(hand written)", "text": "1-lang0py/\nlang0py0.lang0",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "nq35O_LXfbGnImWL9Qc06", "containerId": "nq35O_LXfbGnImWL9Qc06",
"originalText": "it1-in.lang0\n(hand written)", "originalText": "1-lang0py/\nlang0py0.lang0",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -977,9 +977,9 @@
{ {
"id": "P9GsVng_mlohB8reiaQaw", "id": "P9GsVng_mlohB8reiaQaw",
"type": "text", "type": "text",
"x": 1042.7000732421875, "x": 1042.5200576782227,
"y": -443.5, "y": -443.5,
"width": 141.099853515625, "width": 141.4598846435547,
"height": 50, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -994,20 +994,20 @@
"index": "a0l8O", "index": "a0l8O",
"roundness": null, "roundness": null,
"seed": 1003079478, "seed": 1003079478,
"version": 348, "version": 349,
"versionNonce": 1453458550, "versionNonce": 63585919,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684961559, "updated": 1738502497243,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it1-in.lang0\n(hand written)", "text": "1-lang0py/\nlang0py0.lang0",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "sm_C3kQH3NnoN8GY0WsHa", "containerId": "sm_C3kQH3NnoN8GY0WsHa",
"originalText": "it1-in.lang0\n(hand written)", "originalText": "1-lang0py/\nlang0py0.lang0",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1049,9 +1049,9 @@
{ {
"id": "ypQvCIgox5Ez78rMw8nJk", "id": "ypQvCIgox5Ez78rMw8nJk",
"type": "text", "type": "text",
"x": 1531.4500732421875, "x": 1536.7000579833984,
"y": -62.5, "y": -62.5,
"width": 141.099853515625, "width": 130.59988403320312,
"height": 50, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -1066,20 +1066,20 @@
"index": "a0lC", "index": "a0lC",
"roundness": null, "roundness": null,
"seed": 1922220522, "seed": 1922220522,
"version": 659, "version": 660,
"versionNonce": 1812183146, "versionNonce": 1720655071,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1738502509525,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it2-in.lang0\n(hand written)", "text": "2-lang0c/\nlang0c0.lang0",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "FkKqusUxwu0Fdxigv0fZW", "containerId": "FkKqusUxwu0Fdxigv0fZW",
"originalText": "it2-in.lang0\n(hand written)", "originalText": "2-lang0c/\nlang0c0.lang0",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1121,9 +1121,9 @@
{ {
"id": "5JR6I1qRvymfZUCUFUEiC", "id": "5JR6I1qRvymfZUCUFUEiC",
"type": "text", "type": "text",
"x": 1693.4500732421875, "x": 1698.7000579833984,
"y": -248.5, "y": -248.5,
"width": 141.099853515625, "width": 130.59988403320312,
"height": 50, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -1138,20 +1138,20 @@
"index": "a0lE", "index": "a0lE",
"roundness": null, "roundness": null,
"seed": 887058026, "seed": 887058026,
"version": 720, "version": 721,
"versionNonce": 1951147498, "versionNonce": 1934701887,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1738502510388,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it2-in.lang0\n(hand written)", "text": "2-lang0c/\nlang0c0.lang0",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "EIr70q6Ecsh_k_mhXX_d1", "containerId": "EIr70q6Ecsh_k_mhXX_d1",
"originalText": "it2-in.lang0\n(hand written)", "originalText": "2-lang0c/\nlang0c0.lang0",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1193,9 +1193,9 @@
{ {
"id": "2mQPed9SFteJcR4z6zGyt", "id": "2mQPed9SFteJcR4z6zGyt",
"type": "text", "type": "text",
"x": 1803.4500732421875, "x": 1808.7000579833984,
"y": -429.5, "y": -429.5,
"width": 141.099853515625, "width": 130.59988403320312,
"height": 50, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
@ -1210,20 +1210,20 @@
"index": "a0lF", "index": "a0lF",
"roundness": null, "roundness": null,
"seed": 1202851626, "seed": 1202851626,
"version": 768, "version": 769,
"versionNonce": 1685533546, "versionNonce": 1994500511,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1738502511204,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it2-in.lang0\n(hand written)", "text": "2-lang0c/\nlang0c0.lang0",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "P5YHIvfxndgZtpw2M194q", "containerId": "P5YHIvfxndgZtpw2M194q",
"originalText": "it2-in.lang0\n(hand written)", "originalText": "2-lang0c/\nlang0c0.lang0",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1233,7 +1233,7 @@
"x": 876, "x": 876,
"y": 121, "y": 121,
"width": 195.0000000000001, "width": 195.0000000000001,
"height": 74.99999999999999, "height": 60,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1249,8 +1249,8 @@
"type": 3 "type": 3
}, },
"seed": 1738165110, "seed": 1738165110,
"version": 320, "version": 322,
"versionNonce": 242867434, "versionNonce": 348133425,
"isDeleted": false, "isDeleted": false,
"boundElements": [ "boundElements": [
{ {
@ -1258,17 +1258,17 @@
"type": "text" "type": "text"
} }
], ],
"updated": 1736684364282, "updated": 1738501921397,
"link": null, "link": null,
"locked": false "locked": false
}, },
{ {
"id": "MFQOMZ3Q8GWnWIOy737f6", "id": "MFQOMZ3Q8GWnWIOy737f6",
"type": "text", "type": "text",
"x": 920.2900619506836, "x": 911.3100509643555,
"y": 146, "y": 126,
"width": 106.41987609863281, "width": 124.37989807128906,
"height": 25, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1282,27 +1282,27 @@
"index": "a0t", "index": "a0t",
"roundness": null, "roundness": null,
"seed": 781897450, "seed": 781897450,
"version": 334, "version": 341,
"versionNonce": 1304604586, "versionNonce": 722253937,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684364282, "updated": 1738502436384,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it1-out0.py", "text": "1-lang0py/\nlang0py0.exe",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "xhGx8DjmbBrbJtwOztMKw", "containerId": "xhGx8DjmbBrbJtwOztMKw",
"originalText": "it1-out0.py", "originalText": "1-lang0py/\nlang0py0.exe",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
{ {
"id": "V4SlwrmLxEj5lu0skBUJ1", "id": "V4SlwrmLxEj5lu0skBUJ1",
"type": "rectangle", "type": "rectangle",
"x": 1638.5, "x": 1636.8333333333335,
"y": 118.5, "y": 118.5,
"width": 195.0000000000001, "width": 195.0000000000001,
"height": 74.99999999999999, "height": 74.99999999999999,
@ -1321,8 +1321,8 @@
"type": 3 "type": 3
}, },
"seed": 1180838326, "seed": 1180838326,
"version": 735, "version": 736,
"versionNonce": 1456551466, "versionNonce": 183022687,
"isDeleted": false, "isDeleted": false,
"boundElements": [ "boundElements": [
{ {
@ -1330,17 +1330,17 @@
"type": "text" "type": "text"
} }
], ],
"updated": 1736684934138, "updated": 1738502399176,
"link": null, "link": null,
"locked": false "locked": false
}, },
{ {
"id": "uq1n89eIzIoEF64MTNtC0", "id": "uq1n89eIzIoEF64MTNtC0",
"type": "text", "type": "text",
"x": 1680.0600662231445, "x": 1677.5733846028647,
"y": 143.5, "y": 131,
"width": 111.87986755371094, "width": 113.5198974609375,
"height": 25, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1354,20 +1354,20 @@
"index": "a0tG", "index": "a0tG",
"roundness": null, "roundness": null,
"seed": 1735849130, "seed": 1735849130,
"version": 750, "version": 769,
"versionNonce": 1549590762, "versionNonce": 368020433,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1738502474072,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it2-out0.py", "text": "2-lang0c/\nlang0c0.exe",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "V4SlwrmLxEj5lu0skBUJ1", "containerId": "V4SlwrmLxEj5lu0skBUJ1",
"originalText": "it2-out0.py", "originalText": "2-lang0c/\nlang0c0.exe",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1409,10 +1409,10 @@
{ {
"id": "Y8BLkvSVXeE_VCIsnaqRY", "id": "Y8BLkvSVXeE_VCIsnaqRY",
"type": "text", "type": "text",
"x": 1055.2600555419922, "x": 1046.280044555664,
"y": -52.00000000000001, "y": -64.5,
"width": 102.47988891601562, "width": 120.43991088867188,
"height": 25, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1426,20 +1426,20 @@
"index": "a0u", "index": "a0u",
"roundness": null, "roundness": null,
"seed": 15431402, "seed": 15431402,
"version": 394, "version": 402,
"versionNonce": 1445402998, "versionNonce": 624349585,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684465162, "updated": 1738502440183,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it1-out1.py", "text": "1-lang0py/\nlang0py1.exe",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "q7GdmXdIkEVil1E7K3Vtv", "containerId": "q7GdmXdIkEVil1E7K3Vtv",
"originalText": "it1-out1.py", "originalText": "1-lang0py/\nlang0py1.exe",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1481,10 +1481,10 @@
{ {
"id": "nB2NHk0Nl6BGmmPd2LQlN", "id": "nB2NHk0Nl6BGmmPd2LQlN",
"type": "text", "type": "text",
"x": 1187.5300598144531, "x": 1178.550048828125,
"y": -243.25, "y": -255.75,
"width": 107.93988037109375, "width": 125.89990234375,
"height": 25, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1498,20 +1498,20 @@
"index": "a0u2", "index": "a0u2",
"roundness": null, "roundness": null,
"seed": 993774442, "seed": 993774442,
"version": 460, "version": 466,
"versionNonce": 789420906, "versionNonce": 407639167,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684954094, "updated": 1738502442119,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it1-out2.py", "text": "1-lang0py/\nlang0py2.exe",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "4tXC4CO1352XEGgn5ZWPo", "containerId": "4tXC4CO1352XEGgn5ZWPo",
"originalText": "it1-out2.py", "originalText": "1-lang0py/\nlang0py2.exe",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1553,10 +1553,10 @@
{ {
"id": "K8FKdMdbEtQXcBMy_4JGQ", "id": "K8FKdMdbEtQXcBMy_4JGQ",
"type": "text", "type": "text",
"x": 1327.2000579833984, "x": 1324.3000411987305,
"y": -434.5, "y": -447,
"width": 106.09988403320312, "width": 111.89991760253906,
"height": 25, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1570,20 +1570,20 @@
"index": "a0u3", "index": "a0u3",
"roundness": null, "roundness": null,
"seed": 414675062, "seed": 414675062,
"version": 502, "version": 507,
"versionNonce": 1109378358, "versionNonce": 47527537,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684963415, "updated": 1738502444576,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it1-out3.py", "text": "1-lang0py/\nlang0py.exe",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "_njzXhKgPzadFQfgDnI_E", "containerId": "_njzXhKgPzadFQfgDnI_E",
"originalText": "it1-out3.py", "originalText": "1-lang0py/\nlang0py.exe",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1625,10 +1625,10 @@
{ {
"id": "-3hZTUkUzcwcd4qQ6tH9Q", "id": "-3hZTUkUzcwcd4qQ6tH9Q",
"type": "text", "type": "text",
"x": 1533.4500579833984, "x": 1530.5500411987305,
"y": 324.25, "y": 311.75,
"width": 106.09988403320312, "width": 111.89991760253906,
"height": 25, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1642,20 +1642,20 @@
"index": "a0u8", "index": "a0u8",
"roundness": null, "roundness": null,
"seed": 1942100970, "seed": 1942100970,
"version": 523, "version": 527,
"versionNonce": 1708469866, "versionNonce": 1763250065,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1738502452896,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it1-out3.py", "text": "1-lang0py/\nlang0py.exe",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "ZjoMA7OeaNnjNpaVjFLsc", "containerId": "ZjoMA7OeaNnjNpaVjFLsc",
"originalText": "it1-out3.py", "originalText": "1-lang0py/\nlang0py.exe",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1697,10 +1697,10 @@
{ {
"id": "gSS5ui-65NHgMOUQh5qaI", "id": "gSS5ui-65NHgMOUQh5qaI",
"type": "text", "type": "text",
"x": 1820.8600616455078, "x": 1814.2100448608398,
"y": -54.5, "y": -67,
"width": 96.27987670898438, "width": 109.57991027832031,
"height": 25, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1714,20 +1714,20 @@
"index": "a0uV", "index": "a0uV",
"roundness": null, "roundness": null,
"seed": 2126958442, "seed": 2126958442,
"version": 761, "version": 771,
"versionNonce": 1958222826, "versionNonce": 1871453791,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1738502478104,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it2-out1.c", "text": "2-lang0c/\nlang0c1.exe",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "_dSfxbsy4dHEcZZ5zwehT", "containerId": "_dSfxbsy4dHEcZZ5zwehT",
"originalText": "it2-out1.c", "originalText": "2-lang0c/\nlang0c1.exe",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1769,10 +1769,10 @@
{ {
"id": "0RfiY6ME4YQvG93V4ZTf7", "id": "0RfiY6ME4YQvG93V4ZTf7",
"type": "text", "type": "text",
"x": 1922.1300659179688, "x": 1915.4800491333008,
"y": -233.5, "y": -246,
"width": 101.7398681640625, "width": 115.03990173339844,
"height": 25, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1786,20 +1786,20 @@
"index": "a0uZ", "index": "a0uZ",
"roundness": null, "roundness": null,
"seed": 1038423094, "seed": 1038423094,
"version": 823, "version": 832,
"versionNonce": 1725802858, "versionNonce": 606612113,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1738502480152,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it2-out2.c", "text": "2-lang0c/\nlang0c2.exe",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "7AT_y3BQx_MTOK2YJ5gyT", "containerId": "7AT_y3BQx_MTOK2YJ5gyT",
"originalText": "it2-out2.c", "originalText": "2-lang0c/\nlang0c2.exe",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1841,10 +1841,10 @@
{ {
"id": "yJu3JDSgZH2EElzwcEo8a", "id": "yJu3JDSgZH2EElzwcEo8a",
"type": "text", "type": "text",
"x": 2038.050064086914, "x": 2037.4800415039062,
"y": -418.5, "y": -431,
"width": 99.89987182617188, "width": 101.0399169921875,
"height": 25, "height": 50,
"angle": 0, "angle": 0,
"strokeColor": "#1e1e1e", "strokeColor": "#1e1e1e",
"backgroundColor": "transparent", "backgroundColor": "transparent",
@ -1858,20 +1858,20 @@
"index": "a0ub", "index": "a0ub",
"roundness": null, "roundness": null,
"seed": 1154290486, "seed": 1154290486,
"version": 865, "version": 868,
"versionNonce": 69064426, "versionNonce": 1145930655,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1738502483040,
"link": null, "link": null,
"locked": false, "locked": false,
"text": "it2-out3.c", "text": "2-lang0c/\nlang0c.exe",
"fontSize": 20, "fontSize": 20,
"fontFamily": 5, "fontFamily": 5,
"textAlign": "center", "textAlign": "center",
"verticalAlign": "middle", "verticalAlign": "middle",
"containerId": "wtdGNdh8BUiQz-JxcpA_L", "containerId": "wtdGNdh8BUiQz-JxcpA_L",
"originalText": "it2-out3.c", "originalText": "2-lang0c/\nlang0c.exe",
"autoResize": true, "autoResize": true,
"lineHeight": 1.25 "lineHeight": 1.25
}, },
@ -1900,7 +1900,7 @@
"version": 59, "version": 59,
"versionNonce": 2125545782, "versionNonce": 2125545782,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684495257, "updated": 1736684495257,
"link": null, "link": null,
"locked": false, "locked": false,
@ -1946,7 +1946,7 @@
"version": 124, "version": 124,
"versionNonce": 1720455530, "versionNonce": 1720455530,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684957255, "updated": 1736684957255,
"link": null, "link": null,
"locked": false, "locked": false,
@ -1992,7 +1992,7 @@
"version": 163, "version": 163,
"versionNonce": 1556910134, "versionNonce": 1556910134,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684961559, "updated": 1736684961559,
"link": null, "link": null,
"locked": false, "locked": false,
@ -2038,7 +2038,7 @@
"version": 472, "version": 472,
"versionNonce": 550988202, "versionNonce": 550988202,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1736684934138,
"link": null, "link": null,
"locked": false, "locked": false,
@ -2084,7 +2084,7 @@
"version": 532, "version": 532,
"versionNonce": 2119214186, "versionNonce": 2119214186,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1736684934138,
"link": null, "link": null,
"locked": false, "locked": false,
@ -2130,7 +2130,7 @@
"version": 579, "version": 579,
"versionNonce": 911509290, "versionNonce": 911509290,
"isDeleted": false, "isDeleted": false,
"boundElements": null, "boundElements": [],
"updated": 1736684934138, "updated": 1736684934138,
"link": null, "link": null,
"locked": false, "locked": false,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 143 KiB

12
tests/.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
/*.it0
/*.it0.c
/*.it0.o
/*.it0.py
/*.it1
/*.it1.c
/*.it1.o
/*.it1.py
/*.it2
/*.it2.c
/*.it2.o
/*.results

71
tests/Makefile Normal file
View File

@ -0,0 +1,71 @@
.SUFFIXES:
.PHONY: all clean
PYVERSION=3.10
PYPREFIX=/usr
CYTHON=cython3
CC=gcc
TESTLIST=$(shell ls *.lang0 | sed 's/.lang0//')
all: all-it0.results all-it1.results all-it2.results
all-it0.results: $(addsuffix .it0, $(TESTLIST))
-rm -f $@
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; ./$(test).it0 >> $@ ; echo "" >> $@)
! grep -v 'Success' $@
all-it1.results: $(addsuffix .it1, $(TESTLIST))
-rm -f $@
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; ./$(test).it1 >> $@ ; echo "" >> $@)
! grep -v 'Success' $@
all-it2.results: $(addsuffix .it2, $(TESTLIST))
-rm -f $@
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; ./$(test).it2 >> $@ ; echo "" >> $@)
! grep -v 'Success' $@
clean:
-rm -f *.result *.it0* *.it1* *.it2*
###
# it0
%.it0.py: %.lang0 ../0-lang0py/lang0py.exe
cat $< | ../0-lang0py/lang0py.exe > $@
%.it0.c: %.it0.py
$(CYTHON) -3 --embed -o $@ $^
%.it0.o: %.it0.c
$(CC) -c $^ -I$(PYPREFIX)/include/python$(PYVERSION)
%.it0: %.it0.o
$(CC) -o $@ $^ -lpython$(PYVERSION)
###
# it1
%.it1.py: %.lang0 ../1-lang0py/lang0py.exe
cat $< | ../1-lang0py/lang0py.exe > $@
%.it1.c: %.it1.py
$(CYTHON) -3 --embed -o $@ $^
%.it1.o: %.it1.c
$(CC) -c $^ -I$(PYPREFIX)/include/python$(PYVERSION)
%.it1: %.it1.o
$(CC) -o $@ $^ -lpython$(PYVERSION)
###
# it2
%.it2.c: %.lang0 ../2-lang0c/lang0c.exe
cat $< | ../2-lang0c/lang0c.exe > $@
%.it2.o: %.it2.c
$(CC) -c $^ -I$(PYPREFIX)/include/python$(PYVERSION)
%.it2: %.it2.o
$(CC) -o $@ $^ -lpython$(PYVERSION)

3
tests/emit.lang0 Normal file
View File

@ -0,0 +1,3 @@
main:
emit "Success"
/