Code Monkey home page Code Monkey logo

compiler's Introduction

Compiler

A MIPS compiler for the Tiger language created by Andrew Appel.

Pre-requisite:

This compiler is written in SML (Standard ML of New Jersey) v110.99. Get the latest version here: https://www.smlnj.org/.

SPIM can be used to test the generated MIPS assembly, which can be downloaded here: http://spimsimulator.sourceforge.net/.

The Tiger Language:

The target language of this compiler, Tiger, is a small language with nested functions, record values with implicit pointers, arrays, integer and string variables, and a few simple structured control constructs. A detailed manual can be found in the PDF file tiger.pdf in this repo.

Instructions:

To use the compiler, first type sml in terminal window to start the repl.

Then, type CM.make "sources.cm" to compiler the modules.

Now, assembly for the Tiger language can be generated using the function Main.compile. For example, to compiler the program queens.tig which solves the 8 Queens Problem, simply type Main.compile queens.tig, and an MIPS assembly file queens.s will be generated in the same directory.

Features:

  • Tiger is a typed language and our compiler does type checking. If there is a typing error, an error message will be generated.
  • Our compiler also does bounds checking for array subscriptions. If the index is larger than the size of the array or smaller than 0, the program will instantly exit.

compiler's People

Contributors

yc2454 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.