Giter VIP home page Giter VIP logo

tiger's Introduction

Tiger Compiler

Tiger Compiler from "Modern Compiler Implementation in ML" by Andrew W. Appel

Introduction

This is a Tiger compiler with all modules completed until Chapter 12 in the book. Basically I followed all the instructions from the book without much alternation. I also tried to adhere to the functional style as much as possible, that means, minimize the usage of mutable data structures.

Requirement

So far the compiler works with either mac or linux. Besides that, you need to have Standard ML and spim installed. Both of them can be fetched via homebrew.

Standard ML is obviously need to compile the programs. Since the compiler generates spim code, you'll need the SPIM simulator to actually run the executables.

Build

To build the compiler, simply run

make main

This will build the image using sources.cm. Note that it currently doesn't support windows.

Compile

Given a tiger source program foo.tig, to compile it, you'll need to first copy the file to the project directory, and run

make foo.spim

This will compile the file, append runtime.s to it, and generate a output SPIM program called foo.spim. Then to execute the program, run

spim -file foo.spim

If foo.spim exists, make will not overwrite it. You must remove the file before running make again.

Future Work

The second half of the book covers a lot of interesting stuff, and I'm thinking about extending the compile with the following features:

  • Garbage Collection
  • OO Features
  • Functional Features
  • Polymorphism and Type Inference
  • Optimizations

tiger's People

Contributors

humberto-ortiz avatar sunchao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tiger's Issues

Bug in unTx function

I know this repo was finished a long time ago but as a person who is learning how to write a Tiger compiler, this is still a valuable resource. As I read your code, I double that the unNx function has an error.
image

I think the correct implementation for unNx with Cx should be something like this.

    let val t = Temp.newlabel() in T.SEQ(genstm(t,t), T.LABEL t) end

Looking forward to hearing from you. xD

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.