https://github.com/giovananog/simples-compiler
Compiler developed during the Language Theory and Compilers course
https://github.com/giovananog/simples-compiler
compiler computer-science-degree cpp
Last synced: about 1 month ago
JSON representation
Compiler developed during the Language Theory and Compilers course
- Host: GitHub
- URL: https://github.com/giovananog/simples-compiler
- Owner: giovananog
- Created: 2024-01-08T13:00:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-29T16:43:02.000Z (11 months ago)
- Last Synced: 2025-02-01T19:13:08.275Z (3 months ago)
- Topics: compiler, computer-science-degree, cpp
- Language: C
- Homepage:
- Size: 182 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SIMPLES Compiler



> This repository contains the implementation of a compiler for the SIMPLES language as part of the Compiler Theory and Language course, taught by Professor Luiz Eduardo da Silva at the Federal University of Alfenas (UNIFAL-MG).
## 💻 ObjectiveThe objective of this project is to enhance the SIMPLES compiler to allow compilation of record types. Additionally, the compiler should include semantic actions for type checking in expressions containing records.
## 📋 Problem
Records are heterogeneous data structures that compose a set of variables that can have different types. Each element of the record set is individually accessed through the access expression: `.`. Fields can only be accessed in this way. Record fields can also be records themselves. When declaring a record, space must be reserved for each field, starting from a base address. The name of the record refers to this initial memory address. Therefore, each field corresponds to an offset from this initial address.
## 🛠️ Instructions
1. Modify the rules for variable declaration, reading variables, assignment command, and expressions to allow the use of records in the SIMPLES language.
- Modify the variable declaration rules to allow declarations in this form:
```
registro reg1
def
inteiro a
logico b
fim def c
```
- This declaration should be stored in the symbol table for later translation of operations with variables of the record type. A suggested structure is the linked list of fields.2. Modify the rules where access expressions with records and record fields can be used (reading, writing, assignment, and expressions in general) to translate the access expression to memory locations.
## 📁 Project Structure
The project directory should include the following files:
- `lexico.l`: Lexer file for lexical analysis.
- `sintatico.y`: Parser file for syntactic analysis.
- `utils.c`: Utility functions used in the compiler.
- `makefile`: Makefile for compiling the SIMPLES compiler.## ⚙️ Compilation and Execution
To compile the SIMPLES compiler, use the following commands:
```bash
make simples
```
To clean the project directory, use:
```bash
make clean
```
To run the compiler, use the following command:
```bash
./simples .simples
```