Tiny Compiler

Contents

Materials

This is a set of self-guided activities to demonstrate the structure of a tiny compiler for a tiny programming language.

Exploration 1: Front End

Exploration 2: Back End

Exploration 3: Java CUP Parser

Completing the Tiny Back End (Revised End-of-Term Mini-Project)

According to the revised end-of-term plan, you will complete the implementation of the Tiny Compiler Back End with your project team.

Configure Team Repo

The guided exercise has you clone the public repository with starter code. Here’s how to get connected to your team repo after doing so:

  1. Accept the GitHub invitation in your email.
  2. (One teammate who “drove” the main copy in class:) Add and commit any changes you have made so far.
  3. Run git remote set-url origin URL, replacing URL with the URL for your repository.
  4. Run git push.
  5. (For Tuesday folks:) I fixed a typo that you will encounter when you uncomment codee in exercise 10. Please run:
    • git pull git@github.com:wellesleycs301s21t4/tiny-back.git main
  6. Now other teammates can clone the team repo (or run the git remote set-url origin URL step in their local copy).

Assembler Support

To assemble the x86 assembly text generated by the CodeGen into an executable x86 binary and to build the runtime library that interacts with the operating system to provide the implementations of print and input, the Tiny compiler’s Link phase uses the standard assembler for a C compiler toolchain.

If the Link phase raises errors about not finding gcc or clang, this is because you don’t currently have those tools installed.

  • On macOS, run this in the terminal to initiate installation of the developer tools: xcode-select --install
  • On Ubuntu, run this in the terminal to install standard development tools: sudo apt install build-essential

Submitting

To submit the Tiny Back End, please complete all code parts of the exercises. Optionally, you may submit written answers to other exercises by editing the README.md file with text answers or to include a link to a shared Google Doc, etc. The code is the only required part. As usual, it should be in good style and well documented.

To submit, please follow the Pull Request submission steps as you did for the Roost project. Instead of using a separate checkpoint branch, just create the pull request directly from the main branch:

  • base:reviewcompare:main

For all work, consider May 28 the standard deadline. If really necessary, work can be accepted until 4 PM Tuesday June 1 ET, but I cannot guarantee to be available for assistance during this extended window.