Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / parse.ml @ 29ced7be

History | View | Annotate | Download (1.36 KB)

1 b38ffff3 ploc
(********************************************************************)
2
(*                                                                  *)
3
(*  The LustreC compiler toolset   /  The LustreC Development Team  *)
4
(*  Copyright 2012 -    --   ONERA - CNRS - INPT                    *)
5
(*                                                                  *)
6
(*  LustreC is free software, distributed WITHOUT ANY WARRANTY      *)
7
(*  under the terms of the GNU Lesser General Public License        *)
8
(*  version 2.1.                                                    *)
9
(*                                                                  *)
10
(********************************************************************)
11 0cbf0839 ploc
12
exception Syntax_err of Location.t
13
14
open Format
15 6aeb3388 xthirioux
open LustreSpec
16
open Corelang
17
18 0cbf0839 ploc
let report_error loc =
19
  Location.print loc;
20
  print_string "Syntax error\n"
21 70e1006b xthirioux
22
let header parsing_fun token_fun lexbuf =
23 2ea1e4a6 xthirioux
  try
24 70e1006b xthirioux
    let ast = parsing_fun token_fun lexbuf in
25 2ea1e4a6 xthirioux
    Parsing.clear_parser ();
26
    ast
27
  with
28
  | Parsing.Parse_error ->
29
    let loc = Location.curr lexbuf in
30
    raise (Syntax_err loc)
31 0cbf0839 ploc
32 2ea1e4a6 xthirioux
let prog parsing_fun token_fun lexbuf =
33 0cbf0839 ploc
  try
34
    let ast = parsing_fun token_fun lexbuf in
35
    Parsing.clear_parser ();
36
    ast
37
  with
38 6affc9f5 xthirioux
  | Parsing.Parse_error ->
39
    let loc = Location.curr lexbuf in
40
    raise (Syntax_err loc)
41 0cbf0839 ploc
42
(* Local Variables: *)
43
(* compile-command:"make -C .." *)
44
(* End: *)