A compiler for the CypLang programming language — a French pseudo-code language that compiles to native executables via LLVM. Developed in C as part of an algorithms and compilation course.
Pipeline: .cyp source → Lexer → Parser/AST → IR (three-address code) → LLVM IR → native binary
- gcc or clang (C11)
- LLVM development libraries (tested with LLVM 22)
- make
- Git
brew install llvmHomebrew installs LLVM as "keg-only". The Makefile auto-detects it at
/opt/homebrew/opt/llvm. Ifllvm-configis already in your PATH (e.g. on Linux), that works too.
sudo apt install llvm-devgit clone https://github.com/AmigosKazz/CypLang.git
cd CypLang
makeThe cyplang executable is created at build/bin/cyplang.
# 1. Compile CypLang source to LLVM IR
./build/bin/cyplang compile examples/hello.cyp -o hello.ll
# 2. Compile LLVM IR to a native binary
clang hello.ll -o hello # use system clang, or:
# /opt/homebrew/opt/llvm/bin/clang hello.ll -o hello # Homebrew clang on macOS
# 3. Run it
./hello
# Hello, World!./build/bin/cyplang examples/hello.cypThis prints the source, AST, three-address IR, and LLVM IR to stdout — useful for understanding the compilation pipeline.
make test6 integration tests covering arithmetic, unary expressions, variables, floats, functions, and Hello World.
CypLang uses French keywords. Here's a quick reference:
entier x <- 42 | Integer variable declaration + assignment
reel pi <- 3.14 | Float variable declaration
afficher("Hello, World!") | Print to stdout (maps to printf)
debfonc somme(d entier a, d entier b) | Function declaration
retourner a + b | Return statement
finfonc | End of function
si condition alors | If
...
sinon | Else
...
finsi | End if
tantque condition faire | While loop
...
finfaire | End while
Operators: +, -, *, /, div, mod, =, !=, <, >, <=, >=, et, ou, non
Types: entier (int), reel (float), chaine (string), booleen (bool)
Parameter modes: d (data/input), r (result/output), dr (data-result/inout)
cyplang/
├── examples/ # CypLang code examples
│ └── hello.cyp # Hello World
├── src/
│ ├── frontend/
│ │ ├── token/token.h # Token types and definitions
│ │ ├── lexer/lexer.{c,h} # Tokenizer (40+ token types)
│ │ ├── parser/parser.{c,h} # Recursive descent parser
│ │ └── ast/ast.{c,h} # AST node types and operations
│ ├── middle/
│ │ └── ir_generator.{c,h} # Three-address IR generation
│ ├── backend/
│ │ └── llvm_emitter.{c,h} # LLVM IR emission (C API)
│ └── main.c # CLI entry point
├── tests/
│ ├── run.sh # Bash test harness
│ └── cases/ # Test cases (.cyp + .expected)
├── Makefile # Primary build system
├── CMakeLists.txt # CMake (for IDE support)
└── LICENSE # MIT
- Full pipeline:
.cyp→ LLVM IR → native binary - Integer and float arithmetic with correct operator precedence
- Variable declarations (
entier,reel) - User-defined functions with parameters and return
- String literals and
afficher()(prints viaprintf) - CLI:
cyplang FILE.cyp(debug) andcyplang compile FILE.cyp -o OUT.ll(compile) - Integration test suite (
make test)
- Control flow (
si/tantque/pour) has a parser bug — not yet emitted to LLVM IR - All function parameters and return values are typed as
i32(proper type threading planned) - Mixed-type arithmetic (int + float in the same expression) is not yet supported
- No runtime library beyond
afficher→printf - No interpreter mode — compilation only
This project is licensed under the MIT License — see the LICENSE file for details.