Skip to content

Chouette Compiler est un compilateur pour le langage Mini Python, implémenté en Java. Il effectue l'analyse lexicale et syntaxique pour générer un arbre syntaxique abstrait (AST). L'interface utilise un serveur Java HttpServer pour visualiser le code source et l'AST, ce dernier étant généré graphiquement avec Graphviz.

Notifications You must be signed in to change notification settings

linalek/mini-python-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chouette Compiler

Below is a screenshot of our Mini Python Compiler interface. On the left side, you can see an example of Mini Python code, and on the right side, the corresponding Abstract Syntax Tree (AST) generated by our compiler:

Mini Python Compiler Interface


Table of Contents

  1. Introduction
  2. Features
  3. Installation
  4. Usage
  5. Examples
  6. Project Management
  7. Acknowledgements

Introduction

The Mini Python Compiler is a Java-based compiler project focusing on:

  • Lexical and Syntactic Analysis: We tokenize Mini Python code and build a parse tree.
  • Abstract Syntax Tree (AST) Construction: We transform the parse tree into an AST suitable for further processing.

This compiler demonstrates how Mini Python fragments can be parsed and analyzed. We do not rely on extra Java dependencies.
However, Graphviz must be installed on your system for generating the graphical representation of the AST.

Team

  • Lucine GIRAUD
  • Lina LEKBOURI
  • Julien MARLAND
  • Hugo WERCK

Why use our Mini Python Compiler?

  • Straightforward Setup: Managed via a Makefile, no special Java libraries needed.
  • Interactive UI: Utilizes Java's built-in HttpServer to serve an HTML interface for viewing the source and AST.
  • Graphical AST: Automatically generated using Graphviz.

Features

  • Cross-platform: Works on Linux, macOS, and Windows.
  • AST Generation: Displays a real-time visualization of the parsed AST via Graphviz.
  • Error Reporting: Helpful syntax error messages for debugging.
  • Extensible: Easily add new language features or optimizations.

Installation

Prerequisites

  1. Java (any reasonably recent version should work).
  2. Graphviz software installed on your system : pip install graphviz

Installing the Compiler

Clone the repository:

git clone [URL of project]
cd mini-python-compiler

Ensure that the prerequisites are met, particularly that Java and Graphviz are properly installed.


Usage

Building and Running with Makefile

A Makefile is provided to simplify compilation, execution, and cleanup. The primary targets are run and clean.

Available Makefile Targets

  • Compile the project: make compile
  • Execute the compiler: make execute
  • Build and run the compiler: make run
  • Clean the build artifacts: make clean

Launching the Compiler & Web UI

To compile and run the compiler along with the web interface, simply execute: make

This command will:

  1. Compile the Java source code.
  2. Execute the Main class, which starts an HTTP server locally (by default on http://localhost:8080/).

Open your web browser and navigate to the address above to see the interface:

  • On the left: A sample Mini Python code snippet.
  • On the right: The automatically generated AST or a list of the errors.

Command-line / Advanced Usage

Although the primary usage is via the HTML interface, you can adapt the project to run lexical and syntax analysis in a purely command-line manner by modifying the Java classes and bypassing the HTTP server calls. Currently, the recommended (and simplest) approach is to use the provided Makefile targets to build and run the project.


Examples

Within the HTML interface, you’ll find various test scripts (Arbres, exemples d'erreurs etc.):

  • Arbre 1: Demonstrates the base of the langage with list initialization, arithmetic, and if/else, loop...
  • Arbre 2: Showcases a simpler exemple.
  • Erreurs Syntaxiques 3 and 4: Additional usage scenarios with multiple syntax errors.
  • Erreurs Lexicales: Showcases most of the lexical errors.

You can quickly modify the code snippet on the left pane and observe the updated AST or errors on the right.


Project Management

In-depth details of the operation of the compiler are documented in the report located at docs/gestion_de_projet/Rapport.pdf, as well as the meeting reports in CR_reunions.pdf.


Acknowledgements

  • Graphviz for the AST visualization.
  • Java's HttpServer for the lightweight web server integration.
  • Special thanks to our professors, peers, and any external libraries that made this project possible.

About

Chouette Compiler est un compilateur pour le langage Mini Python, implémenté en Java. Il effectue l'analyse lexicale et syntaxique pour générer un arbre syntaxique abstrait (AST). L'interface utilise un serveur Java HttpServer pour visualiser le code source et l'AST, ce dernier étant généré graphiquement avec Graphviz.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •