Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / parse.ml @ 55537f48

History | View | Annotate | Download (1.36 KB)

1 a2d97a3e 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 22fe1c93 ploc
12
exception Syntax_err of Location.t
13
14
open Format
15 b1655a21 xthirioux
open LustreSpec
16
open Corelang
17
18 22fe1c93 ploc
let report_error loc =
19
  Location.print loc;
20
  print_string "Syntax error\n"
21 ef34b4ae xthirioux
22
let header parsing_fun token_fun lexbuf =
23 89b9e25c xthirioux
  try
24 ef34b4ae xthirioux
    let ast = parsing_fun token_fun lexbuf in
25 89b9e25c 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 22fe1c93 ploc
32 89b9e25c xthirioux
let prog parsing_fun token_fun lexbuf =
33 22fe1c93 ploc
  try
34
    let ast = parsing_fun token_fun lexbuf in
35
    Parsing.clear_parser ();
36
    ast
37
  with
38 21485807 xthirioux
  | Parsing.Parse_error ->
39
    let loc = Location.curr lexbuf in
40
    raise (Syntax_err loc)
41 22fe1c93 ploc
42
(* Local Variables: *)
43
(* compile-command:"make -C .." *)
44
(* End: *)