█████╗ ███╗ ██╗███████╗██╗ ██╗
██╔══██╗████╗ ██║██╔════╝╚██╗██╔╝
███████║██╔██╗ ██║█████╗ ╚███╔╝
██╔══██║██║╚██╗██║██╔══╝ ██╔██╗
██║ ██║██║ ╚████║███████╗██╔╝ ██╗
╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝
A custom programming language and full visual compiler debugger — built from scratch in Python.
ANEX is a fully custom programming language designed and implemented from scratch in Python — complete with a visual compiler debugger that lets you watch every stage of the compiler pipeline happen live, in real time, as your program runs.
Most people learn to write code. ANEX lets you see how code is actually read, parsed, executed, and compiled — from raw text all the way down to pseudo-assembly output.
Built as a Compiler Construction course project.
Every stage in your textbook — implemented, visualized, and interactive.
Source Code --> Lexer --> Parser --> Interpreter --> Symbol Table
|
Semantic Analysis
|
Optimizer
|
Code Generation
|
Output
| # | Stage | What It Does |
|---|---|---|
| 1 | Source Code | Write ANEX programs in the built-in editor with syntax highlighting |
| 2 | Lexer | Breaks source into typed tokens — KEYWORD, NUMBER, STRING, OP, SYM, IDENT |
| 3 | Parser + AST | Builds an interactive Abstract Syntax Tree — click any node to collapse |
| 4 | Interpreter | Walks the AST and traces every step of execution, live |
| 5 | Symbol Table | Tracks every variable (name, type, scope, value, update count) and function (params, call count, return value) |
| 6 | Semantic Analysis | Catches type mismatches, undeclared variables, duplicate declarations, and argument count errors — with fix suggestions |
| 7 | Optimizer | Applies constant folding, dead code elimination, identity elimination, and strength reduction — shows before/after |
| 8 | Code Generation | Translates your program into Three-Address Code and Pseudo-Assembly — split-pane view |
| 9 | Output | Every emit() statement rendered cleanly |
ANEX is a statically-typed, interpreted language with clean, readable syntax.
int x = 10;
bool flag = true;
string name = "ANEX";
if result > 12 {
emit("Big result!");
} else {
emit("Small result.");
}
int i = 1;
while i <= 5 {
emit(i);
i = i + 1;
}
unit Main {
func factorial(n) {
if n <= 1 {
return 1;
}
return n * factorial(n - 1);
}
int result = factorial(7);
emit("7! =");
emit(result);
}
bool a = true;
bool b = false;
emit(a and b); // false
emit(a or b); // true
emit(not a); // false
emit(x > 10 and x < 20);
emit("Hello, ANEX!");
emit(result);
The debugger is built with Python + customtkinter and features:
- Two-panel layout — code editor on the left, analysis panels on the right
- Tab-based navigation — switch between all 9 pipeline stages instantly
- Live pipeline indicator — glowing dots show which stage just completed
- Real-time stats bar — token count, AST nodes, execution steps, variables, output lines, and runtime in ms
- VS Code-style editor — syntax highlighting, line numbers, collapsible editor panel (Ctrl+B)
- Keyboard shortcuts —
Ctrl+Enterto run,Ctrl+Bto toggle editor - Live clock — always visible in the top bar
- Status bar — shows exactly what the pipeline is doing at every moment
- Built-in examples — Hello World, Factorial, Fibonacci, While Loop, Functions, Logic
pip install customtkintergit clone https://github.com/Ali-Nawaz-devt/Anex-Programming-Language.git
cd Anex-Programming-Languagepython gui.pypython anex.py program.anxAnex-Programming-Language/
│
├── gui.py # Visual compiler debugger (main interface)
├── anex.py # CLI runner for .anx files
│
└── src/
├── lexer.py # Lexical analyser — source to tokens
├── parser.py # Parser — tokens to AST
├── interpreter.py # Interpreter — AST execution
├── anex_ast.py # AST node definitions
└── tokens.py # Token types and keywords
unit Main {
func fib(n) {
if n <= 1 {
return n;
}
return fib(n - 1) + fib(n - 2);
}
int i = 0;
while i <= 9 {
emit(fib(i));
i = i + 1;
}
}
unit Main {
bool a = true;
bool b = false;
int x = 15;
emit(a and b);
emit(a or b);
emit(not a);
emit(x > 10 and x < 20);
emit(x == 15);
}
| Optimization | Before | After |
|---|---|---|
| Constant Folding | int x = 2 + 3 |
int x = 5 |
| Dead Code Elimination | if false { ... } |
block removed |
| Identity Elimination | x = x + 0 |
x = x |
| Strength Reduction | y = n * 0 |
y = 0 |
Three-Address Code (TAC)
BEGIN Main
t1 = x
t2 = y
t3 = t1 + t2
result = t3
if t4 goto THEN1 else goto ELSE1
THEN1:
PRINT "Big result!"
goto ENDIF1
ELSE1:
PRINT "Small result."
ENDIF1:
END
Pseudo-Assembly
LOAD [x], R1
LOAD [y], R2
ADD R1, R2, R3
STORE R3, [result]
CMP R4, #true
JEQ THEN1
JMP ELSE1
| Technology | Purpose |
|---|---|
| Python 3.10+ | Core language |
| customtkinter | GUI framework |
| tkinter Canvas | AST tree renderer |
| Threading | Non-blocking pipeline execution |
| Regex | Syntax highlighting |
Most developers use languages every day without ever understanding how they actually work.
I wanted to change that — for myself first.
Building ANEX forced me to understand every layer of a programming language from the ground up: how raw text becomes tokens, how tokens become structure, how structure becomes execution, and how execution can be optimized and compiled down to machine-level instructions.
Every stage you see in the debugger is something I implemented myself — the lexer, the parser, the interpreter, the symbol table, the semantic analyser, the optimizer, and the code generator.
This is what compiler construction actually looks like in practice.
Ali Nawaz
BS Computer Science
The Shaikh Ayaz University
If you find this project interesting, give it a star — it helps more people discover it.
Built with curiosity. Powered by Python. Driven by the need to understand.