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
|
open Format
|
12 |
b1655a21
|
xthirioux
|
|
13 |
04a63d25
|
xthirioux
|
type error =
|
14 |
|
|
| Undefined_token of string
|
15 |
|
|
| Unexpected_eof
|
16 |
|
|
| Unfinished_string
|
17 |
|
|
| Unfinished_comment
|
18 |
|
|
| Syntax_error
|
19 |
9ae027f8
|
ploc
|
| String_Syntax_error of string
|
20 |
04a63d25
|
xthirioux
|
| Unfinished_annot
|
21 |
|
|
| Unfinished_node_spec
|
22 |
|
|
| Annot_error of string
|
23 |
|
|
| Node_spec_error of string
|
24 |
|
|
|
25 |
|
|
exception Error of (Location.t * error)
|
26 |
|
|
|
27 |
|
|
let pp_error fmt err =
|
28 |
|
|
match err with
|
29 |
57c96fb7
|
Lélio Brun
|
| Unexpected_eof ->
|
30 |
|
|
fprintf fmt "unexpected end of file"
|
31 |
|
|
| Undefined_token tok ->
|
32 |
|
|
fprintf fmt "undefined token '%s'" tok
|
33 |
|
|
| Unfinished_string ->
|
34 |
|
|
fprintf fmt "unfinished string"
|
35 |
|
|
| Unfinished_comment ->
|
36 |
|
|
fprintf fmt "unfinished comment"
|
37 |
|
|
| Syntax_error ->
|
38 |
|
|
fprintf fmt "syntax error"
|
39 |
|
|
| String_Syntax_error s ->
|
40 |
|
|
fprintf fmt "syntax error in %s" s
|
41 |
|
|
| Unfinished_annot ->
|
42 |
|
|
fprintf fmt "unfinished annotation"
|
43 |
|
|
| Unfinished_node_spec ->
|
44 |
|
|
fprintf fmt "unfinished node specification"
|
45 |
|
|
| Annot_error s ->
|
46 |
|
|
fprintf fmt "impossible to parse the following annotation:@.%s@.@?" s
|
47 |
|
|
| Node_spec_error s ->
|
48 |
|
|
fprintf fmt "Impossible to parse the following node specification:@.%s@.@?" s
|
49 |
04a63d25
|
xthirioux
|
|
50 |
|
|
let report_error (loc, err) =
|
51 |
57c96fb7
|
Lélio Brun
|
eprintf "Syntax error: %a@."
|
52 |
|
|
(* pp_error err *)
|
53 |
04a63d25
|
xthirioux
|
Location.pp_loc loc
|
54 |
ef34b4ae
|
xthirioux
|
|
55 |
|
|
let header parsing_fun token_fun lexbuf =
|
56 |
57c96fb7
|
Lélio Brun
|
try parsing_fun token_fun lexbuf with _ ->
|
57 |
89b9e25c
|
xthirioux
|
let loc = Location.curr lexbuf in
|
58 |
57c96fb7
|
Lélio Brun
|
let e = loc, Syntax_error in
|
59 |
|
|
report_error e;
|
60 |
|
|
raise (Error e)
|
61 |
22fe1c93
|
ploc
|
|
62 |
89b9e25c
|
xthirioux
|
let prog parsing_fun token_fun lexbuf =
|
63 |
57c96fb7
|
Lélio Brun
|
try parsing_fun token_fun lexbuf with err ->
|
64 |
21485807
|
xthirioux
|
let loc = Location.curr lexbuf in
|
65 |
57c96fb7
|
Lélio Brun
|
let e = loc, Syntax_error in
|
66 |
|
|
report_error e;
|
67 |
|
|
raise (Error e)
|
68 |
22fe1c93
|
ploc
|
|
69 |
|
|
(* Local Variables: *)
|
70 |
|
|
(* compile-command:"make -C .." *)
|
71 |
|
|
(* End: *)
|