Skip to content

KaramNS/MVaP-Basic-Programming-Language-Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compiler Construction

Project Overview

This repository contains a complete compiler construction project developed in the Compilation course (Licence Informatique, S5).

The objective is to design and implement a structured compiler using ANTLR4, progressively extending a language from simple expressions to a fully functional language supporting:

  • Arithmetic, boolean, and rational expressions
  • Semantic analysis and type checking
  • Variables and scoped blocks
  • Control flow (conditionals and loops)
  • User-defined functions
  • Stack-based code generation targeting the MVaP virtual machine

The project follows a classical compiler pipeline:

Grammar → Parser → Semantic Analysis → Code Generation → Virtual Machine Execution

Compiler Architecture

The project evolves through the following stages:

  1. Lexical and syntactic analysis (ANTLR grammars)
  2. Attributed grammars and interpretation
  3. Semantic validation (type checking, scope management)
  4. Stack-based code generation (MVaP)
  5. Control flow compilation
  6. Function calls and activation records

Target machine: MVaP (version 3.2)


TP Modules

Each TP folder contains:

  • .g4 grammar files
  • .rat test programs
  • Optional scripts
  • A dedicated README

Learning Outcomes

This project demonstrates:

  • Formal language theory applied in practice
  • Grammar ambiguity control
  • Semantic analysis and type systems
  • Stack machine architecture
  • Activation record design
  • Recursive function execution
  • End-to-end compiler pipeline implementation

Setup & Execution

Environment Requirements

  • Java (JDK 8+)
  • ANTLR4
  • MVaP Assembler and Simulator
  • Bash (recommended)

Installation Guides

Running the Compiler


Documentation

Additional documentation and reference materials are available in the docs/ directory:

  • Setup instructions (ANTLR & MVaP installation guides)
  • Bash command memo
  • MVaP instruction cheat sheet
  • Official TP subject PDFs

These documents provide the theoretical background, machine instruction reference, and environment setup required to run and understand the compiler.


Contributors

This project was developed as part of the Compilation course.

Contributors:


Project Status

  • TP1--TP6: Fully implemented
  • TP7--TP8: Advanced control flow and function mechanism implemented
  • Further optimizations possible (symbol table improvements, memory model refinement)

About

End-to-end compiler implementation (ANTLR -> semantic analysis -> MVaP code generation)

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors