Back to projects

Project

In Progress

Faz Compiler

A compiler for my own programming language, written in pure C, targeting x86-64 assembly.

Tech Stack

Cx86-64 AssemblyMake

Overview

Faz is a custom programming language and compiler built entirely from scratch in C. The compiler takes Faz source code through a complete compilation pipeline—lexical analysis, parsing, semantic analysis, and code generation—ultimately producing x86-64 assembly that can be assembled and linked into native executables. The project started as a deep dive into how programming languages actually work under the hood. Rather than relying on parser generators or compiler frameworks, every component is hand-written, giving complete control over the compilation process and a thorough understanding of each stage. Currently, the compiler successfully handles basic programs with variable declarations, arithmetic expressions, and control flow. The tokenizer correctly identifies all language constructs, and the recursive descent parser builds a proper AST that feeds into the code generator.

Features

  • Hand-written lexer with full tokenization
  • Recursive descent parser producing AST
  • x86-64 assembly code generation
  • Basic type system
  • Variable declarations and arithmetic expressions
  • No external dependencies - pure C implementation

Challenges

Implementing the code generator was particularly challenging. Mapping high-level constructs to assembly requires careful register allocation and understanding of calling conventions. Debugging assembly output meant stepping through machine code to trace issues back to the generation logic.

What I Learned

Building a compiler from scratch demystified so much about how languages work. Understanding the full pipeline from source text to machine code changed how I think about the languages I use daily. The constraint of pure C forced disciplined memory management and data structure design.

Future Plans

Implement functions and a proper call stack. Add control flow (if/else, loops). Build a simple standard library. Eventually explore optimisation passes.