This project involves the implementation of a compiler for the miniPython language, which is a subset of Python. The project is developed in two phases using the SableCC tool.
The project consists of two main phases:
-
- Lexical Analysis
- Syntax Analysis
-
- Abstract Syntax Tree (AST) Construction
- Symbol Table & Semantic Analysis
The compiler is implemented in Java using the SableCC tool.
Download SableCC v3 and place it either in the project folder or in your system PATH.
- Java 8 or newer (e.g., OpenJDK)
javacandjavaavailable in your$PATH- SableCC (
sablecc.jar)Note: The
sablecc.jarfile should be placed inside alib/folder within your project directory.
From the folder where the grammar file is located (e.g., phaseA/):
- Copy
sablecc.batinto thephaseA/folder. - Run:
sablecc minipython.grammar- Copy the
sableccshell script into the directory. - Run:
chmod +x sablecc
./sablecc minipython.grammarAfter execution, a folder named minipython/ will be automatically generated, containing the subfolders: analysis/, lexer/, parser/, node/