source: Deliverables/D2.3/8051-memoryspaces-branch/src/acc.ml @ 461

Last change on this file since 461 was 460, checked in by campbell, 9 years ago

Port memory spaces changes to latest prototype compiler.

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 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.is_matita_output_enabled () then
37      Languages.save_matita filename (input_ast :: target_asts);
38    (if Options.annotation_requested () then
39       let annotated_input_ast = Languages.annotate input_ast final_ast in
40       Languages.save filename annotated_input_ast);
41    (if Options.is_debug_enabled () then 
42      List.iter (Languages.save filename) intermediate_asts);
43    if Options.interpretation_requested () || Options.is_debug_enabled () then
44      begin
45        let asts = input_ast :: target_asts in
46        let label_traces = List.map Languages.interpret asts in
47          Printf.eprintf "Checking execution traces...";
48          Checker.same_traces (List.combine asts label_traces);
49          Printf.eprintf "OK.\n%!";
50      end
51
52let _ =
53  if Options.is_dev_test_enabled () then Dev_test.do_dev_test input_files
54  else List.iter process input_files
Note: See TracBrowser for help on using the repository browser.