This is the source code Tutorial. Lcc is based llvm c99 compiler. You can click this to visit my video and this compiler tutorial.
This project will implement almost all ISO C99 syntax and can work on Windows, Linux and Mac OS X.
ISO C 99 Doc link (pdf file): C99
Module | Status |
---|---|
Preprocess | working... |
Lexer | 100% |
Parser | 100% |
Semantics | 5% |
CodeGen | working... |
catch2 will be integrated in the future
一:Install the latest LLVM library
Mac:
----------------------
1, install homebrew
reference: https://brew.sh/
or reference: https://brew.idayer.com/
2, brew install llvm
Linux:
----------------------
1, sudo apt-get update
2, sudo apt-get -y install llvm-12
Windows:
----------------------
reference: https://blog.csdn.net/kingfox/article/details/117450533
二:Build LLVM manually
git clone https://github.com/llvm/llvm-project.git
cd llvm-project/llvm && mkdir llvm_install_dir && mkdir build
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../llvm_install_dir ../llvm
一:Compile
1, git clone [email protected]:iiicp/lcc.git
2, cd lcc && mkdir build && cd build
3, cmake -GNinja -DLLVM_DIR="Path to Your LLVM CMake dir" ..
4, ninja
二:Run
lcc support --dumpTokens and --dumpAst command line options
./lcc --help
./lcc -emit-tokens ../tests/c/stmt.c
./lcc -emit-ast ../tests/c/stmt.c
- unicode char
- _Complex
- direct-declarator ( identifier-list{opt} )
eg: int f(a, b) int a,b {return a+b;}