package rtop

  1. Overview
  2. Docs
Reason toplevel

Install

Dune Dependency

Authors

Maintainers

Sources

reason-3.14.0.tbz
sha256=1d09ba24a0594745ab6b38b4d5f81ead8565b73cb69ad46af1c2c26f8d324f00
sha512=542d63c99ab976d011ca39953c022bdd2120177d5905df7ee6ff9623ec4d52c09a323ff7aec95fba5e71611c3850a88172e1c2be94ce68d966b5680ddd436494

doc/src/rtop/reason_util.ml.html

Source file reason_util.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
36
37
38
(**
 * 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.
 *)

let transmogrify_exn exn template =
  assert (Obj.tag (Obj.repr exn) = 0);
  Obj.set_field (Obj.repr exn) 0 (Obj.field (Obj.repr template) 0);
  exn

let extract_exn src name =
  try
    ignore (!Toploop.parse_toplevel_phrase (Lexing.from_string src));
    assert false
  with
  | exn ->
    assert (Printexc.exn_slot_name exn = name);
    exn

let exn_Lexer_Error = extract_exn "\128" "Lexer.Error"
let exn_Syntaxerr_Error = extract_exn "fun" "Syntaxerr.Error"

let correctly_catch_parse_errors fn lexbuf =
  (*let kind = if !Toploop.input_name = "//toplevel//" then `Toplevel else
    `Batch in*)
  fn lexbuf
(*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) *)
OCaml

Innovation. Community. Security.