source: Deliverables/D2.2/8051/src/acc.ml @ 486

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

Deliverable D2.2

File size: 1.9 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 _ = Printf.eprintf "Processing %s :\n" filename in
25  let src_language = Options.get_source_language () in
26  let tgt_language = Options.get_target_language () in
27  let input_ast    = Languages.parse src_language filename in 
28  let input_ast    = Languages.labelize input_ast in
29  let target_asts =
30    (** If debugging is enabled, the compilation function returns all
31        the intermediate programs. *)
32    Languages.compile (Options.is_debug_enabled ()) 
33      src_language tgt_language input_ast
34  in
35  let final_ast, intermediate_asts = Misc.ListExt.cut_last target_asts in
36    Languages.save filename final_ast;
37    (if Options.annotation_requested () then
38       let annotated_input_ast = Languages.annotate input_ast final_ast in
39       Languages.save filename annotated_input_ast);
40    (if Options.is_debug_enabled () then 
41      List.iter (Languages.save filename) intermediate_asts);
42    if Options.interpretation_requested () || Options.is_debug_enabled () then
43      begin
44        let asts = input_ast :: target_asts in
45        let label_traces = List.map Languages.interpret asts in
46          Printf.eprintf "Checking execution traces...";
47          Checker.same_traces (List.combine asts label_traces);
48          Printf.eprintf "OK.\n%!";
49      end
50
51let _ =
52  if Options.is_dev_test_enabled () then Dev_test.do_dev_test input_files
53  else List.iter process input_files
Note: See TracBrowser for help on using the repository browser.