GithubHelp home page GithubHelp logo

twoc's Introduction

twoc

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

tests

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

python syntax

in
match
class
with
is

ctypes
i = 42
a = pointer(i)
print(a.contents) deref
addressof(i) or i.addressof
byref
cast(obj, type)

python types

  • dict
  • list
  • set
  • interned strings

threec

twoc is simple and ignorant

threec will track contents and scope

play with silly hacky ideas

repl

add dependancy graph server + client

areans

fat arrays

data, cap, len

default argument values

store compiler settings inside the file

link settings saved in file e.g. SDL

silly ideas

wikipedia swizzling

swizzle rgb bgr like Odin?

Member functions

a:int = 0
a.print()
int a = 0;
int__print(&a)

inver variable type on first use

a = 128
int a = 128;

twoc's People

Contributors

willbr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.