Revision 57ecad58
Added by Christophe Garion almost 6 years ago
src/tools/stateflow/main_with_json.ml | ||
---|---|---|
1 |
open Env |
|
2 | 1 |
open Basetypes |
3 | 2 |
open Datatype |
4 |
(* open Interpreter *) |
|
5 | 3 |
open Parser_json |
6 |
(* open Transformer *) |
|
7 |
open Theta |
|
8 |
open CPS_ccode_generator |
|
9 |
open CPS_interpreter |
|
10 |
open CPS_transformer |
|
4 |
open Sys |
|
11 | 5 |
|
12 | 6 |
module ParseExt = |
13 | 7 |
struct |
... | ... | |
18 | 12 |
|
19 | 13 |
module Parse = Parser (ParseExt) |
20 | 14 |
|
21 |
module Prog = |
|
22 |
struct |
|
23 |
let json = Yojson.Basic.from_file "GPCA_Alarm_Alarm_SFIR_pp.json" |
|
24 |
let Program (init, defs, vars) = Parse.parse_prog json |
|
25 |
let prog = Parse.parse_prog json |
|
26 |
(* let user_vars = Parse.parse_variables json *) |
|
27 |
(*let _ = Format.printf "Model definitions@.%a@.####" Simulink.pp_src defs; ()*) |
|
28 |
end |
|
29 |
|
|
30 |
module Transformer = |
|
31 |
(* CPS_ccode_generator.LustrePrinter (Program) *) |
|
32 |
CodeGenerator |
|
33 |
(* CPS_ccode_generator.Evaluator *) |
|
34 |
|
|
35 |
module Interp = Interpreter (Transformer) |
|
36 |
|
|
37 |
module KenvTheta = KenvTheta (Transformer) |
|
38 |
|
|
39 |
module Modularity : KenvTheta.ModularType = |
|
40 |
struct |
|
41 |
let modular : type b. (path_t, b, bool) tag_t -> path_t -> b = |
|
42 |
fun tag -> |
|
43 |
match tag with |
|
44 |
| E -> (fun p p' f -> true) |
|
45 |
| D -> (fun p -> true) |
|
46 |
| X -> (fun p f -> true) |
|
47 |
end |
|
48 |
|
|
49 |
module Tables = KenvTheta.MemoThetaTables () |
|
50 |
|
|
51 |
module Thetaify = KenvTheta.ModularThetaify (Tables) (Modularity) |
|
52 |
|
|
53 |
module EvalProg = Interp.Evaluation (Thetaify) (Prog) |
|
54 |
|
|
55 | 15 |
let main () = |
56 | 16 |
begin |
57 |
SF.pp_prog Format.std_formatter (Parse.parse_prog Prog.json);
|
|
58 |
(* SF.pp_vars Format.std_formatter (Parse.parse_variables Prog.json); *)
|
|
17 |
let json = Yojson.Basic.from_file Sys.argv.(1) in
|
|
18 |
SF.pp_prog Format.std_formatter (Parse.parse_prog json);
|
|
59 | 19 |
end |
60 | 20 |
|
61 | 21 |
let _ = main () |
Also available in: Unified diff
parser-json: clean main program + add pp for vars