Exercise 1 Consider the following programming language, called miniML, that features (recursive) procedures and explicit references.
Syntax The syntax is defined as follows:
| P | E | |
| E | n | |
| | | x | |
| | | E + E | E E | E E | E/E | |
| | | E E | |
| | | iszero E | |
| | | if E then E else E | |
| | | let x = E in E | |
| | | letrec f(x) = E in E | |
| | | proc x E | |
| | | E E | |
| | | ref E | |
| | | ! E | |
| | | E := E | |
| | | E;E | |
| | | begin E end |
Semantics The semantics is defined with the following domain:
| Val | = | Z + Bool + Procedure + RecProcedure + Loc |
| Procedure | = | Var E Env |
| RecProcedure | = | Var Var E Env |
| Env | = | Var Val |
| Mem | = | Loc Val |
1
and evaluation rules:
,0 0,1 ,0
,0 ` iszero E true,1 ,0 ` iszero
,0 ` E1 true,1 ,1 ` E2 v,2
,0 ` if E1 then E2 else E3 v,2
,0 ` E1 false,1 ,1 ` E3 v,2
,0 ` if E1 then E2 else E3 v,2
,0 ` E1 v1,1 [x 7 v1],1 ` E2 v,2
,0 ` let x = E1 in E2 v,2
[f 7 (f,x,E1,)],0 ` E2 v,1
, ` letrec f(x) = E in E v, , ` proc x E (x,E,),
Dom(1)
,0 ` E v,1
,0 ` begin E end v,1
Implement an interpreter of miniML. Raise an exception UndefinedSemantics whenever the semantics is undefined. Skeleton code will be provided (before you start, see README.md).
2

![[Solved] ENE4014-Homework 3](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] ENE4014-Homework 2](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.