X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=compiler%2Fsrc%2Flib%2Ftiger%2Ftiger_error.mli;h=9090ad481cea6192139ad93a45b97bad5ad88f4c;hb=54e838f482844369048d4f88e87a092a87162b72;hp=25072b42763563c434d7ea8db129fae31cdc612e;hpb=7c14a966d15aab098a4239b6ae6a3fc207504e7f;p=tiger.ml.git diff --git a/compiler/src/lib/tiger/tiger_error.mli b/compiler/src/lib/tiger/tiger_error.mli index 25072b4..9090ad4 100644 --- a/compiler/src/lib/tiger/tiger_error.mli +++ b/compiler/src/lib/tiger/tiger_error.mli @@ -1,3 +1,80 @@ -exception T of string +module Abs = Tiger_absyn +module Pos = Tiger_position +module Sym = Tiger_symbol +module Typ = Tiger_env_type -val exn : pos:Tiger_position.t -> msg:string -> 'a +type t = + | Invalid_syntax of Pos.t + | Unknown_id of {id : Sym.t; pos : Pos.t} + | Unknown_type of {ty_id : Sym.t; pos : Pos.t} + | Id_is_a_function of {id : Sym.t; pos : Pos.t} + | Id_not_a_function of {id : Sym.t; pos : Pos.t} + | No_such_field_in_record of {field : Sym.t; record : Typ.t; pos : Pos.t} + | Exp_not_a_record of {ty : Typ.t; pos : Pos.t} + | Exp_not_an_array of {ty : Typ.t; pos : Pos.t} + | Wrong_type of + { expected : Typ.t + ; given : Typ.t + ; pos : Pos.t + } + | Wrong_type_of_expression_in_var_dec of + { var_id : Sym.t + ; expected : Typ.t + ; given : Typ.t + ; pos : Pos.t + } + | Wrong_type_used_as_record of + { ty_id : Sym.t + ; ty : Typ.t + ; pos : Pos.t + } + | Wrong_type_used_as_array of + { ty_id : Sym.t + ; ty : Typ.t + ; pos : Pos.t + } + | Wrong_type_of_field_value of + { field_id : Sym.t + ; expected : Typ.t + ; given : Typ.t + ; pos : Pos.t + } + | Wrong_type_of_arg of + { func : Sym.t + ; expected : Typ.t + ; given : Typ.t + ; pos : Pos.t + } + | Wrong_number_of_args of + { func : Sym.t + ; expected : int + ; given : int + ; pos : Pos.t + } + | Invalid_operand_type of + { oper : Abs.oper + ; valid : string list + ; given : Typ.t + ; pos : Pos.t + } + | Different_operand_types of + { oper : Abs.oper + ; left : Typ.t + ; right : Typ.t + ; pos : Pos.t + } + +exception T of t + +val raise : t -> 'a + +val to_string : t -> string + +val is_unknown_id : t -> bool +val is_unknown_type : t -> bool +val is_wrong_type : t -> bool +val is_wrong_number_of_args : t -> bool +val is_invalid_syntax : t -> bool +val is_not_a_record : t -> bool +val is_not_an_array : t -> bool +val is_no_such_field_in_record : t -> bool