source: Deliverables/D2.3/8051/src/acc.ml @ 453

Last change on this file since 453 was 453, checked in by ayache, 9 years ago

Import of the Paris's sources.

File size: 1.8 KB
Line 
1open Options
2
3(** Parse the command line. *)
4let input_files = OptionsParsing.results ()
5
6(** For each input file of the source language:
7
8    1. Parse.
9
10    2. Labellize.
11       (Only if {!Options.annotation_requested})
12
13    3. Compile to the target language.
14       (And keep track of annotations if required).
15 
16    4. Annotate the input program with collected costs.
17
18    5. Save the annotated input program.
19
20    Optionnally, we can interpret the intermediate programs
21    if {!Options.interpretation_requested}.
22*)
23let process filename = 
24  let src_language = Options.get_source_language () in
25  let tgt_language = Options.get_target_language () in
26  let input_ast    = Languages.parse src_language filename in 
27  let input_ast    = Languages.labelize input_ast in
28  let target_asts =
29    (** If debugging is enabled, the compilation function returns all
30        the intermediate programs. *)
31    Languages.compile (Options.is_debug_enabled ()) 
32      src_language tgt_language input_ast
33  in
34  let final_ast, intermediate_asts = Misc.ListExt.cut_last target_asts in
35    Languages.save filename final_ast;
36    (if Options.annotation_requested () then
37       let annotated_input_ast = Languages.annotate input_ast final_ast in
38       Languages.save filename annotated_input_ast);
39    (if Options.is_debug_enabled () then 
40      List.iter (Languages.save filename) intermediate_asts);
41    if Options.interpretation_requested () || Options.is_debug_enabled () then
42      begin
43        let asts = input_ast :: target_asts in
44        let label_traces = List.map Languages.interpret asts in
45          Printf.eprintf "Checking execution traces...";
46          Checker.same_traces (List.combine asts label_traces);
47          Printf.eprintf "OK.\n%!";
48      end
49
50let _ =
51  if Options.is_dev_test_enabled () then Dev_test.do_dev_test input_files
52  else List.iter process input_files
Note: See TracBrowser for help on using the repository browser.