a silly toy to compile python to c
include_lib("stdio.h")
def main() -> int:
puts("hi")
return 0
python -m twoc example.c.py
#include <stdio.h>
int
main(void) {
puts("hi");
return 0;
}
run flag pipes the output to tcc
python -m twoc -run example.c.py
STDOUT:
hi
x while
x for
x continue
x break
x if
switch
print macro
struct/union, inherit from Struct or Union like ctypes
typedef
enum
cast to type
goto & labels
pointers
arrays
unions
in
match
class
with
is
ctypes
i = 42
a = pointer(i)
print(a.contents) deref
addressof(i) or i.addressof
byref
cast(obj, type)
- dict
- list
- set
- interned strings
twoc is simple and ignorant
threec will track contents and scope
play with silly hacky ideas
add dependancy graph server + client
data, cap, len
link settings saved in file e.g. SDL
swizzle rgb bgr like Odin?
a:int = 0
a.print()
int a = 0;
int__print(&a)
a = 128
int a = 128;