Skip to content

Latest commit

 

History

History
73 lines (57 loc) · 1.22 KB

File metadata and controls

73 lines (57 loc) · 1.22 KB

Compiler

Work in Progress — not ready for production use.

An educational compiler for a simple C-like custom language, targeting x86-64 assembly (NASM syntax) on Linux. This project is intended for learning purposes and aims to understand the core concepts of compiler design, including lexing, parsing, code generation.


Language Syntax

This compiler supports a minimal subset of C-like syntax:

  • Integer variables
  • Scopes (blocks)
  • Integer arithmetic (+, -, *, /)
  • Equality (==, !=)
  • Comparison (>, >=, <, <=)
  • If/else
  • While loops
  • Comments

Example:

{
    int x;
    x = (1 + 2) * 3;
    
    // comments

    int a;
    int b;
    int counter;

    counter = 0;

    a = 50;
    while (a) {
        b = 5;
        while (b) {
            b = b - 1;
            counter = counter + 1;
        }
        a = a - 1;
    }
}

Build

  1. Clone the repository:
git clone https://github.com/paul-csc/Compiler.git Compiler
cd Compiler
  1. Configure CMake:
cmake -S . -B build 
  1. Compile the project:
cmake --build build
  1. Run the compiler:
./build/Compiler
  1. Assemble and run the generated assembly (example for main program):
./test/assemble.sh main