Share your repls and programming experiences

← Back to all posts
Python Compiler
CSharpIsGud (436)

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

Commentshotnewtop
NishyTheFishy (9)

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.

[deleted]

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

CodeSalvageON (527)

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

sugarfi (493)

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 (1968)

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

Jakman (324)

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

Warhawk947 (506)

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
        __PyValue__(else);
                    ^
CompileDir/output.cpp:23:14: error: expected expression
        __PyValue__(:);
                    ^
2 errors generated.
exit status 1
CSharpIsGud (436)

@Warhawk947 python program your compiling

DannyIsCoding (484)

This is really impressive

wulv (47)

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