Project

General

Profile

« Previous | Next » 

Revision 9d3bcc89

Added by Pierre-Loïc Garoche 3 months ago

Adapted json-parser from stateflow tool to the new signatures

View differences:

src/tools/stateflow/json-parser/json_parser.ml
1 1
open Basetypes
2 2
open Corelang
3 3
open Datatype
4
open LustreSpec
4
(*open LustreSpec*)
5
open Lustre_types
5 6
open Str
6 7
open Yojson
7 8
open Basic
......
116 117
      let l = matched_group 1 s in
117 118
      let r = matched_group 2 s in
118 119
      let e = matched_group 4 s in
119
      Const_real (Num.num_of_string (l ^ r),
120
                  String.length r + (-1 * int_of_string e),
121
                  s)
120
      Const_real (Real.create (l ^ r) 
121
                    (String.length r + (-1 * int_of_string e))
122
                    s)
122 123
    else
123 124
    if string_match real_regexp_simp s 0 then
124 125
      let l = matched_group 1 s in
125 126
      let r = matched_group 2 s in
126
      Const_real (Num.num_of_string (l ^ r), String.length r, s)
127
      Const_real (Real.create (l ^ r)  (String.length r) s)
127 128
    else
128 129
      raise (JSON_parse_error ("Invalid real constant " ^ s))
129 130
  and lustre_datatype_of_json json location =
......
150 151
    Logs.debug (fun m -> m "parse_variable %s" (json |> member "name" |> to_string));
151 152
    let location                  = Location.dummy_loc in
152 153
    let (datatype, initial_value) = lustre_datatype_of_json json location in
153
    mkvar_decl location ~orig:true
154
      ( json |> member "name" |> to_string,
155
        {ty_dec_desc = datatype;  ty_dec_loc = location},
156
        {ck_dec_desc = Ckdec_any; ck_dec_loc = location},
157
        true,
158
        Some initial_value
159
      )
154
    let vdecl = 
155
      mkvar_decl location ~orig:true
156
        ( json |> member "name" |> to_string,
157
          {ty_dec_desc = datatype;  ty_dec_loc = location},
158
          {ck_dec_desc = Ckdec_any; ck_dec_loc = location},
159
          true,
160
          Some initial_value,
161
          None (* no parentid *)
162
        )
163
    in
164
    { variable = vdecl; init_val = initial_value }
160 165
end
161 166

  

Also available in: Unified diff