Project

General

Profile

Download (2.24 KB) Statistics
| Branch: | Tag: | Revision:
1
open Log
2
open Format
3

    
4
let check_stateless_decls decls =
5
  report ~level:1 (fun fmt -> fprintf fmt ".. checking stateless/stateful status@,@?");
6
  try
7
    Stateless.check_prog decls
8
  with (Stateless.Error (loc, err)) as exc ->
9
    Format.eprintf "Stateless status error at loc %a: %a@]@."
10
      Location.pp_loc loc
11
      Stateless.pp_error err;
12
    raise exc
13

    
14
let type_decls env decls =  
15
  report ~level:1 (fun fmt -> fprintf fmt ".. typing@,@?");
16
  let new_env = 
17
    begin
18
      try
19
	Typing.type_prog env decls
20
      with (Types.Error (loc,err)) as exc ->
21
	Format.eprintf "Typing error at loc %a: %a@]@."
22
	  Location.pp_loc loc
23
	  Types.pp_error err;
24
	raise exc
25
    end 
26
  in
27
  if !Options.print_types then
28
    report ~level:1 (fun fmt -> fprintf fmt "@[<v 2>@ %a@]@,@?" Corelang.pp_prog_type decls);
29
  new_env
30
      
31
let clock_decls env decls = 
32
  report ~level:1 (fun fmt -> fprintf fmt ".. clock calculus@,@?");
33
  let new_env =
34
    begin
35
      try
36
	Clock_calculus.clock_prog env decls
37
      with (Clocks.Error (loc,err)) as exc ->
38
	Location.print loc;
39
	eprintf "Clock calculus error at loc %a: %a@]@." Location.pp_loc loc Clocks.pp_error err;
40
	raise exc
41
    end
42
  in
43
  if !Options.print_clocks then
44
    report ~level:1 (fun fmt -> fprintf fmt "@[<v 2>@ %a@]@,@?" Corelang.pp_prog_clock decls);
45
  new_env
46

    
47
(* Loading Lusi file and filling type tables with parsed
48
   functions/nodes *)
49
let load_lusi own filename =
50
  Location.input_name := filename;
51
  let lexbuf = Lexing.from_channel (open_in filename) in
52
  Location.init lexbuf filename;
53
  (* Parsing *)
54
  report ~level:1 (fun fmt -> fprintf fmt "@[<v>.. parsing header file %s@,@?" filename);
55
  try
56
    Parse.header own Parser_lustre.header Lexer_lustre.token lexbuf
57
  with
58
  | (Lexer_lustre.Error err) | (Parse.Syntax_err err) as exc -> 
59
    Parse.report_error err;
60
    raise exc
61
  | Corelang.Error (loc, err) as exc ->
62
     Format.eprintf "Parsing error at loc %a: %a@]@."
63
       Location.pp_loc loc
64
       Corelang.pp_error err;
65
     raise exc
66

    
67
let check_lusi header =
68
  let new_tenv = type_decls Basic_library.type_env header in   (* Typing *)
69
  let new_cenv = clock_decls Basic_library.clock_env header in   (* Clock calculus *)
70
  header, new_tenv, new_cenv
71

    
72
(* Local Variables: *)
73
(* compile-command:"make -C .." *)
74
(* End: *)
(28-28/59)