The PyAsm Compiler is a compiler implemented in C++, designed to parse and analyze MiniPython (MPY) source code by generating an Abstract Syntax Tree (AST) and performing error validation at various compilation stages. PyAsm enables static analysis of MiniPython scripts and facilitates structured representation of the input source.
- Aymeric ROBERT
- Baptiste PACHOT
- Alexis CHAVY
- Johan Kasczyk
- Optimized Parsing and AST Generation – Efficient processing of MiniPython syntax.
- Error Detection – Provides structured error reporting for syntax and semantic issues.
- Designed for Educational and Research Purposes – A tool for understanding compiler design in an academic setting.
- Cross-Platform Compatibility – Can be compiled and executed on Linux and macOS.
- Lexical and Syntax Analysis – Tokenization and parsing of MiniPython scripts.
- AST Generation – Converts source code into a structured AST representation.
- Error Handling and Reporting – Detects and reports syntax errors with precision.
- Graphical AST Visualization – Generates DOT format output for AST representation.
- Modular Architecture – Easily extendable for additional features such as optimizations.
- Command-Line Interface – Configurable options for analysis and debugging.
Ensure that the following dependencies are installed:
- C++20 (GCC, Clang, or MSVC)
- CMake (>= 3.22)
- Graphviz (for AST visualization)
- Make (or an equivalent build system)
- Git
./scripts/install_deps.sh # Installs required dependenciesgit clone https://gibson.telecomnancy.univ-lorraine.fr/projets/2425/compil/pyasm.git
cd pyasm./scripts/build.sh # Builds the project./scripts/run.sh <source-file>| Option | Description |
|---|---|
-o <file> |
Specify the output file name |
--debug |
Enable debug mode |
--dot <file> |
Export AST to DOT format for visualization |
--help |
Display usage information |
./scripts/run.sh ./data/examples/ex1.mpy./scripts/run.sh --debug ./data/examples/ex1.mpyprint("Hello, world!")./scripts/run.sh ./data/examples/hello.mpydef fibonacci(n):
if n <= 1:
return n
else:
return fibonacci(n-1) + fibonacci(n-2)
print(fibonacci(10))./scripts/run.sh ./data/examples/fibonacci.mpyTo validate the functionality of PyAsm, run the test suite:
./scripts/full_setup.sh # Installs dependencies, builds, and runs the projector execute individual test scripts:
./scripts/run_tests.sh./scripts/run.sh --dot ast.dot ./data/examples/ex1.mpy
dot -Tpdf ast.dot -o ast.pdfThis generates an AST visualization in PDF format.
This project utilizes:
- CMake – Build system
- Graphviz – AST visualization
- GCC / Clang – Compilation
- GitLab – Version control
Special thanks to Telecom Nancy for hosting the project infrastructure.