OVERVIEW
Monorepo/Core Toolchain/Kale Compiler
v0.2.0 • ActiveSource Code
src/kale/

Kale Compiler

Reference PythonKale & LLVM Native Compiler

The official Kale compiler transforms high-level syntax into pristine, highly-optimized LLVM IR. Features stack array literals, struct-by-value passing, IEEE 754 float arithmetic (f32/f64), dynamic library linking (-l/-L), and direct AOT binary emission via Clang/LLD.

Target Architecturex86_64 / Native
BackendLLVM 18 / Clang LLD
Compile Latency< 24ms (AOT)
MilestoneM1 Stabilized
Kale Compiler
Compiler Internal Stages
AOT Emission Latency < 24ms
STAGE 1
Lexer & Token Stream
Single-pass UTF-8 scanner with zero allocations
STAGE 2
Parser & AST Tree
Recursive descent parser emitting strict typed AST nodes
STAGE 3
Type Binder & Inference
Symbol resolution, struct layout, and type deduction
STAGE 4
LLVM IR Emitter
LLVM 18 IR generation linked directly via Clang/LLD
Native C ABI Linker

Zero-Overhead Foreign Function Interface

Kale links directly against native C dynamic libraries with no runtime marshaling wrapper. Functions declared with extern symbols resolve directly through the platform loader (kernel32, user32, opengl32, glfw3, sqlite3).

// Linker Flags
python -m kale.cli build main.kl -o bin/app.exe -lglfw3 -lopengl32 -lsqlite3
Compiler Hardware Architecture
compiler_demo.kl
kale
// Stack array literals, float math, and external linking
import "packages/std/io/file.kl" as file;

struct Vector3 {
    x: f32,
    y: f32,
    z: f32,
}

fn length(v: Vector3) -> f32 {
    let sum: f32 = (v.x * v.x) + (v.y * v.y) + (v.z * v.z);
    return sqrtf(sum);
}

fn main() -> int32 {
    let vertices: [f32; 4] = [0.0, 1.0, 0.5, -0.5];
    let pos: Vector3 = Vector3 { x: 1.5, y: 2.5, z: 3.0 };
    return 0;
}
Compilation & Linker Directives

Deterministic command-line invocations to build, link native dynamic dependencies, and run automated regression tests:

$python -m kale.cli build main.kl -o bin/app.exe
$python -m kale.cli emit-ir main.kl -o bin/app.ll
$python -m pytest tests/test_compiler.py
Monorepo Governance

GPG Key 1B917D4779A6102E • Continuous integration with automated symbol verification.

Architectural Capabilities
LLVM IR Generation

Zero-overhead type translation with direct mapping to LLVM primitive types, pointer types, and memory layout.

Flexible Linker Arguments

Supports seamless FFI binding with -l and -L flags linking against Windows Win32, GLFW3, OpenGL, and SQLite3.

Struct-by-Value & Stack Arrays

Enables zero-heap allocation patterns and ergonomic data transfer for graphics and systems programming.