|
15 | 15 |
|
16 | 16 | (* Auxiliary type for reporting syntax errors *)
|
17 | 17 |
|
18 |
| -type error = |
19 |
| - | Unclosed of Location.t * string * Location.t * string |
20 |
| - | Expecting of Location.t * string |
21 |
| - | Not_expecting of Location.t * string |
22 |
| - | Applicative_path of Location.t |
23 |
| - | Variable_in_scope of Location.t * string |
24 |
| - | Other of Location.t |
25 |
| - | Ill_formed_ast of Location.t * string |
26 |
| - | Invalid_package_type of Location.t * string |
| 18 | +type error = Variable_in_scope of Location.t * string |
27 | 19 |
|
28 | 20 | exception Error of error
|
29 |
| -exception Escape_error |
30 |
| - |
31 |
| -let prepare_error = function |
32 |
| - | Unclosed (opening_loc, opening, closing_loc, closing) -> |
33 |
| - Location.errorf ~loc:closing_loc |
34 |
| - ~sub: |
35 |
| - [ |
36 |
| - Location.errorf ~loc:opening_loc "This '%s' might be unmatched" opening; |
37 |
| - ] |
38 |
| - ~if_highlight: |
39 |
| - (Printf.sprintf |
40 |
| - "Syntax error: '%s' expected, the highlighted '%s' might be \ |
41 |
| - unmatched" |
42 |
| - closing opening) |
43 |
| - "Syntax error: '%s' expected" closing |
44 |
| - | Expecting (loc, nonterm) -> |
45 |
| - Location.errorf ~loc "Syntax error: %s expected." nonterm |
46 |
| - | Not_expecting (loc, nonterm) -> |
47 |
| - Location.errorf ~loc "Syntax error: %s not expected." nonterm |
48 |
| - | Applicative_path loc -> |
49 |
| - Location.errorf ~loc |
50 |
| - "Syntax error: applicative paths of the form F(X).t are not supported \ |
51 |
| - when the option -no-app-func is set." |
52 |
| - | Variable_in_scope (loc, var) -> |
53 |
| - Location.errorf ~loc |
54 |
| - "In this scoped type, variable '%s is reserved for the local type %s." var |
55 |
| - var |
56 |
| - | Other loc -> Location.errorf ~loc "Syntax error" |
57 |
| - | Ill_formed_ast (loc, s) -> |
58 |
| - Location.errorf ~loc "broken invariant in parsetree: %s" s |
59 |
| - | Invalid_package_type (loc, s) -> |
60 |
| - Location.errorf ~loc "invalid package type: %s" s |
61 |
| - |
62 |
| -let () = |
63 |
| - Location.register_error_of_exn (function |
64 |
| - | Error err -> Some (prepare_error err) |
65 |
| - | _ -> None) |
66 |
| - |
67 |
| -let report_error ppf err = Location.report_error ppf (prepare_error err) |
68 |
| - |
69 |
| -let location_of_error = function |
70 |
| - | Unclosed (l, _, _, _) |
71 |
| - | Applicative_path l |
72 |
| - | Variable_in_scope (l, _) |
73 |
| - | Other l |
74 |
| - | Not_expecting (l, _) |
75 |
| - | Ill_formed_ast (l, _) |
76 |
| - | Invalid_package_type (l, _) |
77 |
| - | Expecting (l, _) -> |
78 |
| - l |
79 |
| - |
80 |
| -let ill_formed_ast loc s = raise (Error (Ill_formed_ast (loc, s))) |
0 commit comments