Started work for type inference
This commit is contained in:
@ -1,12 +1,47 @@
|
||||
type variable = string
|
||||
|
||||
val globalIdentifier : int ref
|
||||
|
||||
module VariableMap : Map.S with type key = variable
|
||||
module VariableSet : Set.S with type elt = string
|
||||
|
||||
type ftype =
|
||||
IntegerType
|
||||
| BooleanType
|
||||
| PolimorphicType of variable
|
||||
| FunctionType of ftype list * ftype
|
||||
type fsubstitution = (* goes from polimorphic types to types *)
|
||||
ftype VariableMap.t
|
||||
type fenvironment = (* goes from variables to types *)
|
||||
ftype VariableMap.t
|
||||
type typingshape = (* tuple of a simple type environment and a simple type *)
|
||||
fenvironment * ftype
|
||||
|
||||
type intermediaryType =
|
||||
IInteger
|
||||
| IBoolean
|
||||
| IVariable of variable
|
||||
| IFunction of variable list * ftype list * intermediaryType
|
||||
| IApplication of intermediaryType * intermediaryType list
|
||||
| IPlus of intermediaryType * intermediaryType
|
||||
| IMinus of intermediaryType * intermediaryType
|
||||
| ITimes of intermediaryType * intermediaryType
|
||||
| IDivision of intermediaryType * intermediaryType
|
||||
| IModulo of intermediaryType * intermediaryType
|
||||
| IPower of intermediaryType * intermediaryType
|
||||
| IPowerMod of intermediaryType * intermediaryType * intermediaryType
|
||||
| IRand of intermediaryType
|
||||
| IBAnd of intermediaryType * intermediaryType
|
||||
| IBOr of intermediaryType * intermediaryType
|
||||
| IBNot of intermediaryType
|
||||
| ICmp of intermediaryType * intermediaryType
|
||||
| ICmpLess of intermediaryType * intermediaryType
|
||||
| ICmpLessEq of intermediaryType * intermediaryType
|
||||
| ICmpGreater of intermediaryType * intermediaryType
|
||||
| ICmpGreaterEq of intermediaryType * intermediaryType
|
||||
| IIfThenElse of intermediaryType * intermediaryType * intermediaryType
|
||||
| ILetIn of variable * ftype * intermediaryType * intermediaryType
|
||||
| ILetFun of variable * ftype * variable list * ftype list * intermediaryType * intermediaryType
|
||||
|
||||
type t_exp =
|
||||
Integer of int (* x := a *)
|
||||
@ -32,7 +67,7 @@ type t_exp =
|
||||
| CmpGreaterEq of t_exp * t_exp (* x >= x *)
|
||||
| IfThenElse of t_exp * t_exp * t_exp (* if b then c else c *)
|
||||
| LetIn of variable * t_exp * t_exp (* let x = x in x *)
|
||||
| LetFun of variable * variable list * ftype * t_exp * t_exp (* let rec x: t. x in x*)
|
||||
| LetFun of variable * variable list * ftype * t_exp * t_exp (* let rec x: t. x in x *)
|
||||
|
||||
type permittedValues =
|
||||
IntegerPermitted of int
|
||||
|
||||
Reference in New Issue
Block a user