Java Python CSE 305: Language Interpreter Design
Due: July 8 2024, 11:59pm
1 Overview
The goal of this project is to understand and build an interpreter for a small, OCaml-like, stack- based bytecode language. You will be implementing this interpreter in OCaml, like the previous assignments. The project is broken down into three parts. Part 1 is defined in Section 4 and is worth 100 points, Part 2 is defined in Section 5 and is worth 150 points, and Part 3 is defined in Section 6 and is worth 150 points. All parts are due by July 8 2024, 11:59pm, but we recommend you keep to the following time schedule for each part:
1. Part 1 by June 17 2024, 11:59pm(100 points)
2. Part 2 by June 26 2024, 11:59pm(150 points)
3. Part 3 by July 8 2024, 11:59pm(150 points) **this is the last day to submit**
This is an individual project. You will submit a file named interpreter.ml which contains a function, interpreter, with the following type signature:
val interpreter : string * string -> unit
If your program does not match the type signature, it will not compile on Autolab and you will receive 0 points. You may, however, have helper functions defined outside of interpreter—the grader is only explicitly concerned with the type of interpreter.
You must submit a solution for each part. Each part is graded individually, so you may wish, for example, to submit your Part 3 solution for parts 1 and 2. Late submissions will not be accepted and will be given a score of 0. Test cases will also be provided on Piazza for you to test your code locally. These will not be exhaustive, so you are highly encouraged to write your own tests to check your interpreter against all the functionality described in this document.
2 Functionality
Given the following function header:
let interpreter ((input : string), (output : string )) : unit = . . .
input and output will be passed in as strings that represent paths to files just like in the Pangram assignment. Your function should write any output your interpreter produces to the file specified by output. In the examples below, the input file is read from top to bottom and then each com- mand is executed by your interpreter in the order it was read. It is incredibly useful to read in all of the commands into a list prior to executing them, separating input from the actual interpreta- tion of the commands. The input file can be arbitrarily long. You may find the library function String.split__ on__char to be useful for separating a string into a string list.
3 Grammar
The following is a context free grammar for the bytecode language you will be implementing. Terminal symbols are identified by monospace font, and nontermina