The goal of this project is to implement a compiler for the AME language, a high-level programming language. The development consists of building:
- Lexical Analyzer (LA);
- Syntax Analyzer (SA);
- Semantic Analyzer (SAn);
- Intermediate Code Generator (ICG).
This work is part of the syllabus for the Compiler Construction course (INE5426), taught by Prof. Alvaro Junio Pereira Franco.
The code organization is very simple:
- The execution of the analyzers is centralized in
main.py; src/lexercontains the code related to the LA;src/syntaxcontains the code related to the SA;src/semanticcontains the code related to the SAn;src/testcontains the.amefiles to be tested;src/resourcescontains text files that describe the SDDs and SDTs of the project, and the language grammar.
- make;
- Python >= 3.10;
- pip;
- venv;
- ply.
- The version of the mentioned library is listed in the
requirements.txtfile.
To install the project dependencies, run the command below:
make installIf you encounter issues with venv, it is recommended to delete the
venvfolder in the root of the project and run the command again.
To run the project after installation, execute the command below:
make run FILE=path/to/file.ameWhere path/to/file.ame is the path to the .ame file to be analyzed.
The project includes ready-to-use tests. To execute them, run the command below:
make desired_testWhere desired_test is the desired test. The available tests are:
test1: tests themerge.amefile;test2: tests theprimo.amefile;test3: tests theadivinha.amefile;
Alternatively, you can run the following command to execute all of them sequentially:
make tests