kolga is a compiler (indefinitely WIP) with the following goals:
- Use the LLVM API to generate IR and machine code.
- Build a type checker, implement type inference, and provide more complex ADT's.
- Support object/struct composability.
- Build some light concurrency primitives like coroutines.
Right now, kolga features basic language syntax:
- Functions (with recursion)
- Classes
- Basic control flow
- A few different types: 64-bit numbers, ASCII strings, bool, and void
Some compiler features so far:
- Lexing and parsing into an AST
- Type checking, including for ADT's
- Basic type inference for variable assignments. Functions still require type annotations.
- LLVM IR codegen directly from AST (no additional IR) and optimization manager
cargo run [filename]
cargo test -- --nocapture
# some basic type inference
fn basicFunc(x~num)~num {
let inferMe ~= x + 10;
let dontInferMe~num = x - 1;
return inferMe;
}
let plsInferMe ~= basicFunc(1);
fn basicFunc(x~num, y~num)~num {
let z~num = 10;
return x + y + z;
}
fn double(x~num)~num {
return x * 2;
}
fn negate(y~bool)~bool {
return !y;
}
# simple class declaration and use
class mClass {
let z~num;
let y~num;
fn nop()~void {
return;
}
fn triple()~num {
return self.y * 3;
}
}
let instance~mClass {
z = 1,
y = 10,
};
instance.nop();
let tripled ~= instance.triple(); // 30
kolgac
contains code for lexing and parsing, as well as appropriate token and AST data structures. This is the core compiler.
kolgac_types
contains type checking/inference
kolgac_codegen
handles generating the llvm ir from the ast
kolgac_errors
contains error handling/emitting functions, are well as error types for each stage in the compiler
The src
directory contains the file kolga.rs
, which is the main entry point into the compiler.