Welcome to the Bling Compiler — a powerful toolchain designed to translate Bling source code into optimized Apple Silicon (ARM64) assembly. This compiler is thoughtfully architected and built from the ground up, encompassing three key phases: lexical analysis, parsing, and code generation.
The Bling language is minimalist yet expressive, supporting core constructs for computation. Here's a snippet that generates a Fibonacci-like sequence:
int x = 0;
int y = 1;
int z = 0;
int i = 1;
while(i neq 100){
x = y;
y = z;
z = y + x;
i = i + 1;
}
exit(x);
-
🔍 Lexical Analyzer (Lexer):
Converts.blingsource files into a stream of tokens — recognizing keywords, identifiers, operators, separators, and literals. -
🌲 Parser:
Builds an Abstract Syntax Tree (AST) from the token stream, capturing the structural and syntactic essence of the code. -
⚙️ Code Generator (in progress):
Traverses the AST to produce ARM64 assembly instructions, specifically optimized for Apple Silicon.
A Makefile is included to simplify building and running the compiler.
Ensure you have the following installed:
- 🧰 A C compiler (
gccorclang) - 📦
makeutility
make compTo compile a Bling source file:
make run FILE=<your_file.bling>If no
FILEis specified, it defaults totest.bling.
make cleanRemoves all build artifacts and binaries.
.
├── main.c # Entry point
├── lexer.{h,c} # Lexical analyzer
├── parser.{h,c} # AST builder
├── codegenerator.{h,c} # ARM64 code generator (in progress)
├── utils/ # Hashmaps and reusable components
├── assembly/ # Apple Silicon assembly tests/resources
├── test.bling # Sample Bling code
└── Makefile # Build automation-
🧬 Full ARM64 Code Generation:
Finalize and polish the code generator for complete ARM64 coverage. -
🧵 Richer Language Support:
Add strings, floats, and other primitive types. -
🧠 Advanced Control Flow:
Support forif,else, nested loops, and user-defined functions. -
🛡 Robust Error Handling:
Improve diagnostic messages and recovery mechanisms. -
🧪 Automated Testing Suite:
Ensure correctness and performance of all components — especially ARM64 output.
This project is open-source and available under the terms of the LICENSE.md file.