Type checking for miniFun, adding some tests

This commit is contained in:
elvis
2024-10-24 15:35:42 +02:00
parent 8d327a08bb
commit 0c9490780a
6 changed files with 401 additions and 13 deletions

View File

@ -1,12 +1,16 @@
type variable = string
module VariableMap : Map.S with type key = variable
type ftype =
IntegerType
| BooleanType
| FunctionType of ftype list * ftype
type t_exp =
Integer of int
| Boolean of bool
| Variable of variable
| Function of variable list * t_exp
| Function of variable list * ftype * t_exp
| Application of t_exp * t_exp list
| Plus of t_exp * t_exp
| Minus of t_exp * t_exp
@ -26,7 +30,7 @@ type t_exp =
| CmpGreaterEq of t_exp * t_exp
| IfThenElse of t_exp * t_exp * t_exp
| LetIn of variable * t_exp * t_exp
| LetFun of variable * variable list * t_exp * t_exp
| LetFun of variable * variable list * ftype * t_exp * t_exp
type permittedValues =
IntegerPermitted of int
@ -47,5 +51,8 @@ exception AbsentAssignment of string
exception WrongType of string
exception DivisionByZero of string
exception WrongAriety of string
exception WrongTypeSpecification of string
val reduce : t_exp -> int -> int
val typecheck : t_exp -> bool