Logo
Fab.Magalhães

Software Engineer

Pascal Standard Compilator: Building a Pascal to Pseudo-Assembly-Code Compilator in Python

March 20, 2025Software Development, Course, Project, Learning, Compiler
MacBook Mockup Background
https://mackgame4-portfolio.vercel.app
Technologies

Python, Ply.Lex/Yacc - Lexical Analysis and Parsing, Assembly Language, x86 Architecture

Team

Afonso Pedreira, Fábio Magalhães, André Pinto

Timeline & Status

Delivered May 5, 2025

Source

https://github.com/Mackgame4/UM-PL2025-A104365

Overview

This project was developed for the "Programação de Linguagens" course at the "Universidade do Minho" as part of a Software Engineering degree. The main objective was to create a compiler that translates a subset of the Pascal programming language into pseudo-assembly code for the x86 architecture of a virtual machine given by the university, using Python and the Ply.Lex/Yacc libraries for lexical analysis and parsing.

General AST Diagram
General AST DiagramPNG
Math Operations & Variable Atributions Diagram
Math Operations & Variable Atributions DiagramPNG
Array Diagram
Array DiagramPNG
If Statement Diagram
If Statement DiagramPNG
For Loop Diagram
For Loop DiagramPNG
While Loop Diagram
While Loop DiagramPNG
Simple Pascal Example Input
Simple Pascal Example InputPNG
Simple pseudo-assembly Code Output
Simple pseudo-assembly Code OutputPNG
Advanced Pascal Example Input
Advanced Pascal Example InputPNG
Advanced pseudo-assembly Code Output
Advanced pseudo-assembly Code OutputPNG