summaryrefslogtreecommitdiff
path: root/src/main.ml
blob: 444a416ec5105d51195c73ef0d536d0018f7e7a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
open Types
open CfimAst
open CfimOfJson

type declaration =
  | Type of TypeDefId.id
  | Fun of FunDefId.id
  | RecTypes of TypeDefId.id list
  | RecFuns of FunDefId.id list

type rust_module = {
  declarations : declaration list;
  types : type_def TypeDefId.vector;
  functions : fun_def FunDefId.vector;
}

let () =
  (* let json = Yojson.Basic.from_string "{\"Return\"}" in
     print_endline (Yojson.Basic.show json)*)
  let json = Yojson.Basic.from_file "../charon/charon/tests/test1.cfim" in
  match cfim_module_of_json json with
  | Error s -> Printf.printf "error: %s\n" s
  | Ok _ast -> print_endline "Ok"
(*  let json = Yojson.Basic.from_string "{\"Statement\":\"Return\"}" in
  print_endline (Yojson.Basic.show json)*)

(*  let json = Yojson.Safe.from_file "../charon/charon/tests/test1.cfim" in
  match cfim_module_of_json json with
  | Error s -> Printf.printf "error: %s\n" s
  | Ok _ast -> print_endline "Ok"*)

(*  let json = Yojson.Basic.from_file "../charon/charon/tests/test1.cfim" in *)
(*  let _json1 = Yojson.Safe.from_file "../charon/charon/tests/test1.cfim" in
  let st1 = Return in
  let json1 = statement_to_yojson st1 in
  print_endline (Yojson.Safe.to_string json1);
  let e1 = Statement Return in
  let e1_json = expression_to_yojson e1 in
  print_endline (Yojson.Safe.to_string e1_json);
  let int_ty = Isize in
  let int_ty_json = integer_type_to_yojson int_ty in
  print_endline (Yojson.Safe.to_string int_ty_json);
  let json2 = Yojson.Safe.from_string "[\"Return\"]" in
  match statement_of_yojson json2 with
  | Error s -> Printf.printf "error: %s\n" s
  | Ok _ast -> print_endline "ast"*)
(*  match rust_module_of_yojson json with
  | Error s -> Printf.printf "error: %s\n" s
  | Ok _ast -> print_endline "ast"*)