Project

General

Profile

« Previous | Next » 

Revision 22a34b49

Added by Christophe Garion about 6 years ago

  • ID 22a34b49c4a5001b78734ad5ffae8704f9a89aaa
  • Parent 1d0fd52b

json-parser: starting changing datatypes

View differences:

src/tools/stateflow/json-parser/main_parse_json_file.ml
7 7
module ParseExt =
8 8
struct
9 9
  open Yojson.Basic
10
    
11
      
10

  
11

  
12 12
  let remove_quotes s =
13 13
    let len = String.length s in
14 14
    if String.get s 0 = '"' && String.get s (len-1) = '"' then
......
23 23
	let s = json |> Util.member key |> to_string in
24 24
	try
25 25
	  let s'= remove_quotes s in
26
	  if s' = "" then [] else  
26
	  if s' = "" then [] else
27 27
	    let lexbuf = Lexing.from_string s' in
28 28
	    Parser_lustre.vdecl_list Lexer_lustre.token lexbuf
29 29
	with _ -> (Format.eprintf "Issues parsing decls for %s: %s@.@?" key s; assert false)
30
	  
30

  
31 31
      in
32 32
      let inputs = get_vdecls "inputs" json in
33 33
      let outputs = get_vdecls "outputs" json in
34 34
      let variables = get_vdecls "variables" json in
35 35
      inputs, outputs, variables
36
      
36

  
37 37
  (* Protecting the generation of condition/action in case of an empty string
38 38
     instead of a subtree *)
39 39
  let protect default parse_fun embed_fun json =
......
56 56
	"Unable to explore json subtree: empty string %s@." (to_string json);
57 57
      default
58 58
    )
59
      
59

  
60 60
  let parse_condition =
61 61
    protect
62 62
      Condition.tru
......
68 68
	cinputs = in_;
69 69
	coutputs = out_;
70 70
	cvariables = locals_;
71
	  
71

  
72 72
      })
73
    
73

  
74 74
  let parse_action =
75 75
    protect Action.nil Parser_lustre.stmt_list
76 76
      (fun (stmts, asserts, annots) (in_, out_, locals_) ->
......
85 85
	    avariables = locals_;
86 86
	  })
87 87
      )
88
      
88

  
89 89
  let parse_event json  = Some Yojson.Basic.(json |> to_string)
90 90
end
91 91

  
......
121 121
      | _ (* 0 *) -> false, false ,false
122 122
    in
123 123
    let state_vars = Datatype.SF.states Model.model in
124
    let global_vars = Datatype.SF.global_vars Model.model in
125
    
124
    (* let global_vars = Datatype.SF.global_vars Model.model in *)
125
    let global_vars = [] in
126

  
126 127
    let module T = CPS_lustre_generator.LustrePrinter (struct
127 128
      let state_vars = state_vars
128
      let global_vars = global_vars 
129
      let global_vars = global_vars
129 130
    end) in
130 131
    let module Sem = CPS.Semantics (T) (Model) in
131 132
    let prog = Sem.code_gen modularmode in
......
144 145
    let auto_fmt = Format.formatter_of_out_channel auto_out in
145 146
    Format.fprintf auto_fmt "%a@." Printers.pp_prog prog;
146 147
    Format.eprintf "Print initial lustre model with automaton in sf_gen_test_auto.lus@.";
147
    
148

  
148 149
    let prog, deps = Compiler_stages.stage1 prog "" "" in
149 150

  
150 151
    (* Format.printf "%a@." Printers.pp_prog prog; *)

Also available in: Unified diff