COS 320, Spring 2000. Programming Assignment
Programming Assignment 1: Interpreter
Described in Modern Compiler
Implementation, Chapter 1.
Getting started with ML
- Use CIT Sparc machines (CS 101 cluster, sunlab1-sunlab4, yuma,
tucson, flagstaff). If you have a PC running Linux, then you should
also be able to install ML there. You can grab a copy of the compiler
from the official
server at Bell Labs.
- Edit your .cshrc or equivalent so that
your path contains /u/cos320/ml.
- Make a new directory as1 for this assignment.
- Copy the files /u/cos320/chap1/*.sml and
/u/cos320/chap1/*.cm into as1.
- Please, familiarize yourself with the code that is already there.
Pay special attention to how it is divided into separate
- Edit maxarg.sml and interp.sml
until they do something useful.
- You may find the ML Basis
- Run sml.
- Inside the running ML session invoke CM.make();
to compile your code.
- Observe the compiler's messages and fix the problems that are
reported. It may be a good idea to have the ML session in a
separate xterm window. You can keep a running ML session while you
are debugging. Simply type CM.make(); again when you
think you have fixed the problem. This procedure saves a lot of time,
because you avoid starting ML over and over again.
- Test your code by invoking Test.maxarg(); and
Test.interp(); (still within the running ML session).
- If your code still does not work as intended, then debug,
recompile, rerun. Repeat as necessary.
- Submit by submit 1 maxarg.sml interp.sml.
- Once you are done, to further familiarize yourself with ML and
with simple interpreters you may want to spend some time extending the
language and your interpreter. The extension might add new operators
for comparison (use 0 for false and non-zero for true outcomes), and
syntax that takes the "straight-line programming language" to
something with conditionals (if) or loops
(while). This does not give you extra credit
immediately, but it could help you get up to speed. Eventually it may
even pay a nice dividend when you are working on future assignments.