-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpression.mli
executable file
·79 lines (62 loc) · 2.13 KB
/
expression.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
type myStack =
EmptyStack
| NonEmptyStack of int * myStack
type myMap =
| Map of (int, string) Hashtbl.t
type myTree =
| EmptyTree
| NonEmptyTree of int * myTree * myTree * int
type expr =
| TreeConst of myTree
| MapConst of myMap
| StackConst of myStack
| Id of string
| IntConst of int
| Add of expr * expr
| Sub of expr * expr
| If of expr * expr * expr
| Let of string * expr * expr
| BoolConst of bool
| Not of expr
| Or of expr * expr
| And of expr * expr
| Equals of expr * expr
| Closure of string * expr * env
(* Corresponds to the underlying function closure. Note that it is a normal form as IntConst and BoolConst. *)
| FunDef of string * expr
(* The abstract syntactic structure. This doesn't have the information about the environment. *)
| FunApp of expr * expr
(* Application of function *)
| CreateStack of string(*The name of the list*)
| PushToStack of string * int(*The list identifier and the value to add (int for now)*)
| TopOfStack of string
| PopFromStack of string
| CreateMap of string
| AddMapping of string * int * string
| GetMapValue of string * int
| CreateTree of string(*The name of tree*)
| AddElementTree of string * int(*Tree identifier and the value to add*)
| DeleteElementTree of string * int(*Tree identifier and the value to delete*)
| EndProgram
and env =
EmptyEnv
| NonEmptyEnv of (string * expr) * env
type exprResult =
{
mutable res_expr : expr;
mutable res_env : env
}
val string_of_expr : expr -> string
val string_of_stack : myStack -> string
val string_of_tree : myTree -> string
val string_of_map : myMap -> string
val emptyEnv : unit -> env
val addBinding : string -> expr -> env -> env
val apply : string -> env -> expr
val addElementToStack : int -> string -> env -> env
val topOfStack : string -> env -> expr
val popFromStack : string -> env -> env
val addMapping : int -> string -> string -> env -> env
val getValueFromKey : int -> string -> env -> expr
val addElementToTree : string -> int -> env -> env
val removeElementFromTree : string -> int -> env -> env