Revision 430dc9ee
Added by Christophe Garion over 4 years ago
src/tools/stateflow/json-parser/json_parser.ml | ||
---|---|---|
1 | 1 |
open Yojson |
2 | 2 |
open Datatype |
3 |
(* open Simulink *) |
|
4 |
(* open Transformer *) |
|
5 | 3 |
open Basetypes |
6 | 4 |
open Basic |
7 | 5 |
open Corelang |
8 |
(* open CPS *) |
|
9 | 6 |
open LustreSpec |
10 | 7 |
open Str |
11 | 8 |
|
... | ... | |
75 | 72 |
} |
76 | 73 |
and parse_dest json = |
77 | 74 |
Logs.debug (fun m -> m "parse_dest"); |
78 |
(json |> member "type" |> to_string |> |
|
75 |
let dest_type = json |> member "type" |> to_string in |
|
76 |
(dest_type |> |
|
79 | 77 |
(function |
80 | 78 |
| "State" -> (fun p -> DPath p) |
81 | 79 |
| "Junction" -> (fun j -> DJunction (path_concat j)) |
82 |
| _ -> assert false))
|
|
80 |
| _ -> failwith ("Invalid destination type: " ^ dest_type)))
|
|
83 | 81 |
(json |> member "name" |> parse_path) |
84 | 82 |
and parse_internal_composition json = |
85 | 83 |
Logs.debug (fun m -> m "parse_internal_composition"); |
86 |
(json |> member "type" |> to_string |> |
|
84 |
let state_type = json |> member "type" |> to_string in |
|
85 |
(state_type |> |
|
87 | 86 |
(function |
88 | 87 |
| "EXCLUSIVE_OR" -> (fun tinit substates -> Or (tinit, substates)) |
89 | 88 |
| "PARALLEL_AND" -> (fun tinit substates -> assert (tinit = []); And (substates)) |
90 |
| _ -> assert false))
|
|
89 |
| _ -> failwith ("Invalid state type: " ^ state_type)))
|
|
91 | 90 |
(json |> member "tinit" |> parse_tinit) |
92 | 91 |
(json |> member "substates" |> to_list |> List.map to_string) |
93 | 92 |
and parse_tinit json = |
Also available in: Unified diff
json-parser: replace assert with exceptions