Pine is a statically typed, compiled programming language focused on high performance, minimal design, and a modern developer experience.
It features a clean syntax, explicit typing, LLVM-based code generation, and a transparent compilation pipeline that exposes every stage - from tokenization to native executable output.
This project includes a CLI compiler called pinec, which can build, analyze, and run Pine programs.
Pine has evolved beyond arithmetic and functions into a small but expressive systems-style language core.
- Statically typed
- Compiled to native executables (via LLVM)
- First-class functions
- Explicit function signatures
- Local variables & reassignment
- Arithmetic & comparison expressions
- Conditional branching (
if / else if / else) whileloops- Expression-based returns
i32i62f32f64boolstr
- Constant string literals
- String comparison (
==,!=) - Runtime-backed operations
- Designed for future evolution into heap strings
Pine supports calling native functions using the alien keyword:
alien "c" fn pine_print(s: str) -> i32
This enables direct interoperability with C (and other C-ABI languages).
Example wrappers:
fn print(s: str) {
pine_print(s)
}
fn println(s: str) {
pine_println(s)
}
You can also read input:
let name = read("Enter your name:")
println(name)
Pine exposes its compilation stages for learning and debugging:
- Lexing β Token stream
- Parsing β AST
- Semantic Analysis β Type checking
- Codegen β LLVM IR
- Object emission
- Linking β Native executable (with runtime)
pine/
βββ examples/
β βββ main.alp
βββ runtime/
β βββ c/
βββ crates/
β βββ lexer/
β βββ parser/
β βββ analyzer/
β βββ codegen/
β βββ linker/
β βββ utils/
βββ tools/
β βββ pinec/
Create a file with the .alp extension:
fn add(n1: i32, n2: i32) -> i32 {
return n1 + n2
}
fn main() {
let result = add(10, 20)
return result
}
pinec build -s examples/main.alpThis will:
- Lex the source
- Parse it into an AST
- Type-check the program
- Generate LLVM IR
- Emit object code
- Link runtime & produce a native executable
Output binary:
./examples/main./examples/mainTransparency is a core Pine goal - you can inspect every stage.
pinec build -s examples/main.alp tokensUse cases:
- Debug lexer issues
- Study token output
pinec build -s examples/main.alp astVisualize:
dot -Tpng ast.dot -o ast.pngpinec build -s examples/main.alp analyzeUseful for:
- Populating infered types
- Debugging AST
pinec build -s examples/main.alp objectUseful for:
- Creating object file
- Custom linking with other FFI languages
pinec build -s examples/main.alp llvm-irUseful for:
- Learning LLVM
- Debugging codegen
- Optimization research
fn main() {
let a = "hello"
let b = "world"
return if a != b { 1 } else { 0 }
}
fn is_even(n: i32) -> bool {
return n % 2 == 0
}
fn main() {
let x = 10
if is_even(x) {
return 1
}
return 0
}
fn main() {
let res = read("Are you a one or a zero?")
println(res)
return 0
}
Declare foreign functions using alien:
alien "c" fn pine_print(s: str) -> i32
alien "c" fn pine_read_line_stdin(prompt: str) -> str
Then wrap them in Pine:
fn read(prompt: str) -> str {
pine_read_line_stdin(prompt)
}
This enables:
- Native runtime libraries
- libc integration
- Custom system bindings
Runtime functions are implemented in C and linked during compilation.
Examples:
pine_printpine_printlnpine_strcmppine_read_line_stdin
This modular design allows selective linking and smaller binaries.
- Learn compiler internals
- Explore LLVM IR generation
- Experiment with language features
- Maintain transparent compilation stages
- Enable gradual evolution toward a self-hosting language
Planned / future features:
- Heap strings (
struct { ptr, len }) - String methods (concat, slice, length)
- Structs & custom types
- Arrays / slices
- File I/O
- Modules & stdlib packaging
- Self-hosting compiler (long-term)
Contributions are welcome!
- Open issues for bugs or feature ideas
- Submit PRs with focused changes
- Discuss language design improvements
Apache License Version 2.0
Pine is a learning-focused language built with real compiler principles:
- LLVM backend
- Native codegen
- Runtime linking
- FFI support
- Transparent compilation stages
If youβre exploring compilers, language design, or systems programming - Pine is meant to grow with you.
Happy hacking π²