Mini Python Compiler
A custom compiler for a subset of Python, from lexical analysis to abstract syntax trees

The Mini Python Compiler is an academic project developed during the 2nd year at Télécom Nancy (Module PCL1).
Its goal was to design and implement the front-end of a compiler for a simplified version of Python, called Mini Python.
We built the compiler from scratch (no parser generators), focusing on lexical and syntactic analysis as well as abstract syntax tree (AST) construction.
Key Features
- Lexical analysis: token recognition (identifiers, keywords, integers, indentation, etc.) via a custom-built automaton.
- Syntax analysis: recursive-descent parser based on a formally defined grammar of Mini Python.
- Abstract Syntax Tree (AST): structured representation of parsed programs and visualization tools.
- Error handling: explicit error messages (lexical and syntax errors) with line numbers; continuation of analysis after errors.
- Testing: validation on both correct Mini Python programs and programs with errors to ensure robustness.
Teamwork & Contributions
This 3-month project (October 2024 – January 2025) was carried out in a team of 4 students.
I contributed to :
- Factoring the grammar
- Implementation of lexical & syntax analyzers
- AST design and visualization
- Error management and testing strategy
This project strengthened my skills in language theory, compiler design, and collaborative software development.
Screenshots / Examples
The following code snippets illustrate some of the Mini Python features supported by our compiler:
def increment_if_positive(x) :
if x > 0 :
x = x + 1
return x
if __name__ == "__main__" :
increment_if_positive(3)And then, here is an example of the AST generated for the whole program above:
