Lcc
llvm-based c compiler
Install / Use
/learn @iiicp/LccREADME
lcc: A Based Of LLVM C Compiler
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
Current Status:
| Module | Status |
| ---- |------------|
| Preprocess | working... |
| Lexer | 100% |
| Parser | 100% |
| Semantics | 5% |
| CodeGen | working... |
Test Status:
catch2 will be integrated in the future
Compile and Run
Install the latest LLVM library or Build LLVM manually
一: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
How to use lcc
一:Compile
1, git clone git@github.com: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
lcc unsupported c99 language features
- unicode char
- _Complex
- direct-declarator ( identifier-list{opt} )
eg: int f(a, b) int a,b {return a+b;}
Reference
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
