Rey is a statically-typed, compiled programming language with clean syntax, built for clarity and hackability. The compiler is written in Rey itself β it bootstraps from a Rust reference interpreter and emits LLVM IR compiled to native binaries via clang.
func greet(name: String): String {
return "Hello, " + name + "!";
}
func main(): Void {
println(greet("Rey"));
}
| Component | State |
|---|---|
| Lexer | β Complete |
| Parser | β Complete |
| Type checker | π§ Stub (inference only) |
| LLVM backend | β Complete |
| C runtime library | β Complete |
| Self-hosting | β Phase H β native compiler passes all e2e tests |
The native compiler (rey-compiler/main.rey) compiles to a standalone binary using clang. No Rust is required at runtime.
- macOS arm64 (other platforms: build from source)
clangonPATH
# Use the pre-built binary from releases/
chmod +x releases/0.2.0/rey-macos-arm64
# Compile a program
./releases/0.2.0/rey-macos-arm64 rey-compiler/main.rey build examples/basic/hello.rey
# Run a program
./releases/0.2.0/rey-macos-arm64 rey-compiler/main.rey run examples/basic/hello.rey# 1. Build the Rust bootstrap interpreter
cd compiler/v1 && cargo build --release && cd ../..
# 2. Compile the Rey compiler using the bootstrap
./compiler/v1/target/release/rey-v0 rey-compiler/main.rey build rey-compiler/main.rey
# 3. Sign the output (macOS)
codesign -s - rey-compiler/main.bin
# 4. Run a Rey program with the native compiler
./rey-compiler/main.bin rey-compiler/main.rey run examples/basic/hello.reyvar x = 42;
var name: String = "Rey";
const PI: float = 3.14159;
func add(a: int, b: int): int {
return a + b;
}
var double = (x: int) => x * 2;
if x > 0 { println("positive"); } else { println("non-positive"); }
while i < 10 { i = i + 1; }
loop { if done { break; } }
for item in [1, 2, 3] { println(item.toString()); }
struct Point {
pub x: int,
pub y: int,
}
var p = Point { x: 3, y: 4 };
enum Color { Red, Green, Blue }
match color {
Color.Red => println("red"),
Color.Green => println("green"),
_ => println("other"),
}
var v = Vec.new();
v.push("a");
v.push("b");
println(v.join(", ")); // a, b
var m = HashMap.new();
m.set("count", 42);
println(m.get("count").toString());
var r = readFile("data.txt");
if r.isOk() {
println(r.unwrap());
} else {
println("error: " + r.unwrapOr("unknown"));
}
import lexer;
import parser;
var tokens = lexer.tokenize(source, "file.rey");
var ast = parser.parse(tokens, "file.rey");
rey-lang/
βββ compiler/v1/ # Rust bootstrap interpreter (not needed at runtime)
β βββ src/ # Lexer, parser, tree-walk interpreter
βββ rey-compiler/ # Self-hosted LLVM compiler (written in Rey)
β βββ main.rey # Compiler entry point and pipeline
β βββ src/
β β βββ lexer/ # Tokenizer
β β βββ parser/ # Recursive-descent parser + AST definitions
β β βββ typecheck/ # Type checker (stub)
β β βββ codegen/ # LLVM IR emitter
β βββ runtime/ # C runtime library (librey_rt)
β β βββ rey_rt.h # Public ABI header
β β βββ string.c # String operations
β β βββ vec.c # Dynamic arrays
β β βββ hashmap.c # Hash maps
β β βββ result.c # Result/Option/instanceof
β β βββ io.c # File I/O and process
β β βββ mem.c # Allocator
β βββ tests/e2e/ # End-to-end test suite
βββ releases/ # Pre-built binaries (by version)
βββ examples/ # Example Rey programs
βββ spec/ # Language specification
βββ tests/ # Interpreter-level test fixtures
# Build runtime first (only needed once)
make -C rey-compiler/runtime
# Run all e2e tests with the native compiler
bash rey-compiler/tests/e2e/run.shExpected output: OK
ARCHITECTURE.mdβ compiler pipeline and designCONTRIBUTING.mdβ style guide and how to extend the languageROADMAP.mdβ future directions and known limitationsreleases/0.2.0/RELEASE.mdβ v0.2.0 release notes
MIT β see LICENSE.