Project

General

Profile

Revision 55963629 src/tools/importer/main_lustre_importer.ml

View differences:

src/tools/importer/main_lustre_importer.ml
9 9
In a first step, lustrei -vhdl -print myvhdl.json shall print the VHDL model in stdout
10 10

  
11 11
 *)
12

  
12
(*
13 13
open Vhdl_ast
14 14
open Vhdl_test
15
       
15
  *)
16
open Yojson.Safe
17
open Vhdl_deriving_yojson
18
open Vhdl_json_lib
19
open Printf
20

  
16 21
let _ =
17 22
(*
18 23
  (* Load model with Yojson *)
......
25 30
  Format.printf "Loaded VHDL:@.%a@." pp_vhdl_design vhdl
26 31
 *)
27 32

  
28
  let vhdl = design1 in
29
  Format.printf "Loaded VHDL:@.%a@." pp_vhdl_design vhdl;
30
  ()
33
  let vhdl_json = from_file Sys.argv.(1) in
34
  Format.printf "Original file:\n%s\n\n" (pretty_to_string vhdl_json);
35

  
36
  (*let vhdl = design1 in
37
  Format.printf "Loaded VHDL:@.%a@." pp_vhdl_design vhdl;*)
38

  
39
  let vhdl1_json = vhdl_json |> 
40
                   prune_str "TOKEN" |>
41
                   prune_str "IDENTIFIER" |>
42
                   prune_str "SUBTYPE_INDICATION" |>
43
                   prune_null_assoc |>
44
                   to_list_content_str "DESIGN_UNIT" |>
45
                   to_list_content_str "INTERFACE_VARIABLE_DECLARATION" |>
46
                   flatten_ivd |>
47
                   to_list_str "ARCHITECTURE_BODY" |>
48
                   to_list_str "ARCHITECTURE_DECLARATIVE_PART" |>
49
                   to_list_str "ARCHITECTURE_STATEMENT_PART" |>
50
                   to_list_str "ENTITY_DECLARATION" |>
51
                   to_list_str "PACKAGE_DECLARATION" in
52
  Format.printf "Preprocessed json:\n";
53
  Format.printf "%s\n\n" (pretty_to_string vhdl1_json);
54
  List.iter (Format.printf "%s\n") (print_depth vhdl1_json 5 "");
55

  
56
  to_file (Sys.argv.(1)^".out.json") vhdl1_json;
57

  
58
  match vhdl_file_t_of_yojson vhdl1_json with
59
    Ok x -> Format.printf "Parsed VHDL: \n%s\n" (pretty_to_string (vhdl_file_t_to_yojson x))
60
  | Error e -> failwith e;

Also available in: Unified diff