Calibre is a statically typed language implemented in Rust with a working stackless bytecode VM, formatter, and LSP. The project is actively evolving, but it already supports a broad set of language features and a usable workflow.
- Parser and AST pipeline are implemented (
crates/parser) - MIR lowering and type inference are implemented (
crates/mir) - LIR/bytecode lowering is implemented (
crates/lir) - VM runtime/interpreter is implemented (
crates/vm) - Formatter is implemented (
fmt) - LSP server is implemented and actively improving (
lsp) - Cranelift backend exists but is still in-progress (
crates/cranelift)
letcreates immutable bindingslet mutcreates mutable bindings- tuple and struct destructuring declarations are supported
let x = 10;
let mut y = 20;
let mut a, mut b = 1, 2;
- Functions in calibre are first-class values and can even have param types and return types inferred if enough information is provided
const add = fn (a, b) => a + b;
const main = fn => {
let result = add(2, 3);
print(result);
};
Calibre currently supports primitives and structured types including:
int,uint,float,bool,char,str,nulllist:<T>T?/Err!Ok- generators (
gen:<T>) - references/pointers in relevant contexts (
&T,&mut T,ptr:<T>)
type Point = struct { x : int, y : int };
type MaybeInt = enum {
Some : int,
None,
};
const inspect = fn (v : MaybeInt) => {
match v {
.Some : x => print("value=" & x),
.None => print("none")
};
};
trait Person {
const name : fn (&Self) -> str;
const greeting = fn (self : &Self) -> str => "Hello " & self.name();
};
type User = struct { name : str };
impl Person for User {
const name = fn (self : &User) -> str => self.name;
};
Calibre currently supports:
if/elsematchwith value and condition styles- loops and list comprehensions
for break,continue,return,defer
for i in 0..10 => {
if i % 2 == 0 => continue;
print(i);
};
const evens = fn(x for x in 0..20 if x % 2 == 0);
print(evens.collect());
The standard library includes runtime-backed primitives such as:
ChannelWaitGroupMutexspawnselect
Examples are available in examples/async.cal.
Calibre supports C/Zig-style extern declarations with explicit signatures.
extern "c" const c_strlen = fn(str) -> @usize from "libc" as "strlen";
cargo build -p calcargo run -p calcargo run -p cal -- run examples/examples.calcargo run -p cal -- run --example my_examplecargo run -p cal -- test
cargo run -p cal -- benchcargo run -p cal-fmt -- --max-width 100 --path examples/examples.calcargo run -p cal-lspThe examples/ directory contains practical programs for current language/runtime features, including:
examples/showcase/main.cal(general language surface)examples/traits.cal(traits/impl)examples/generators.cal(generators/pipelines)examples/async.cal(channels, mutexes, spawn/select)examples/hashmap.cal(collections)examples/stdlib_showcase.cal(stdlib breadth)
cal/: CLI frontend and REPLlsp/: language serverfmt/: source formattercrates/parser/: parser + AST + parser diagnosticscrates/mir/: semantic analysis, type resolution, MIRcrates/lir/: lower-level IR / bytecode prepcrates/vm/: runtime VM + native stdlib bindingscrates/std/: the standard library written in calibrecrates/diagnostics/: diagnostics emission helperscrates/cranelift/: JIT/AOT compilation backend work-in-progress
- Interpreter backend
- Cranelift backend
- Formatter
- LSP support
- Package manager
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.