1234567891011121314151617181920212223242526272829303132333435363738(**
* Some of this was coppied from @whitequark's m17n project.
*)(*
* Portions Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)lettransmogrify_exnexntemplate=assert(Obj.tag(Obj.reprexn)=0);Obj.set_field(Obj.reprexn)0(Obj.field(Obj.reprtemplate)0);exnletextract_exnsrcname=tryignore(!Toploop.parse_toplevel_phrase(Lexing.from_stringsrc));assertfalsewith|exn->assert(Printexc.exn_slot_nameexn=name);exnletexn_Lexer_Error=extract_exn"\128""Lexer.Error"letexn_Syntaxerr_Error=extract_exn"fun""Syntaxerr.Error"letcorrectly_catch_parse_errorsfnlexbuf=(*let kind = if !Toploop.input_name = "//toplevel//" then `Toplevel else
`Batch in*)fnlexbuf(*with exn when kind = `Toplevel -> (* In expunged toplevel, we have a
split-brain situation where toplevel and m17n have different internal IDs for
the "same" exceptions. Fixup. *) raise (match exn with (* FIXME... Maybe? *)
(*| Reason_lexer.Error _ -> transmogrify_exn exn exn_Lexer_Error*) |
Syntaxerr.Error _ -> transmogrify_exn exn exn_Syntaxerr_Error |
Reason_syntax_util.Error (loc, _) -> transmogrify_exn
(Syntaxerr.Error(Syntaxerr.Other loc)) exn_Syntaxerr_Error | _ -> exn) *)