Assignment 4
CS 550 Programming Languages
Instructor: Jeremy Johnson
Due date: Mon. May 11 at 11:59 pm
Functional Mini Language (100 points)
This assignment modifies the mini language and mini language interpreter
from lecture 2 to support functional
programming. You will treat Proc statements as expressions that
can be assigned to variables, passed as arguments to function calls, and
returned as values from functions. This also allows unamed functions
(like lambda expressions). To do this requires a syntactic change and
a semantic change. Now values in an environment can be ints, lists, or
procs. Furthermore, you need to allow nested procedures and hence must
support a chain of environments. Finally, you will explore both static
and dynamic scope rules. You may model your solution after the scheme
interpreter and its variants discussed in
lecture 4. If you did not successfully
complete assignment 2 or
assignment 3 you may extend the interpreter from
lecture 2.
This assignment may be written in any of the following languages: C, C++, java, python,
and their corresponding parser generators,
though the current mini language interpreter provided from me is written in C++ and
bison(there is some java code but that code does not suppport the extension of the mini
language to allow procedures).
Background Information
Background information is available in lectures
2 and
4.
What to do
Modify the mini language grammar, parser and interpreter to treat Proc
as an expression so that it can be assigned to variables, passed as an
argument, and returned as a function value. You must support nested procedures
and should use a list of environments to resolve variable references. You wil
need to implement two versions of your interpreter: 1) using static scope, and
2) using dynamic scope. You must test your interpreters with mini language
programs that have a nested procedure, a procedure that passes a procedure
as an argument, a procedure that returns a procedure, and atleast one example
where you get different results using static and dynamic scoping.
How to submit
Students should submit their solution electronically using webct.
Only one submission is required per group. The group leader for the
assignment should submit the assignment.
Submit a gzipped tar file, called A4.tar.gz (the tar file should contain
a directory called A4 which contains the files). The tar file should
contain source code, instructions how to run your programs, sample input
and output files, and a README file. The README file should describe all
files that are included, contain instructions how to build and use the
code, and outline how the code works. The README file should also contain
a list of all group members and the group leader for the submitted assignment.
You should also indicate how you
tested your code. If your program is not working, you
should clearly state this in the README file. Code should be
documented (clear specifications and comments for any tricky parts of the code).
Those questions that involve hand computations or proofs should be submitted
as pdf or text files whose name indicates the question.