Radiant is an experimental programming language and compiler frontend written in Go.
It currently scans and parses .kel source files, then lowers the AST to LLVM IR (.ll).
- Lexing and parsing for core language constructs:
- variable declarations (
let) - functions (
fn), parameters, and returns - conditionals (
if / elif / else) - expressions, unary/binary operators, and function calls
- variable declarations (
- Basic type tokens (
number,string,bool,char) with simple pointer syntax (*/&) - LLVM IR generation (written to
build/example.ll) - External
printfdeclaration for output from generated code
This project is still in active development and many language features are not implemented yet.
src/main.go– entrypoint (REPL/file execution flow)src/scanner– tokenizersrc/parser– Pratt parser + statement parsingsrc/ast– AST node definitionssrc/llvm– LLVM IR generatorresources/*.kel– sample source filesinternal/generator.go– codegen utility for AST boilerplate
- Go 1.22+
- LLVM 17 available on your system (
go-llvmbindings are used)
On Apple Silicon with Homebrew, these environment variables are commonly needed:
export LLVM_CONFIG="/opt/homebrew/opt/llvm@17/bin/llvm-config"
export PATH="/opt/homebrew/opt/llvm@17/bin:$PATH"go run -tags=llvm17 ./src- With no args: starts the REPL.
- With a file arg: compiles that file.
Example:
go run -tags=llvm17 ./src ./resources/scratch1.kelGenerated IR is written to:
build/example.ll
./run.sh– run compiler withllvm17build tag./build.sh– build binary intobuild/./generate.sh– regenerate AST boilerplate frominternal/generator.go
fn main() {
let num = 10;
let numAddr = #
printf("number %f has address %p", num, numAddr);
return;
}
See resources/ for more examples.