A simple Compiler
- OS£ºWindows10, Mac
- Programming Language£ºC + llvm + Python
- C-Version£ºC11
- Python-Version£ºPython3
Remember to use python3.
For Linux user you can simply run
sudo apt-get install llvm
For Mac OS user you can simply run
brew install homebrew/versions/llvm38
You can also install llvm by compling the source code.
pip install llvmlite
pip install PLY
To Run source code, you can use the follow script
python main.py [-o outfile] infile
For example
python main.py KMP.c
Another example
python main.py -o test.ll KMP.c
You can use pyinstaller
to pack it.
lex.py
: The lex define of compileryacc.py
: The yacc define of compilerPrecompiler.py
: The Precompiler of compilerIRLibs.py
: The IR libs to generate IR codeCompiler.py
: The compiler core to parse syntax treemain.py
: The entry to run compilerDebug.py
: Run compiler to compiletest.c
filetest.c
': You can put your test code here when debugging