CS代考程序代写 interpreter Create a file interpreter_bigstep.ml
Create a file interpreter_bigstep.ml
with the following data type:
type exp =
| True
| False
| If of exp * exp * exp
| Num of int
| IsZero of exp
| Plus of exp * exp
| Mult of exp * exp
Create the function: string_of_exp : exp -> string
let rec string_of_exp (e : exp) = … insert code …
The function string_of_exp takes in input an expression and returns its corresponding human-readable string.
Test string_of_exp with input expressions (which you will have to figure out) that returns the human-readable programs:
1) 3
2) true
3) false
4) (3 + 2)
5) (3 * 2)
6) (3 + (3 + (2 * (3 + 2))))
7) if true then 3 else 5
8) if false then (3 + 2) else (5 + 1)
9) if (false + true) then (3 + false) else (3 * 1)
10) if (isZero 1) then (3 + 2) else (5 + 1)
11) (isZero (3 * 5))
12) (isZero if (isZero 1) then (3 + 2) else (5 + 1))
13) (3 + if (isZero 1) then (3 + 2) else (5 + 1))
14) (3 + (if (isZero 1) then (3 + 2) else (5 + 1) * (isZero true)))
15) if if true then true else false then (3 + 2) else (5 + 1)
16) if true then if (isZero (3 * 5)) then (3 + 2) else (5 + 1) else if true then (3 * 2) else (2 * (3 + 2))