PROJECT 001

Pinky Language Compiler

A complete compiler implementation for the Pinky programming language. Built from first principles with full lexical analysis, recursive descent parsing, AST optimization, and LLVM code generation.

001

Architecture

Source Code
Lexer
Tokenization
Parser
AST Generation
Optimizer
Constant Folding
Interpreter
VM
LLVM
002

Features

Lexical Analysis

Tokenizes source code into a stream of tokens with line tracking.

Recursive Descent Parser

Builds Abstract Syntax Tree using top-down parsing.

AST Optimization

Constant folding and expression simplification.

Tree-Walk Interpreter

Direct AST execution for quick testing.

Stack-Based VM

Custom bytecode compiler and virtual machine.

LLVM Backend

Generates native executables via LLVM IR.

003

Language Syntax

Variables & Expressions
x := 10 + 5 * 2
name := "Hello"
flag := true
Control Flow
if x > 10 then
    println("Big")
else
    println("Small")
end
Loops
for i := 1, 10 do
    println(i)
end

while x > 0 do
    x := x - 1
end
Functions
func add(a, b)
    ret a + b
end

result := add(3, 4)