Clover is a C-like language, performs semantic analysis, and emits LLVM IR. (I am trying to keep it low level and thinking of making it performance oriented)
- Lexer, parser, and AST construction
- Semantic analysis (type checking, basic symbol resolution)
- LLVM IR code generation (prints module IR to stdout)
- Supported features:
- Built-in integer and floating types, casts
constbindings (immutability enforced by semantic pass)structdeclarations and field accessexterndeclarations to call C functions- Control flow:
if/elif/else,do(do-while),loop,break,continue - Pointers, address-of (
&) and deref (*) insideunsafecontexts - Arithmetic and bitwise operators
- Basic testing via
llior by producing object files and linking withclang
CMakeLists.txt— build configuration (uses CMake + LLVM)include/— public headers (AST, lexer, parser, sem, codegen)src/— implementation (frontend + codegen)test/— example programs (e.g.,test/test.clv)
Configure and build with CMake. Example:
# If `llvm-config --cmakedir` is non-empty, pass it as `LLVM_DIR`.
cmake -S . -B build -DLLVM_DIR=$(llvm-config --cmakedir) -DLLVM_LINK_LLVM_DYLIB=ON
cmake --build build -jextern i32 puts(s : *char);
i32 main() {
puts("Hello, Clover!");
ret 0;
}
Example:
const PI : f64 = 3.14159;
i32 main() {
x : f32 = PI as f32;
ret 0;
}
struct vec {
a : f32,
b : f32
}