diff options
author | Paweł Dybiec <pdybiec@stud.cs.uni.wroc.pl> | 2018-10-30 15:32:56 +0100 |
---|---|---|
committer | Paweł Dybiec <pdybiec@stud.cs.uni.wroc.pl> | 2018-10-30 15:32:56 +0100 |
commit | b798ac29c37299b2f761243ae92ab8f7c4c4d7f1 (patch) | |
tree | eb9b9cc9be294fe5bd3acf9a342098ffc0ea06e5 /source/xi_lib/types.ml |
Initial commit
Diffstat (limited to 'source/xi_lib/types.ml')
-rw-r--r-- | source/xi_lib/types.ml | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/xi_lib/types.ml b/source/xi_lib/types.ml new file mode 100644 index 0000000..14809cc --- /dev/null +++ b/source/xi_lib/types.ml @@ -0,0 +1,31 @@ + +type normal_type + = TP_Int + | TP_Bool + | TP_Array of normal_type + +let rec string_of_normal_type = function + | TP_Int -> "int" + | TP_Bool -> "bool" + | TP_Array el -> string_of_normal_type el ^ "[]" + +type extended_type = normal_type list + +let string_of_extended_type xs = + String.concat ", " @@ List.map string_of_normal_type xs + +type result_type + = RT_Unit + | RT_Void + +type env_type + = ENVTP_Var of normal_type + | ENVTP_Fn of extended_type * extended_type + +let string_of_env_type = function + | ENVTP_Var t -> string_of_normal_type t + | ENVTP_Fn (xs, []) -> Format.sprintf "fn(%s)" + (string_of_extended_type xs) + | ENVTP_Fn (xs, rs) -> Format.sprintf "fn(%s) -> (%s)" + (string_of_extended_type xs) + (string_of_extended_type rs) \ No newline at end of file |