Skip to content

Mini Python Compiler Capable of Printing: Strings and Arithmetic Operations

License

Notifications You must be signed in to change notification settings

yycorcino/python-flex-bison-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Python

Mini Python Compiler

A Simple Python Compiler that is capable of printing strings and printing basic arithmetic operations.

About The Project

A mini compiler demonstrating the use of data types utilizing Flex and Bison. In the case of Python, the print statement is able to take in multiple data types such as integers and string. The developer in Python would simply call print(<value>), however inside the compiler it requires complex design to determine the value type then it can print to the console.

Getting Started

Installing and configuring Flex and Bison using Docker.

Prerequisites

Have Docker pre-installed into your operating system.

  • Using CLI Command for Ubuntu
    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    

Installation

Below is an example of how you download this project and start using Docker.

  1. Clone the repo
    git clone <repo_url>
    
  2. Go into the Project Repository
    cd /path/to/repository
    
  3. Build Image
    sudo docker build -t compiler-image .
    
  4. Run Container
    sudo docker run -it compiler-image
    
  5. Run Test inside Container
    $ make
    $ ./compiler <source_file>
    

Usage

Using the pre-defined Python file to test arithmetic operations and printing of strings.

$ make
$ ./compiler __test__/arithmetic.py

Remove all generated files.

make clean

License

Distributed under the MIT License. See LICENSE.txt for more information.