A Tiger Compiler Frontend for C--

This is a sample front-end for the Quick C-- compiler that I developed shortly before I entered graduate school. This compiler emits C-- code. The runtime system supports garbage collection, and two different implementations of exceptions.

The original sources can be found on the Quick C-- website. The original version depends on the Quick C-- build tree, Plan 9 mk, and the noweb literate programming tools. This version is identical, except you only need OCaml, GCC, and a binary distribution of Quick C-- to build it.

The tiger compiler is fully documented. The complete annotated source code can be downloaded or viewed online. In addition, the Tiger compiler was presented during a tutorial session at PLDI in 2004; the slides are available below.

Downloads

Source Files: tigerc.tar.gz (38K).

Complete, Annotated Sources: [ PS | PDF | HTML ]

Slides from PLDI Tutorial: [ PS | PDF ]

README from the distribution

                   Tiger front-end for C--

This directory contains source code for a Tiger language
compiler. This compiler is a front end for the Quick C-- compiler
primarily used for testing Quick C--. The Tiger language is described
in "Modern Compiler Implementation in ML" by Andrew W. Appel. To quote
from Appendix A of this book:

  The Tiger language is a small language with nested functions,
  record values with implicit pointers, arrays, integer and
  string variables, and a few simple structured control constructs.

BUILDING
----------------------------------------------------------------------

This version of the tiger compiler requires OCaml, GCC, and a binary
version of Quick C-- to build. To build the sources, use the build.sh
script.

  ./build.sh

The following files will be produced:

   tigerc     - the tiger compiler
   stdlib.a   - the tiger standard library
   runtime.o  - the stand-alone startup code

USING THE COMPILER
----------------------------------------------------------------------
The tigerc program converts a tiger program into an equivalent c--
program which can then be compiled with qc--. Since this compiler is
intended to be used for testing qc--, it does not attempt to call qc--
or the system linker to produce an executable program. In it's most
basic usage:

   tigerc source.tig > source.c--

The tiger compiler supports two implementations of exceptions. The
default implementation uses a C-- "cut to". Alternatively, you can
generate code for the stack unwinding implementation:

  tigerc -unwind source.tig > source.c--

For additional command line options see:

  tigerc -help

A simple standard library and startup code are included with the
compiler. In order to create an executable, these will have to be
linked with the final result. The qc-- compiler can handle this for
us: 

   qc-- -globals -o source runtime.o stdlib.a source.c--