Homework assignment 2
The required infrastructure for this homework assignment (parser,
pretty-printing, and main function) have been written for you and
are in the files in hw2.tar. To do the
assignment, you do need to understand some of the code here, but
not all. Also, the libraries for Set and Map will help you in
writing short nice solutions.
Before you can start the assignment, you need to download and
unzip the tar file hw2.tar containing the
files you need. After you download the file, the following will
put the files in a directory c311/hw2:
> tar xf hw2.tar
To compile, change directory to the hw2 directory above and
do as follows:
> make depend
> make main
To run the compiled program:
> ./main
Assignment
- The relevent files for the assignment are:
- mlexer.mll - the specification of the lexical analyzer
- mparser.mly - the specification of the parser
- absyn.ml - contains the grammar for abstract syntax of expressions
to be manipulated
- scope.ml - contains the beginnings of your solution
- main.ml - the top level
- util.ml - a file with one trivial general function
- Makefile - the makefile
- tests - a few simple test cases
- Write three functions to compute the free variables, bound variables,
and DeBruijn indices. The functions currently just raise an exception which
makes the program print a message saying it is not yet done. The only file
you actually need to change is scope.ml.
Submission
Turn in the file scope.ml on the electronic
submission page.