A statically-typed programming language built from scratch in C using a 4-pass compiler architecture. I enjoy writing compilers, and I am trying to use C more, so pebble will let me do that.
Functions:
// Regular function
fn add(a int, b int) int {
return a + b;
}
// Expression function (auto-returns)
fn square(x int) int => x * xVariables:
let name = "hello"; // Immutable
var count = 42; // Mutable
let pi = 3.14; // Type inferenceControl Flow:
fn max(a int, b int) int {
if a > b {
return a;
} else {
return b;
}
}
fn factorial(n int) int {
var result = 1;
while n > 1 {
result = result * n;
n = n - 1;
}
return result;
}int- 64-bit integersfloat- 64-bit floating pointbool- Boolean values (true/false)str- String literalsvoid- No return value
make # Build the peb compiler
make clean # Clean build artifacts# Test the foundation systems
./peb --test
# Test the lexer
./peb --test-lexer
# Compile a Pebble source file (when parser is ready)
./peb program.pebPebble uses a 4-pass compilation strategy:
- Pass 1: Lexical analysis + Syntax analysis → AST
- Pass 2: Collect global declarations → Symbol table
- Pass 3: Type resolution and checking → Typed AST
- Pass 4: Function body validation → Verified program
This approach enables:
- Clear separation of concerns
- Excellent error messages with location info
- Forward reference support
- Incremental testing and debugging
- Simplicity: Clean, readable syntax inspired by modern languages
- Safety: Static typing with comprehensive error checking
- Performance: Zero-cost abstractions and efficient compilation
- Clarity: Explicit over implicit, minimal syntax ambiguity