forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.ml
36 lines (32 loc) · 1.64 KB
/
parse.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
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
(* Entry points in the parser *)
let wrap parsing_fun lexbuf =
try
Docstrings.init ();
Lexer.init ();
let ast = parsing_fun Lexer.token lexbuf in
Parsing.clear_parser();
Docstrings.warn_bad_docstrings ();
ast
with
| Parsing.Parse_error | Syntaxerr.Escape_error ->
let loc = Location.curr lexbuf in
raise(Syntaxerr.Error(Syntaxerr.Other loc))
let implementation = wrap Parser.implementation
and interface = wrap Parser.interface
and core_type = wrap Parser.parse_core_type
and expression = wrap Parser.parse_expression
and pattern = wrap Parser.parse_pattern