Skip to content

Latest commit

ย 

History

History
114 lines (75 loc) ยท 2.86 KB

File metadata and controls

114 lines (75 loc) ยท 2.86 KB

๐Ÿ’Ž Bling Compiler Project (for ARM64 architecture) ๐Ÿ

๐Ÿš€ Overview

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);

โœจ Features

  • ๐Ÿ” Lexical Analyzer (Lexer):
    Converts .bling source 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.


๐Ÿ›  Getting Started

A Makefile is included to simplify building and running the compiler.

โœ… Prerequisites

Ensure you have the following installed:

  • ๐Ÿงฐ A C compiler (gcc or clang)
  • ๐Ÿ“ฆ make utility

๐Ÿงฑ Building the Compiler

make comp

๐Ÿƒโ€โ™‚๏ธ Running the Compiler

To compile a Bling source file:

make run FILE=<your_file.bling>

If no FILE is specified, it defaults to test.bling.

๐Ÿงน Cleaning Up

make clean

Removes all build artifacts and binaries.


๐Ÿ—‚ Project Structure

.
โ”œโ”€โ”€ 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

๐Ÿ”ฎ Future Enhancements

  • ๐Ÿงฌ 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 for if, 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.


๐Ÿ“„ License

This project is open-source and available under the terms of the LICENSE.md file.