OCaml Parser HW9

OCaml Parser HW9
Grading criteria
• V (25/30) Your code compiles and passes all test cases.
• % (5/30) You follow the “Writing readable code” guidelines below.
Writing readable code
1. 4 Nice indentation: Your code should look reasonably nice.
2. No long lines: Do not write any lines that are over 100 characters in length.
3. Comments[CHANGED]: Every top-level auxiliary definition that is not exposed by the signature (the corresponding mli file) should have a brief
comment describing its functionality. Theoretically, you should also document all your public functions in the signature, but Favonia has done that for
you. It is also strongly recommended to document cool, interesting, or unusual logic in your code, though we will not take points off for this.
In Homework 9, you will implement the core » pattern matching that powers our mini OCaml interpreter.
1. Download these two files:
– syntax.ml (updated 4/19 10am): & This is the file defining the syntax of the mini OCaml.
– E Note: Favonia may upgrade syntax.ml to support more OCaml features, but Homework 9 shall remain stable.
– pattern.mli (updated 4/19 10am): & This is the signature in an isolated file. (Review Textbook Section 5.5 E if you are not familiar with the mli files.)
2. Alternatively, if you are using the Visual Studio Code cheating mode (ocamllsp), please complete the “Preparation” section in the Hidden Homework
9+ below. While there are other ways to re-activate the cheating mode, using dune is the easiest.
3. Carefully read these parts:
– Comments about the constructors of the variant types pattern and value in syntax.ml.
– The entire pattern.mli.
4. Create pattern.ml (no “‘” in the end) that implements the signature in pattern.mli.
Tips for Using utop
Because this homework involves multiple files, you have to follow these steps to load pattern.ml in utop:
1. #mod_use “environment.ml”: load the environment as the module Environment. This is assuming that you have completed the lab, but an incomplete
environment.ml might still work.
2. #mod_use “syntax.ml”: load the syntax as the module Syntax
3. #use “pattern.ml” : load your Homework 9!
Submission
Submit both your environment.ml (from the lab) and pattern.ml to GradeScope “Lab 4/18 + Homework 9”.