Skip to content
Browse files

Move warning management to Location

  • Loading branch information...
1 parent ec90438 commit 29f99543d902668d90ab78c80e569139727f497b @def-lkb def-lkb committed
Showing with 9 additions and 10 deletions.
  1. +2 −5 chunk.ml
  2. +0 −1 chunk.mli
  3. +1 −1 error_report.ml
  4. +4 −2 parsing/location.ml
  5. +2 −1 parsing/location.mli
View
7 chunk.ml
@@ -9,9 +9,6 @@ type t = item History.t
exception Malformed_module of Location.t
exception Invalid_chunk
-exception Warning of Location.t * string
-
-let wrap_warnings = List.rev_map (fun (l,s) -> Warning (l,s))
let eof_lexer _ = Chunk_parser.EOF
let fail_lexer _ = failwith "lexer ended"
@@ -130,8 +127,8 @@ let sync outlines chunks =
| Some ({ Outline.kind ; Outline.tokens },outlines') ->
let chunk =
match Location.catch_warnings (fun () -> sync_step kind tokens chunks) with
- | warnings, Misc.Inr item -> wrap_warnings warnings, item
- | warnings, Misc.Inl exn -> exn :: wrap_warnings warnings, None
+ | warnings, Misc.Inr item -> warnings, item
+ | warnings, Misc.Inl exn -> exn :: warnings, None
in
let chunks' = History.(insert (Sync.at outlines', chunk) chunks) in
aux outlines' chunks'
View
1 chunk.mli
@@ -14,7 +14,6 @@ and t = item History.t
exception Malformed_module of Location.t
exception Invalid_chunk
-exception Warning of Location.t * string
val sync_step : Outline_utils.kind -> Outline.token list -> t -> item_desc option
val sync : Outline.t -> t -> t
View
2 error_report.ml
@@ -48,7 +48,7 @@ let strict_to_json = function
Some (format ~valid:true ~where:"parser" ~loc (to_string ()))
| Outline.Parse_error loc ->
Some (format ~valid:true ~where:"parser" ~loc "Parse error")
- | Chunk.Warning (loc, msg) ->
+ | Location.Warning (loc, msg) ->
Some (format ~valid:true ~where:"warning" ~loc msg)
| Chunk.Malformed_module loc ->
Some (format ~valid:true ~where:"warning" ~loc "Malformed module")
View
6 parsing/location.ml
@@ -270,7 +270,9 @@ let print_warning loc ppf w =
end
;;
-let warnings : (t * string) list ref option ref = ref None
+exception Warning of t * string
+
+let warnings : exn list ref option ref = ref None
let prerr_warning loc w =
match !warnings with
@@ -280,7 +282,7 @@ let prerr_warning loc w =
print_warning loc ppf w;
match to_string () with
| "" -> ()
- | s -> l := (loc,s) :: !l
+ | s -> l := Warning (loc,s) :: !l
let catch_warnings f =
let caught = ref [] in
View
3 parsing/location.mli
@@ -56,7 +56,8 @@ val print_error_cur_file: formatter -> unit
val print_warning: t -> formatter -> Warnings.t -> unit
val prerr_warning : t -> Warnings.t -> unit
-val catch_warnings : (unit -> 'a) -> (t * string) list * (exn, 'a) Misc.sum
+exception Warning of t * string
+val catch_warnings : (unit -> 'a) -> exn list * (exn, 'a) Misc.sum
val echo_eof: unit -> unit
val reset: unit -> unit

0 comments on commit 29f9954

Please sign in to comment.
Something went wrong with that request. Please try again.