-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTypeExcept.ml
35 lines (33 loc) · 1.28 KB
/
TypeExcept.ml
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
exception AlreadyDeclared of string
exception ClassAlreadyDefined of string
exception ConstructorAlreadyDefined of string
exception InvalidConstructorName of string * Location.t * string
exception MethodAlreadyDefined of string * Type.t
exception NoSuchConstructor of string
exception VariableAlreadyDefined of string
exception WrongType of string
exception RepeatedModifier of string
exception AbstractMethodInNormalClass of string
exception IllegalModifiersCombination of string * string
exception CannotHaveMethodBody of string
exception MissingMethodBody of string
exception IncompatibleType of string
exception MissingReturnStatement
exception WrongMethodArguments of string * Type.t list * Type.t list
exception WrongConstructorArguments of string * Type.t list
exception CannotFindSymbol of string
exception NotAccessible of string
(* TODO check that the above Exception correspond to java exceptions *)
let print_error error =
let colorRed = "\x1b[0;31m" in
let colorReset = "\x1b[0m" in
match error with
| InvalidConstructorName(cname, cloc, class_name) -> (
print_string (colorRed ^ "Invalid constructor " ^ cname ^ " for class " ^ class_name ^ "\n");
print_string "@ ";
Location.print cloc;
print_string colorReset;
raise error
)
| _ as e -> raise e
;;