Share your repls and programming experiences

← Back to all posts
Python Compiler
CSharpIsGud (1048)

A real python compiler!

For now it only supports a small amount of the syntax.

This compiler compiles python directly to C, which then gets compiled to a native executable(which means its much MUCH faster than normal python).

Only variables, if statements and function calls are implemented right now.

Currently I just have it running a small program that tells you if two numbers add up to a target number

NishyTheFishy (10)

Forgive me for not knowing that much, but where is the compiler in this? It seems like just a regular thing to check if two numbers equal a target.


@NishyTheFishy the compiler is every file but . It is compiling

CodeSalvageON (604)

this is god level compared to the crap thats on the talk pages.

sugarfi (630)

You should just compile to asm directly instead of generating C. Also it might be better to use Python bytecode instead of raw Python source. Cool though!

DynamicSquid (4919)

Cool! Isn't this just creating your own language with a Python syntax?

Jakman (449)

Nice. Very quality in content. Much better than what I can make.

Warhawk947 (524)

I got an error:

 clang++-7 -pthread -std=c++17 -o main compiler.cpp lex.cpp main.cpp parser.cpp && ./main && clang++ CompileDir/output.cpp -o compiled && ./compiled
CompileDir/output.cpp:21:14: error: expected expression
CompileDir/output.cpp:23:14: error: expected expression
2 errors generated.
exit status 1
CSharpIsGud (1048)

@Warhawk947 python program your compiling

DannyIsCoding (698)

This is really impressive

wulv (61)

OMG this is awesome! You should definitely work more on it.